Land #5543, add transport delete command
commit
ba340ecec1
|
@ -9,7 +9,7 @@ PATH
|
|||
json
|
||||
metasploit-concern (~> 1.0)
|
||||
metasploit-model (~> 1.0)
|
||||
metasploit-payloads (= 1.0.2)
|
||||
metasploit-payloads (= 1.0.3)
|
||||
msgpack
|
||||
nokogiri
|
||||
packetfu (= 1.1.9)
|
||||
|
@ -123,7 +123,7 @@ GEM
|
|||
activemodel (>= 4.0.9, < 4.1.0)
|
||||
activesupport (>= 4.0.9, < 4.1.0)
|
||||
railties (>= 4.0.9, < 4.1.0)
|
||||
metasploit-payloads (1.0.2)
|
||||
metasploit-payloads (1.0.3)
|
||||
metasploit_data_models (1.2.3)
|
||||
activerecord (>= 4.0.9, < 4.1.0)
|
||||
activesupport (>= 4.0.9, < 4.1.0)
|
||||
|
|
|
@ -325,6 +325,16 @@ class ClientCore < Extension
|
|||
return Rex::Text.md5(mid)
|
||||
end
|
||||
|
||||
def transport_remove(opts={})
|
||||
request = transport_prepare_request('core_transport_remove', opts)
|
||||
|
||||
return false unless request
|
||||
|
||||
client.send_request(request)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
def transport_add(opts={})
|
||||
request = transport_prepare_request('core_transport_add', opts)
|
||||
|
||||
|
@ -648,8 +658,14 @@ class ClientCore < Extension
|
|||
|
||||
# do more magic work for http(s) payloads
|
||||
unless opts[:transport].ends_with?('tcp')
|
||||
sum = uri_checksum_lookup(:connect)
|
||||
url << generate_uri_uuid(sum, opts[:uuid]) + '/'
|
||||
if opts[:uri]
|
||||
url << '/' unless opts[:uri].start_with?('/')
|
||||
url << opts[:uri]
|
||||
url << '/' unless opts[:uri].end_with?('/')
|
||||
else
|
||||
sum = uri_checksum_lookup(:connect)
|
||||
url << generate_uri_uuid(sum, opts[:uuid]) + '/'
|
||||
end
|
||||
|
||||
# TODO: randomise if not specified?
|
||||
opts[:ua] ||= 'Mozilla/4.0 (compatible; MSIE 6.1; Windows NT)'
|
||||
|
|
|
@ -543,12 +543,13 @@ class Console::CommandDispatcher::Core
|
|||
'-t' => [ true, "Transport type: #{Rex::Post::Meterpreter::ClientCore::VALID_TRANSPORTS.keys.join(', ')}" ],
|
||||
'-l' => [ true, 'LHOST parameter (for reverse transports)' ],
|
||||
'-p' => [ true, 'LPORT parameter' ],
|
||||
'-ua' => [ true, 'User agent for http(s) transports (optional)' ],
|
||||
'-ph' => [ true, 'Proxy host for http(s) transports (optional)' ],
|
||||
'-pp' => [ true, 'Proxy port for http(s) transports (optional)' ],
|
||||
'-pu' => [ true, 'Proxy username for http(s) transports (optional)' ],
|
||||
'-ps' => [ true, 'Proxy password for http(s) transports (optional)' ],
|
||||
'-pt' => [ true, 'Proxy type for http(s) transports (optional: http, socks; default: http)' ],
|
||||
'-u' => [ true, 'Custom URI for HTTP/S transports (used when removing transports)' ],
|
||||
'-ua' => [ true, 'User agent for HTTP/S transports (optional)' ],
|
||||
'-ph' => [ true, 'Proxy host for HTTP/S transports (optional)' ],
|
||||
'-pp' => [ true, 'Proxy port for HTTP/S transports (optional)' ],
|
||||
'-pu' => [ true, 'Proxy username for HTTP/S transports (optional)' ],
|
||||
'-ps' => [ true, 'Proxy password for HTTP/S transports (optional)' ],
|
||||
'-pt' => [ true, 'Proxy type for HTTP/S transports (optional: http, socks; default: http)' ],
|
||||
'-c' => [ true, 'SSL certificate path for https transport verification (optional)' ],
|
||||
'-to' => [ true, 'Comms timeout (seconds) (default: same as current session)' ],
|
||||
'-ex' => [ true, 'Expiration timout (seconds) (default: same as current session)' ],
|
||||
|
@ -561,13 +562,14 @@ class Console::CommandDispatcher::Core
|
|||
# Display help for transport management.
|
||||
#
|
||||
def cmd_transport_help
|
||||
print_line('Usage: transport <list|change|add|next|prev> [options]')
|
||||
print_line('Usage: transport <list|change|add|next|prev|remove> [options]')
|
||||
print_line
|
||||
print_line(' list: list the currently active transports.')
|
||||
print_line(' add: add a new transport to the transport list.')
|
||||
print_line(' change: same as add, but changes directly to the added entry.')
|
||||
print_line(' next: jump to the next transport in the list (no options).')
|
||||
print_line(' prev: jump to the previous transport in the list (no options).')
|
||||
print_line(' remove: remove an existing, non-active transport.')
|
||||
print_line(@@transport_opts.usage)
|
||||
end
|
||||
|
||||
|
@ -581,7 +583,7 @@ class Console::CommandDispatcher::Core
|
|||
end
|
||||
|
||||
command = args.shift
|
||||
unless ['list', 'add', 'change', 'prev', 'next'].include?(command)
|
||||
unless ['list', 'add', 'change', 'prev', 'next', 'remove'].include?(command)
|
||||
cmd_transport_help
|
||||
return
|
||||
end
|
||||
|
@ -591,6 +593,7 @@ class Console::CommandDispatcher::Core
|
|||
:transport => nil,
|
||||
:lhost => nil,
|
||||
:lport => nil,
|
||||
:uri => nil,
|
||||
:ua => nil,
|
||||
:proxy_host => nil,
|
||||
:proxy_port => nil,
|
||||
|
@ -610,6 +613,8 @@ class Console::CommandDispatcher::Core
|
|||
case opt
|
||||
when '-c'
|
||||
opts[:cert] = val
|
||||
when '-u'
|
||||
opts[:uri] = val
|
||||
when '-ph'
|
||||
opts[:proxy_host] = val
|
||||
when '-pp'
|
||||
|
@ -733,6 +738,18 @@ class Console::CommandDispatcher::Core
|
|||
else
|
||||
print_error("Failed to add transport, please check the parameters")
|
||||
end
|
||||
when 'remove'
|
||||
if opts[:transport] && !opts[:transport].end_with?('_tcp') && opts[:uri].nil?
|
||||
print_error("HTTP/S transport specified without session URI")
|
||||
return
|
||||
end
|
||||
|
||||
print_status("Removing transport ...")
|
||||
if client.core.transport_remove(opts)
|
||||
print_good("Successfully removed #{opts[:transport]} transport.")
|
||||
else
|
||||
print_error("Failed to remove transport, please check the parameters")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ Gem::Specification.new do |spec|
|
|||
# Things that would normally be part of the database model, but which
|
||||
# are needed when there's no database
|
||||
spec.add_runtime_dependency 'metasploit-model', '~> 1.0'
|
||||
# Needed for Meterpreter on Windows, soon others.
|
||||
spec.add_runtime_dependency 'metasploit-payloads', '1.0.2'
|
||||
# Needed for Meterpreter
|
||||
spec.add_runtime_dependency 'metasploit-payloads', '1.0.3'
|
||||
# Needed by msfgui and other rpc components
|
||||
spec.add_runtime_dependency 'msgpack'
|
||||
# Needed by anemone crawler
|
||||
|
|
Loading…
Reference in New Issue