Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/documentation/modules/payload/windows/meterpreter/reverse_https.md
Views: 11623
windows/meterpreter/reverse_https is a unique Windows payload for Metasploit Framework. It is capable of doing things like remotely control the file system, sniff, keylog, hashdump, pivoting, run extensions, etc. But the real strength of this is the way it talks to the attacker.
Instead of a stream-based communication model (tied to a specific TCP session), the stager provides a packet-based transaction system instead. You know, kind of like a botnet that we see today. The use of HTTPS also makes the payload communication a little bit harder to detect.
Vulnerable Application
This Meterpreter payload is suitable for the following environments:
Windows x64
Windows x86
Deploying windows/meterpreter/reverse_https
windows/meterpreter/revese_https can be used in two different ways.
As an exploit payload
To check if windows/meterpreter/reverse_https is compatible with the exploit or not, first you can use the info
command on the exploit you want to use:
If the platform field includes Windows, then you can use windows/meterpreter/reverse_https as the payload.
Depending on the module, sometimes you have to select a specific target by first checking the target list, like the following:
If there is a Windows target, use that:
To actually set the payload:
In msfconsole, load the exploit.
Do:
set PAYLOAD windows/meterpreter/reverse_https
Set the
LHOST
OPTION WHICH, which IP the same the payload connect to.Run th exploit
As a standalone
To generate windows/meterpreter/reverse_https, you can do this from msfvenom:
Important Basic Commands
pwd command
The pwd
command allows you to see the current directory you're in on the remote target. Example:
cd command
The cd
command allows you to change directories. Example:
cat command
The cat
command allows you to see the content of a file:
upload command
The upload
command allows you to upload a file to the remote target. For example:
The -r
option for the command also allows you to upload recursively.
download command
The download
command allows you download a file from the remote target to your machine. For example:
search command
The search
command allows you to find files on the remote file system. For example, this demonstrates how to find all text files in the current directory:
Note that without the -d
option, the command will attempt to search in all drives.
The -r
option for the commands allows you to search recursively.
ifconfig/ipconfig command
The ifconfig
command displays the network interfaces on the remote machine:
The command ipconfig
is an alias for ifconfig
.
getuid command
The getuid
command shows you the current user that the payload is running as:
execute command
The execute
command allows you to execute a command or file on the remote machine.
The following example will spawn a calculator:
ps command
The ps
command lists the running processes on the remote machine.
shell command
The shell
command allows you to interact with the remote machine's command prompt. Example:
sysinfo command
The sysinfo
command shows you basic information about the remote machine. Example:
keyscan command
The keyscan_start
command starts the keylogging feature on the remote machine.
keyscan_dump command
The keyscan_dump
command is a keylogger feature. You must use the keyscan_start
command before using this. Example:
keyscan_stop command
The keyscan_stop
command stops the keylogger.
screenshot command
The screenshot
command takes a screenshot of the target machine.
webcan_list command
The webcam_list
commands shows you a list of webcams that you can control. You'll probably want to use this first before using any other webcam commands.
webcam_snap command
The webcam_snap
commands uses the selected webcam to take a picture.
webcam_stream command
The webcam_stream
command basically uses the webcam_snap
command repeatedly to create the streaming effect. There is no sound.
record_mic command
The record_mic
command captures audio on the remote machine.
getsystem command
The getsystem
command attempts to elevate your privilege on the remote machine with one of these techniques:
Named pipe impersonation (in memory)
Named pipe impersonation (dropper)
Token duplication (in memory)
Example:
hashdump command
The hashdump
commands allows you to dump the Windows hashes if there are the right privileges. For sxample:
detach command
The detach
command allows you to temporarily disconnect the Meterpreter session without actually losing it, as the following example demonstrates:
By default, the Meterpreter session will continue to reach back to you for five minutes. If it is unable to connect back after that, it will terminate. You can extend this by setting the SessionCommunicationTimeout
option to your choice. Setting this option to 0 ensures that your session will reattach whenever the target comes back online, as long as the payload handler is running.
Using a Post Module
One of the best things about Meterpreter is you have access to a variety of post exploitation modules, specifically for the multi and Windows categories. Post modules provide you with more capabilities to collect data from the remote machine automatically. For example, you can steal passwords from popular applications and enumerate or modify system settings.
To use a post module from the Meterpreter prompt, simply use the run
command:
It is also possible to run a post module via multiple Meterpreter sessions. To learn how, load the specific post module you wish to run, and enter info -d
to see the basic usage in the documentation.
Using the Post Exploitation API in IRB
To enter IRB, do the following at the Meterpreter prompt:
The client object
The client object in Meterpreter's IRB allows you control or retrieve information about the host. For example, this demonstrates how to obtain the current privilege we're running the payload as:
To explore the client object, there are a few tricks. For example, you can use the #inspect method to inspect it:
You can use the #methods method to see what methods you can use:
To find the source of the method, you can use the #source_location method. For example, say I want to find the source code for the #getuid method:
The first element of the array is the location of the file. The second element is the line number of the method.
Using Railgun
Railgun allows you to use the remote machine's Windows API in Ruby. For example, to create a MessageBox on the target machine, do:
To learn more about using Railgun, please read this wiki.
Routing through the portfwd command
The portfwd command allows you to talk to a remote service like it's local. For example, SMB is a commonly targeted protocol, but by default it is blocked by a firewall. To being able to talk to it, we can portfwd via an active session:
And then talk to the remote SMB service like it's local:
Routing through msfconsole
The route command from the msf prompt can also be used to bypass firewall like portfwd, but it also allows you to connect to hosts on a different network through the compromised machine.
To do that, first off, look at the ifconfig/ipconfig output and determine your pivot point:
Make sure you know the subnet, netmask, and the Meterpreter/session ID. Return to the msf prompt, and establish that route:
At that point, you should have a working pivot. You can use other Metasploit modules to explore or exploit more hosts on the network, or use auxiliary/server/socks4a and Proxychains to allow other third-party tools to do the same.
Meterpreter Stageless Mode
A stageless Meterpreter allows a more economical way to deliver the payload, for cases where a normal one would actually cost too much time and bandwidth in a penetration test. To learn more about this, click on this to read more.
To use the stageless payload, use windows/meterpreter_reverse_https
instead.
Meterpreter Sleep Control
The sleep mode allows the payload on the target machine to be quiet for awhile, mainly in order to avoid suspicious active communication. It also provides better efficiency.
It is very simple to use. At the Meterpreter prompt, simply do:
And that will allow Meterpreter to sleep 20 seconds, and will reconnect as long as the handler remains active (such as running as a background job).
To learn more about this feature, please click here.
Meterpreter Timeout Control
The timeout control basically defines the life span of Meterpreter. To configure it, use the set_timeouts
command:
To see the current timeout configuration, you can use the get_timeouts
command:
To learn more about timeout control, please go here.
Meterpreter Transport Control
Transport Control allows you manage transports on the fly while the payload session is still running. Meterpreter can automatically cycle through the transports when communication fails, or you can do it manually.
To learn more about this, please read this documentation.