Skip to content

Commit c75a018

Browse files
committed
Land rapid7#3897 - Fix check for apache_mod_cgi_bash_env & apache_mod_cgi_bash_env_exec
2 parents 80d9af9 + 3259509 commit c75a018

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

modules/auxiliary/scanner/http/apache_mod_cgi_bash_env.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,25 @@ def check_host(ip)
5757
:name => self.name,
5858
:refs => self.references
5959
)
60-
Exploit::CheckCode::Vulnerable
60+
return Exploit::CheckCode::Vulnerable
61+
elsif res && res.code == 500
62+
injected_res_code = res.code
6163
else
62-
Exploit::CheckCode::Safe
64+
return Exploit::CheckCode::Safe
6365
end
66+
67+
res = send_request_cgi({
68+
'method' => datastore['METHOD'],
69+
'uri' => normalize_uri(target_uri.path.to_s)
70+
})
71+
72+
if res && injected_res_code == res.code
73+
return Exploit::CheckCode::Unknown
74+
elsif res && injected_res_code != res.code
75+
return Exploit::CheckCode::Appears
76+
end
77+
78+
Exploit::CheckCode::Unknown
6479
end
6580

6681
def run_host(ip)

modules/exploits/multi/http/apache_mod_cgi_bash_env_exec.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,25 @@ def check
6969
res = req("echo #{marker}")
7070

7171
if res && res.body.include?(marker * 3)
72-
Exploit::CheckCode::Vulnerable
72+
return Exploit::CheckCode::Vulnerable
73+
elsif res && res.code == 500
74+
injected_res_code = res.code
7375
else
74-
Exploit::CheckCode::Safe
76+
return Exploit::CheckCode::Safe
7577
end
78+
79+
res = send_request_cgi({
80+
'method' => datastore['METHOD'],
81+
'uri' => normalize_uri(target_uri.path.to_s)
82+
})
83+
84+
if res && injected_res_code == res.code
85+
return Exploit::CheckCode::Unknown
86+
elsif res && injected_res_code != res.code
87+
return Exploit::CheckCode::Appears
88+
end
89+
90+
Exploit::CheckCode::Unknown
7691
end
7792

7893
def exploit

0 commit comments

Comments
 (0)