Skip to content

Commit f8fb036

Browse files
committed
Fix issue in ps_wmi_exec and powershell staging
The staging function in the post/windows/powershell class was broken in a previous commit as the definition for env_variable was removed and env_prefix alone is now used. This caused an error to be thrown when attempting to stage the payload. This changes the reference from env_variable to env_prefix. Additionally, the ps_wmi_exec module created a powershell script to be run that was intended to be used with the EncodedCommand command line option; however the script itself was never actually encoded. This change passes the compressed script to the encode_script function to resolve that issue.
1 parent 9f892c5 commit f8fb036

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/msf/core/post/windows/powershell.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def stage_cmd_env(compressed_script, env_suffix = Rex::Text.rand_text_alpha(8))
134134

135135
# Build the set commands
136136
set_env_variable = "[Environment]::SetEnvironmentVariable(" \
137-
"'#{env_variable}'," \
137+
"'#{env_prefix}'," \
138138
"'#{chunk}', 'User')"
139139

140140
# Compress and encode the set command

modules/exploits/windows/local/ps_wmi_exec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def build_script
8181
sleep_time = rand(5)+5
8282
psh_payload = "function #{fun_name}{#{psh_payload}};while(1){Start-Sleep -s #{sleep_time};#{fun_name};1}"
8383
end
84-
psh_payload = compress_script(psh_payload_raw, eof)
84+
psh_payload = encode_script(compress_script(psh_payload_raw, eof), eof)
8585
# WMI exec function - this is going into powershell.rb after pull 701 is commited
8686
script = ps_wmi_exec(run_opts)
8787
# Build WMI exec calls to every host into the script to reduce PS instances

0 commit comments

Comments
 (0)