Skip to content

Commit

Permalink
Fix file upload in PowerShell
Browse files Browse the repository at this point in the history
  • Loading branch information
smashery committed Sep 25, 2024
1 parent 583f93a commit a7aa213
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/msf/base/sessions/powershell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def self.to_cmd(executable, args)
# - Side-step any PowerShell magic
# If someone specifically wants to use the PowerShell magic, they can use other APIs

needs_wrapping_chars = ['$', '`', '(', ')', '@', '>', '<', '{','}', '&', ',', ' ']
needs_wrapping_chars = ['$', '`', '(', ')', '@', '>', '<', '{','}', '&', ',', ' ', ';']

result = ""
cmd_and_args = [executable] + args
Expand Down
1 change: 1 addition & 0 deletions lib/msf/core/post/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ def _write_file_powershell_fragment(file_name, data, offset, chunk_size, append
else
file_mode = 'Create'
end
file_name = file_name.gsub("'","''")
pwsh_code = <<~PSH
try {
$encoded='#{encoded_chunk}';
Expand Down
1 change: 0 additions & 1 deletion test/modules/post/test/cmd_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def test_cmd_exec_stderr
true
else
output = cmd_exec("cmd.exe", "/c echo #{test_string} 1>&2")
print_status("line is #{output}")
output.rstrip == test_string
end
else
Expand Down

0 comments on commit a7aa213

Please sign in to comment.