Skip to content

Commit 56d6498

Browse files
committed
Switch PROXY_HOST to PROXY_URL which is more accurate
Still not fully accurate though since socks seems to be prefixed with socks= and not socks://
1 parent 7fc3448 commit 56d6498

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

lib/rex/payloads/meterpreter/config.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ def add_c2_tlv(tlv, opts)
100100
# if the transport URI is for a HTTP payload we need to add a stack
101101
# of other stuff that can only be set in MSF, not in the C2 profile
102102
if url.start_with?('http')
103-
proxy_host = ''
103+
proxy_url = ''
104104
if opts[:proxy_host] && opts[:proxy_port]
105105
prefix = 'http://'
106106
prefix = 'socks=' if opts[:proxy_type].to_s.downcase == 'socks'
107-
proxy_host = "#{prefix}#{opts[:proxy_host]}:#{opts[:proxy_port]}"
107+
proxy_url = "#{prefix}#{opts[:proxy_host]}:#{opts[:proxy_port]}"
108108
end
109109

110-
c2_tlv.add_tlv(MET::TLV_TYPE_C2_PROXY_HOST, proxy_host) unless (proxy_host || '').empty?
110+
c2_tlv.add_tlv(MET::TLV_TYPE_C2_PROXY_URL, proxy_url) unless (proxy_url || '').empty?
111111
c2_tlv.add_tlv(MET::TLV_TYPE_C2_PROXY_USER, opts[:proxy_user]) unless (opts[:proxy_user] || '').empty?
112112
c2_tlv.add_tlv(MET::TLV_TYPE_C2_PROXY_PASS, opts[:proxy_pass]) unless (opts[:proxy_pass] || '').empty?
113113

lib/rex/post/meterpreter/client_core.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def transport_list
147147
}
148148

149149
response.each(TLV_TYPE_C2) { |t|
150-
# TODO: Consider adding more informationt to the output for malleable profiles?
150+
# TODO: Consider adding more information to the output for malleable profiles?
151151
# TLV_TYPE_C2_GET, TLV_TYPE_C2_POST, TLV_TYPE_C2_PREFIX, TLV_TYPE_C2_SUFFIX, TLV_TYPE_C2_ENC,
152152
# TLV_TYPE_C2_SKIP_COUNT, TLV_TYPE_C2_UUID_COOKIE, TLV_TYPE_C2_UUID_GET, TLV_TYPE_C2_UUID_HEADER
153153
# Not sure if this stuff is useful for this display though.
@@ -157,7 +157,7 @@ def transport_list
157157
:retry_total => t.get_tlv_value(TLV_TYPE_C2_RETRY_TOTAL),
158158
:retry_wait => t.get_tlv_value(TLV_TYPE_C2_RETRY_WAIT),
159159
:ua => t.get_tlv_value(TLV_TYPE_C2_UA),
160-
:proxy_host => t.get_tlv_value(TLV_TYPE_C2_PROXY_HOST),
160+
:proxy_host => t.get_tlv_value(TLV_TYPE_C2_PROXY_URL),
161161
:proxy_user => t.get_tlv_value(TLV_TYPE_C2_PROXY_USER),
162162
:proxy_pass => t.get_tlv_value(TLV_TYPE_C2_PROXY_PASS),
163163
:cert_hash => t.get_tlv_value(TLV_TYPE_C2_CERT_HASH),
@@ -931,8 +931,8 @@ def transport_prepare_request(command_id, opts={})
931931
if opts[:proxy_host] && opts[:proxy_port]
932932
prefix = 'http://'
933933
prefix = 'socks=' if opts[:proxy_type].to_s.downcase == 'socks'
934-
proxy = "#{prefix}#{opts[:proxy_host]}:#{opts[:proxy_port]}"
935-
c2_tlv.add_tlv(TLV_TYPE_C2_PROXY_HOST, proxy)
934+
proxy = "#{prefix}#{Rex::Socket.to_authority(opts[:proxy_host], opts[:proxy_port])}"
935+
c2_tlv.add_tlv(TLV_TYPE_C2_PROXY_URL, proxy)
936936

937937
if opts[:proxy_user]
938938
c2_tlv.add_tlv(TLV_TYPE_C2_PROXY_USER, opts[:proxy_user])

lib/rex/post/meterpreter/packet.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ module Meterpreter
121121
TLV_TYPE_C2_RETRY_WAIT = TLV_META_TYPE_UINT | 707 # how long to wait between reconnect attempts
122122
TLV_TYPE_C2_URL = TLV_META_TYPE_STRING | 708 # base URL of this C2 (scheme://host:port/uri)
123123
TLV_TYPE_C2_URI = TLV_META_TYPE_STRING | 709 # URI to append to base URL (for HTTP(s)), if any
124-
TLV_TYPE_C2_PROXY_HOST = TLV_META_TYPE_STRING | 710 # Host name of proxy
124+
TLV_TYPE_C2_PROXY_URL = TLV_META_TYPE_STRING | 710 # Proxy URL
125125
TLV_TYPE_C2_PROXY_USER = TLV_META_TYPE_STRING | 711 # Proxy user name
126126
TLV_TYPE_C2_PROXY_PASS = TLV_META_TYPE_STRING | 712 # Proxy password
127127
TLV_TYPE_C2_GET = TLV_META_TYPE_GROUP | 713 # A grouping of params associated with GET requests

0 commit comments

Comments
 (0)