Skip to content

Commit 9573c7e

Browse files
committed
Implement transport remove
1 parent 77f506c commit 9573c7e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/rex/post/meterpreter/client_core.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,16 @@ def machine_id(timeout=nil)
325325
return Rex::Text.md5(mid)
326326
end
327327

328+
def transport_remove(opts={})
329+
request = transport_prepare_request('core_transport_remove', opts)
330+
331+
return false unless request
332+
333+
client.send_request(request)
334+
335+
return true
336+
end
337+
328338
def transport_add(opts={})
329339
request = transport_prepare_request('core_transport_add', opts)
330340

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,13 +561,14 @@ def cmd_sleep(*args)
561561
# Display help for transport management.
562562
#
563563
def cmd_transport_help
564-
print_line('Usage: transport <list|change|add|next|prev> [options]')
564+
print_line('Usage: transport <list|change|add|next|prev|remove> [options]')
565565
print_line
566566
print_line(' list: list the currently active transports.')
567567
print_line(' add: add a new transport to the transport list.')
568568
print_line(' change: same as add, but changes directly to the added entry.')
569569
print_line(' next: jump to the next transport in the list (no options).')
570570
print_line(' prev: jump to the previous transport in the list (no options).')
571+
print_line(' remove: remove an existing, non-active transport.')
571572
print_line(@@transport_opts.usage)
572573
end
573574

@@ -581,7 +582,7 @@ def cmd_transport(*args)
581582
end
582583

583584
command = args.shift
584-
unless ['list', 'add', 'change', 'prev', 'next'].include?(command)
585+
unless ['list', 'add', 'change', 'prev', 'next', 'remove'].include?(command)
585586
cmd_transport_help
586587
return
587588
end
@@ -733,6 +734,13 @@ def cmd_transport(*args)
733734
else
734735
print_error("Failed to add transport, please check the parameters")
735736
end
737+
when 'remove'
738+
print_status("Removing transport ...")
739+
if client.core.transport_remove(opts)
740+
print_good("Successfully removed #{opts[:transport]} transport.")
741+
else
742+
print_error("Failed to remove transport, please check the parameters")
743+
end
736744
end
737745
end
738746

0 commit comments

Comments
 (0)