Skip to content

Commit 8656add

Browse files
committed
Add uri parameter when removing http/s transports
1 parent 9573c7e commit 8656add

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

lib/rex/post/meterpreter/client_core.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,14 @@ def transport_prepare_request(method, opts={})
658658

659659
# do more magic work for http(s) payloads
660660
unless opts[:transport].ends_with?('tcp')
661-
sum = uri_checksum_lookup(:connect)
662-
url << generate_uri_uuid(sum, opts[:uuid]) + '/'
661+
if opts[:uri]
662+
url << '/' unless opts[:uri].start_with?('/')
663+
url << opts[:uri]
664+
url << '/' unless opts[:uri].end_with?('/')
665+
else
666+
sum = uri_checksum_lookup(:connect)
667+
url << generate_uri_uuid(sum, opts[:uuid]) + '/'
668+
end
663669

664670
# TODO: randomise if not specified?
665671
opts[:ua] ||= 'Mozilla/4.0 (compatible; MSIE 6.1; Windows NT)'

lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,13 @@ def cmd_sleep(*args)
543543
'-t' => [ true, "Transport type: #{Rex::Post::Meterpreter::ClientCore::VALID_TRANSPORTS.keys.join(', ')}" ],
544544
'-l' => [ true, 'LHOST parameter (for reverse transports)' ],
545545
'-p' => [ true, 'LPORT parameter' ],
546-
'-ua' => [ true, 'User agent for http(s) transports (optional)' ],
547-
'-ph' => [ true, 'Proxy host for http(s) transports (optional)' ],
548-
'-pp' => [ true, 'Proxy port for http(s) transports (optional)' ],
549-
'-pu' => [ true, 'Proxy username for http(s) transports (optional)' ],
550-
'-ps' => [ true, 'Proxy password for http(s) transports (optional)' ],
551-
'-pt' => [ true, 'Proxy type for http(s) transports (optional: http, socks; default: http)' ],
546+
'-u' => [ true, 'Custom URI for HTTP/S transports (used when removing transports)' ],
547+
'-ua' => [ true, 'User agent for HTTP/S transports (optional)' ],
548+
'-ph' => [ true, 'Proxy host for HTTP/S transports (optional)' ],
549+
'-pp' => [ true, 'Proxy port for HTTP/S transports (optional)' ],
550+
'-pu' => [ true, 'Proxy username for HTTP/S transports (optional)' ],
551+
'-ps' => [ true, 'Proxy password for HTTP/S transports (optional)' ],
552+
'-pt' => [ true, 'Proxy type for HTTP/S transports (optional: http, socks; default: http)' ],
552553
'-c' => [ true, 'SSL certificate path for https transport verification (optional)' ],
553554
'-to' => [ true, 'Comms timeout (seconds) (default: same as current session)' ],
554555
'-ex' => [ true, 'Expiration timout (seconds) (default: same as current session)' ],
@@ -592,6 +593,7 @@ def cmd_transport(*args)
592593
:transport => nil,
593594
:lhost => nil,
594595
:lport => nil,
596+
:uri => nil,
595597
:ua => nil,
596598
:proxy_host => nil,
597599
:proxy_port => nil,
@@ -611,6 +613,8 @@ def cmd_transport(*args)
611613
case opt
612614
when '-c'
613615
opts[:cert] = val
616+
when '-u'
617+
opts[:uri] = val
614618
when '-ph'
615619
opts[:proxy_host] = val
616620
when '-pp'
@@ -735,6 +739,11 @@ def cmd_transport(*args)
735739
print_error("Failed to add transport, please check the parameters")
736740
end
737741
when 'remove'
742+
if !opts[:transport].end_with?('_tcp') && opts[:uri].nil?
743+
print_error("HTTP/S transport specified without session URI")
744+
return
745+
end
746+
738747
print_status("Removing transport ...")
739748
if client.core.transport_remove(opts)
740749
print_good("Successfully removed #{opts[:transport]} transport.")

0 commit comments

Comments
 (0)