Skip to content

Commit f7a06d8

Browse files
author
HD Moore
committed
Rework PROXY_{HOST|PORT|TYPE|USERNAME|PASSWORD) to the new syntax
1 parent 3aa8cb6 commit f7a06d8

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

lib/msf/core/handler/reverse_hop_http.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,11 @@ def send_new_stage
256256
:expiration => datastore['SessionExpirationTimeout'],
257257
:comm_timeout => datastore['SessionCommunicationTimeout'],
258258
:ua => datastore['MeterpreterUserAgent'],
259-
:proxyhost => datastore['PROXY_HOST'],
260-
:proxyport => datastore['PROXY_PORT'],
261-
:proxy_type => datastore['PROXY_TYPE'],
262-
:proxy_username => datastore['PROXY_USERNAME'],
263-
:proxy_password => datastore['PROXY_PASSWORD']
259+
:proxyhost => datastore['PayloadProxyHost'],
260+
:proxyport => datastore['PayloadProxyPort'],
261+
:proxy_type => datastore['PayloadProxyType'],
262+
:proxy_username => datastore['PayloadProxyUser'],
263+
:proxy_password => datastore['PayloadProxyPass']
264264

265265
blob = encode_stage(blob)
266266

lib/msf/core/handler/reverse_http.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ def lookup_proxy_settings
175175
info = {}
176176
return @proxy_settings if @proxy_settings
177177

178-
if datastore['PROXY_HOST'].to_s == ""
178+
if datastore['PayloadProxyHost'].to_s == ""
179179
@proxy_settings = info
180180
return @proxy_settings
181181
end
182182

183-
info[:host] = datastore['PROXY_HOST'].to_s
184-
info[:port] = (datastore['PROXY_PORT'] || 8080).to_i
185-
info[:type] = datastore['PROXY_TYPE'].to_s
183+
info[:host] = datastore['PayloadProxyHost'].to_s
184+
info[:port] = (datastore['PayloadProxyPort'] || 8080).to_i
185+
info[:type] = datastore['PayloadProxyType'].to_s
186186

187187
uri_host = info[:host]
188188

@@ -196,11 +196,11 @@ def lookup_proxy_settings
196196
info[:info] = "socks=#{info[:info]}"
197197
else
198198
info[:info] = "http://#{info[:info]}"
199-
if datastore['PROXY_USERNAME'].to_s != ""
200-
info[:username] = datastore['PROXY_USERNAME'].to_s
199+
if datastore['PayloadProxyUser'].to_s != ""
200+
info[:username] = datastore['PayloadProxyUser'].to_s
201201
end
202-
if datastore['PROXY_PASSWORD'].to_s != ""
203-
info[:password] = datastore['PROXY_PASSWORD'].to_s
202+
if datastore['PayloadProxyPass'].to_s != ""
203+
info[:password] = datastore['PayloadProxyPass'].to_s
204204
end
205205
end
206206

@@ -299,11 +299,11 @@ def on_request(cli, req, obj)
299299
:expiration => datastore['SessionExpirationTimeout'],
300300
:comm_timeout => datastore['SessionCommunicationTimeout'],
301301
:ua => datastore['MeterpreterUserAgent'],
302-
:proxyhost => datastore['PROXY_HOST'],
303-
:proxyport => datastore['PROXY_PORT'],
304-
:proxy_type => datastore['PROXY_TYPE'],
305-
:proxy_username => datastore['PROXY_USERNAME'],
306-
:proxy_password => datastore['PROXY_PASSWORD']
302+
:proxyhost => datastore['PayloadProxyHost'],
303+
:proxyport => datastore['PayloadProxyPort'],
304+
:proxy_type => datastore['PayloadProxyType'],
305+
:proxy_username => datastore['PayloadProxyUser'],
306+
:proxy_password => datastore['PayloadProxyPass']
307307

308308
resp.body = encode_stage(blob)
309309

lib/msf/core/handler/reverse_https_proxy.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def initialize(info = {})
4040
[
4141
OptString.new('LHOST', [ true, "The local listener hostname" ,"127.0.0.1"]),
4242
OptPort.new('LPORT', [ true, "The local listener port", 8443 ]),
43-
OptString.new('PROXY_HOST', [true, "The proxy server's IP address", "127.0.0.1"]),
44-
OptPort.new('PROXY_PORT', [true, "The proxy port to connect to", 8080 ]),
45-
OptEnum.new('PROXY_TYPE', [true, 'The proxy type, HTTP or SOCKS', 'HTTP', ['HTTP', 'SOCKS']]),
46-
OptString.new('PROXY_USERNAME', [ false, "An optional username for HTTP proxy authentication"]),
47-
OptString.new('PROXY_PASSWORD', [ false, "An optional password for HTTP proxy authentication"])
43+
OptString.new('PayloadProxyHost', [true, "The proxy server's IP address", "127.0.0.1"]),
44+
OptPort.new('PayloadProxyPort', [true, "The proxy port to connect to", 8080 ]),
45+
OptEnum.new('PayloadProxyType', [true, 'The proxy type, HTTP or SOCKS', 'HTTP', ['HTTP', 'SOCKS']]),
46+
OptString.new('PayloadProxyUser', [ false, "An optional username for HTTP proxy authentication"]),
47+
OptString.new('PayloadProxyPass', [ false, "An optional password for HTTP proxy authentication"])
4848
], Msf::Handler::ReverseHttpsProxy)
4949

5050
register_advanced_options(

modules/payloads/stagers/python/reverse_http.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def initialize(info = {})
2626

2727
register_options(
2828
[
29-
OptString.new('PROXY_HOST', [false, "The proxy server's IP address"]),
30-
OptPort.new('PROXY_PORT', [true, "The proxy port to connect to", 8080 ])
29+
OptString.new('PayloadProxyHost', [false, "The proxy server's IP address"]),
30+
OptPort.new('PayloadProxyPort', [true, "The proxy port to connect to", 8080 ])
3131
], self.class)
3232
end
3333

@@ -52,8 +52,8 @@ def generate
5252
target_url << '/'
5353
target_url << generate_uri_checksum(Msf::Handler::ReverseHttp::URI_CHECKSUM_INITP)
5454

55-
proxy_host = datastore['PROXY_HOST'].to_s
56-
proxy_port = datastore['PROXY_PORT'].to_i
55+
proxy_host = datastore['PayloadProxyHost'].to_s
56+
proxy_port = datastore['PayloadProxyPort'].to_i
5757

5858
cmd = "import sys\n"
5959
if proxy_host == ''

modules/payloads/stagers/windows/reverse_https_proxy.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def generate
8282
p[i, u.length] = u
8383

8484
# patch proxy info
85-
proxyhost = datastore['PROXY_HOST'].to_s
86-
proxyport = datastore['PROXY_PORT'].to_s || "8080"
85+
proxyhost = datastore['PayloadProxyHost'].to_s
86+
proxyport = datastore['PayloadProxyPort'].to_s || "8080"
8787

8888
if Rex::Socket.is_ipv6?(proxyhost)
8989
proxyhost = "[#{proxyhost}]"
@@ -93,7 +93,7 @@ def generate
9393
if proxyport == "80"
9494
proxyinfo = proxyhost
9595
end
96-
if datastore['PROXY_TYPE'].to_s == 'HTTP'
96+
if datastore['PayloadProxyType'].to_s == 'HTTP'
9797
proxyinfo = 'http://' + proxyinfo
9898
else #socks
9999
proxyinfo = 'socks=' + proxyinfo
@@ -107,34 +107,34 @@ def generate
107107
p[proxyloc-4] = [calloffset].pack('V')[0]
108108

109109
# Authentication credentials have not been specified
110-
if datastore['PROXY_USERNAME'].to_s == '' or
111-
datastore['PROXY_PASSWORD'].to_s == '' or
112-
datastore['PROXY_TYPE'].to_s == 'SOCKS'
110+
if datastore['PayloadProxyUser'].to_s == '' or
111+
datastore['PayloadProxyPass'].to_s == '' or
112+
datastore['PayloadProxyType'].to_s == 'SOCKS'
113113

114114
jmp_offset = p.index("PROXY_AUTH_STOP") + 15 - p.index("PROXY_AUTH_START")
115115

116116
# Remove the authentication code
117117
p = p.gsub(/PROXY_AUTH_START(.)*PROXY_AUTH_STOP/i, "")
118118
else
119-
username_size_diff = 14 - datastore['PROXY_USERNAME'].to_s.length
120-
password_size_diff = 14 - datastore['PROXY_PASSWORD'].to_s.length
119+
username_size_diff = 14 - datastore['PayloadProxyUser'].to_s.length
120+
password_size_diff = 14 - datastore['PayloadProxyPass'].to_s.length
121121
jmp_offset =
122122
16 + # PROXY_AUTH_START length
123123
15 + # PROXY_AUTH_STOP length
124-
username_size_diff + # Difference between datastore PROXY_USERNAME length and db "PROXY_USERNAME length"
125-
password_size_diff # Same with PROXY_PASSWORD
124+
username_size_diff + # Difference between datastore PayloadProxyUser length and db "PayloadProxyUser length"
125+
password_size_diff # Same with PayloadProxyPass
126126

127127
# Patch call offset
128-
username_loc = p.index("PROXY_USERNAME")
128+
username_loc = p.index("PayloadProxyUser")
129129
p[username_loc - 4, 4] = [15 - username_size_diff].pack("V")
130-
password_loc = p.index("PROXY_PASSWORD")
130+
password_loc = p.index("PayloadProxyPass")
131131
p[password_loc - 4, 4] = [15 - password_size_diff].pack("V")
132132

133133
# Remove markers & change login/password
134134
p = p.gsub("PROXY_AUTH_START","")
135135
p = p.gsub("PROXY_AUTH_STOP","")
136-
p = p.gsub("PROXY_USERNAME", datastore['PROXY_USERNAME'].to_s)
137-
p = p.gsub("PROXY_PASSWORD", datastore['PROXY_PASSWORD'].to_s)
136+
p = p.gsub("PayloadProxyUser", datastore['PayloadProxyUser'].to_s)
137+
p = p.gsub("PayloadProxyPass", datastore['PayloadProxyPass'].to_s)
138138
end
139139

140140
# Patch jmp dbl_get_server_host

0 commit comments

Comments
 (0)