{"id":59327,"date":"2024-09-01T03:00:10","date_gmt":"2024-09-01T00:00:10","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180942\/tftpbrute.rb.txt"},"modified":"2024-09-01T03:00:10","modified_gmt":"2024-09-01T00:00:10","slug":"tftp-brute-forcer","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/tftp-brute-forcer\/","title":{"rendered":"TFTP Brute Forcer"},"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::Auxiliary::Scanner<br \/>include Msf::Auxiliary::Report<\/p>\n<p>def initialize<br \/>super(<br \/>&#8216;Name&#8217; =&gt; &#8216;TFTP Brute Forcer&#8217;,<br \/>&#8216;Description&#8217; =&gt; &#8216;This module uses a dictionary to brute force valid TFTP image names from a TFTP server.&#8217;,<br \/>&#8216;Author&#8217; =&gt; &#8216;antoine&#8217;,<br \/>&#8216;License&#8217; =&gt; BSD_LICENSE<br \/>)<\/p>\n<p>register_options(<br \/>[<br \/>Opt::RPORT(69),<br \/>Opt::CHOST,<br \/>OptPath.new(&#8216;DICTIONARY&#8217;, [ true, &#8216;The list of filenames&#8217;,<br \/>File.join(Msf::Config.data_directory, &#8220;wordlists&#8221;, &#8220;tftp.txt&#8221;) ])<br \/>])<br \/>end<\/p>\n<p>def run_host(ip)<br \/>begin<\/p>\n<p># Create an unbound UDP socket if no CHOST is specified, otherwise<br \/># create a UDP socket bound to CHOST (in order to avail of pivoting)<br \/>udp_sock = Rex::Socket::Udp.create(<br \/>{<br \/>&#8216;LocalHost&#8217; =&gt; datastore[&#8216;CHOST&#8217;] || nil,<br \/>&#8216;Context&#8217; =&gt;<br \/>{<br \/>&#8216;Msf&#8217; =&gt; framework,<br \/>&#8216;MsfExploit&#8217; =&gt; self,<br \/>}<br \/>}<br \/>)<br \/>add_socket(udp_sock)<\/p>\n<p>fd = File.open(datastore[&#8216;DICTIONARY&#8217;], &#8216;rb&#8217;)<br \/>fd.read(fd.stat.size).split(&#8220;\\n&#8221;).each do |filename|<br \/>filename.strip!<br \/>pkt = &#8220;\\x00\\x01&#8221; + filename + &#8220;\\x00&#8221; + &#8220;netascii&#8221; + &#8220;\\x00&#8221;<br \/>udp_sock.sendto(pkt, ip, datastore[&#8216;RPORT&#8217;])<br \/>resp = udp_sock.get(3)<br \/>if resp and resp.length &gt;= 2 and resp[0, 2] == &#8220;\\x00\\x03&#8221;<br \/>print_good(&#8220;Found #{filename} on #{ip}&#8221;)<br \/>#Add Report<br \/>report_note(<br \/>:host =&gt; ip,<br \/>:proto =&gt; &#8216;udp&#8217;,<br \/>:sname =&gt; &#8216;tftp&#8217;,<br \/>:port =&gt; datastore[&#8216;RPORT&#8217;],<br \/>:type =&gt; &#8220;Found #{filename}&#8221;,<br \/>:data =&gt; &#8220;Found #{filename}&#8221;<br \/>)<br \/>end<br \/>end<br \/>fd.close<br \/>rescue<br \/>ensure<br \/>udp_sock.close<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::Auxiliary::Scannerinclude Msf::Auxiliary::Report def initializesuper(&#8216;Name&#8217; =&gt; &#8216;TFTP Brute Forcer&#8217;,&#8216;Description&#8217; =&gt; &#8216;This module uses a dictionary to brute force valid TFTP image names from a TFTP server.&#8217;,&#8216;Author&#8217; =&gt; &#8216;antoine&#8217;,&#8216;License&#8217; =&gt; BSD_LICENSE) register_options([Opt::RPORT(69),Opt::CHOST,OptPath.new(&#8216;DICTIONARY&#8217;, [ true, &#8216;The list of filenames&#8217;,File.join(Msf::Config.data_directory, &#8220;wordlists&#8221;, &#8220;tftp.txt&#8221;) ])])end def run_host(ip)begin # &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-59327","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59327","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=59327"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59327\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}