{"id":59339,"date":"2024-09-01T04:10:42","date_gmt":"2024-09-01T01:10:42","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180920\/snmp_enum_hp_laserjet.rb.txt"},"modified":"2024-09-01T04:10:42","modified_gmt":"2024-09-01T01:10:42","slug":"hp-laserjet-printer-snmp-enumeration","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/hp-laserjet-printer-snmp-enumeration\/","title":{"rendered":"HP LaserJet Printer SNMP Enumeration"},"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::SNMPClient<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Auxiliary::Scanner<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;HP LaserJet Printer SNMP Enumeration&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module allows enumeration of files previously printed.<br \/>It provides details as filename, client, timestamp and username information.<br \/>The default community used is &#8220;public&#8221;.<br \/>},<br \/>&#8216;References&#8217; =&gt;<br \/>[<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/en.wikipedia.org\/wiki\/Simple_Network_Management_Protocol&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/net-snmp.sourceforge.io\/docs\/man\/snmpwalk.html&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;http:\/\/www.nothink.org\/codes\/snmpcheck\/index.php&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;http:\/\/www.securiteam.com\/securitynews\/5AP0S2KGVS.html&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;http:\/\/stuff.mit.edu\/afs\/athena\/dept\/cron\/tools\/share\/mibs\/290923.mib&#8217; ],<br \/>],<br \/>&#8216;Author&#8217; =&gt; &#8216;Matteo Cantoni &lt;goony[at]nothink.org&gt;&#8217;,<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE<br \/>))<br \/>end<\/p>\n<p>def run_host(ip)<br \/>begin<br \/>snmp = connect_snmp<\/p>\n<p>vprint_status(&#8220;Connecting to #{ip}&#8221;)<\/p>\n<p>output_data = []\n<p>output_data &lt;&lt; &#8220;IP address : #{ip}&#8221;<\/p>\n<p>sysName = snmp.get_value(&#8216;1.3.6.1.2.1.1.5.0&#8217;).to_s<br \/>output_data &lt;&lt; &#8220;Hostname : #{sysName.strip}&#8221;<\/p>\n<p>sysDesc = snmp.get_value(&#8216;1.3.6.1.2.1.1.1.0&#8217;).to_s<br \/>sysDesc.gsub!(\/^\\s+|\\s+$|\\n+|\\r+\/, &#8216; &#8216;)<br \/>output_data &lt;&lt; &#8220;Description : #{sysDesc.strip}&#8221;<\/p>\n<p>sysContact = snmp.get_value(&#8216;1.3.6.1.2.1.1.4.0&#8217;).to_s<br \/>output_data &lt;&lt; &#8220;Contact : #{sysContact.strip}&#8221; if not sysContact.empty?<\/p>\n<p>sysLocation = snmp.get_value(&#8216;1.3.6.1.2.1.1.6.0&#8217;).to_s<br \/>output_data &lt;&lt; &#8220;Location : #{sysLocation.strip}&#8221; if not sysLocation.empty?<\/p>\n<p>output_data &lt;&lt; &#8220;&#8221;<\/p>\n<p>snmp.walk([<br \/>&#8220;1.3.6.1.4.1.11.2.3.9.4.2.1.1.6.5.1&#8221;, # job-info-name1 &#8211; document name1<br \/>&#8220;1.3.6.1.4.1.11.2.3.9.4.2.1.1.6.5.2&#8221;, # job-info-name2 &#8211; document name2<br \/>&#8220;1.3.6.1.4.1.11.2.3.9.4.2.1.1.6.5.23.1&#8221;, # job-info-attr-1 &#8211; username<br \/>&#8220;1.3.6.1.4.1.11.2.3.9.4.2.1.1.6.5.23.2&#8221;, # job-info-attr-2 &#8211; machine name<br \/>&#8220;1.3.6.1.4.1.11.2.3.9.4.2.1.1.6.5.23.3&#8221;, # job-info-attr-3 &#8211; domain (?)<br \/>&#8220;1.3.6.1.4.1.11.2.3.9.4.2.1.1.6.5.23.4&#8221;, # job-info-attr-4 &#8211; timestamp<br \/>&#8220;1.3.6.1.4.1.11.2.3.9.4.2.1.1.6.5.23.6&#8221;, # job-info-attr-6 &#8211; application name<br \/>&#8220;1.3.6.1.4.1.11.2.3.9.4.2.1.1.6.5.23.7&#8221;, # job-info-attr-7 &#8211; application command<br \/>]) do |name1,name2,username,client,domain,timestamp,app_name,app_command|<\/p>\n<p>filename = name1.value.to_s + name2.value.to_s<\/p>\n<p>if (username.value.to_s !~ \/noSuchInstance\/)<br \/>if username.value.to_s =~ \/^JobAcct(\\d+)=(.*)\/<br \/>username = $2<br \/>end<br \/>else<br \/>username = &#8221;<br \/>end<\/p>\n<p>if (client.value.to_s !~ \/noSuchInstance\/)<br \/>if client.value.to_s =~ \/^JobAcct(\\d+)=(.*)\/<br \/>client = $2<br \/>end<br \/>else<br \/>client = &#8221;<br \/>end<\/p>\n<p>if (domain.value.to_s !~ \/noSuchInstance\/)<br \/>if domain.value.to_s =~ \/^JobAcct(\\d+)=(.*)\/<br \/>domain = $2<br \/>end<br \/>else<br \/>domain = &#8221;<br \/>end<\/p>\n<p>if (timestamp.value.to_s !~ \/noSuchInstance\/)<br \/>if timestamp.value.to_s =~ \/^JobAcct(\\d+)=(.*)\/<br \/>timestamp = $2<br \/>end<br \/>else<br \/>timestamp = &#8221;<br \/>end<\/p>\n<p>if (app_name.value.to_s !~ \/noSuchInstance\/)<br \/>if app_name.value.to_s =~ \/^JobAcct(\\d+)=(.*)\/<br \/>app_name = $2<br \/>end<br \/>else<br \/>app_name = &#8221;<br \/>end<\/p>\n<p>if (app_command.value.to_s !~ \/noSuchInstance\/)<br \/>if app_command.value.to_s =~ \/^JobAcct(\\d+)=(.*)\/<br \/>app_command = $2<br \/>end<br \/>else<br \/>app_command = &#8221;<br \/>end<\/p>\n<p>if not timestamp.empty?<br \/>output_data &lt;&lt; &#8220;File name : #{filename}&#8221;<br \/>output_data &lt;&lt; &#8220;Username : #{username}&#8221; if not username.empty?<br \/>output_data &lt;&lt; &#8220;Client : #{client}&#8221; if not client.empty?<br \/>output_data &lt;&lt; &#8220;Domain : #{domain}&#8221; if not domain.empty?<br \/>output_data &lt;&lt; &#8220;Timestamp : #{timestamp}&#8221; if not timestamp.empty?<br \/>output_data &lt;&lt; &#8220;Application : #{app_name} (#{app_command})&#8221; if not app_name.empty?<br \/>output_data &lt;&lt; &#8220;&#8221;<br \/>end<br \/>end<\/p>\n<p>output_data.each do |row|<br \/>print_good(&#8220;#{row}&#8221;)<br \/>end<\/p>\n<p>disconnect_snmp<\/p>\n<p>rescue SNMP::RequestTimeout<br \/>print_error(&#8220;#{ip}, SNMP request timeout.&#8221;)<br \/>rescue Errno::ECONNREFUSED<br \/>print_error(&#8220;#{ip}, Connection refused.&#8221;)<br \/>rescue SNMP::InvalidIpAddress<br \/>print_error(&#8220;#{ip}, Invalid IP Address. Check it with &#8216;snmpwalk tool&#8217;.&#8221;)<br \/>rescue ::Interrupt<br \/>raise $!<br \/>rescue ::Exception =&gt; e<br \/>print_error(&#8220;#{ip}, Unknown error: #{e.class} #{e}&#8221;)<br \/>end<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::SNMPClientinclude Msf::Auxiliary::Reportinclude Msf::Auxiliary::Scanner def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;HP LaserJet Printer SNMP Enumeration&#8217;,&#8216;Description&#8217; =&gt; %q{This module allows enumeration of files previously printed.It provides details as filename, client, timestamp and username information.The default community used is &#8220;public&#8221;.},&#8216;References&#8217; =&gt;[[ &#8216;URL&#8217;, &#8216;https:\/\/en.wikipedia.org\/wiki\/Simple_Network_Management_Protocol&#8217; ],[ &#8216;URL&#8217;, &#8216;https:\/\/net-snmp.sourceforge.io\/docs\/man\/snmpwalk.html&#8217; &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-59339","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59339","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=59339"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59339\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}