From e9be0d3f7a6477cea9e1984d39518fe4a1fe207a Mon Sep 17 00:00:00 2001 From: RageLtMan Date: Sun, 17 May 2015 13:42:58 -0400 Subject: [PATCH] Allow cmd_arp to use -S flag Allow searching for regex' through ARP output using Table's new 'SearchTerm' parameter. Example: ``` meterpreter > arp -S 10.2.1.1 ARP cache ========= IP address MAC address Interface ---------- ----------- --------- 10.2.1.1 00:01:02:03:04:05 15 ``` --- .../console/command_dispatcher/stdapi/net.rb | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb index 67fcdef867..50852d8d5d 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb @@ -58,6 +58,13 @@ class Console::CommandDispatcher::Stdapi::Net "-h" => [ false, "Help banner." ], "-S" => [ true, "Search string." ]) + # + # Options for ARP command. + # + @@arp_opts = Rex::Parser::Arguments.new( + "-h" => [ false, "Help banner." ], + "-S" => [ true, "Search string." ]) + # # List of supported commands. # @@ -126,7 +133,7 @@ class Console::CommandDispatcher::Stdapi::Net search_term = /#{search_term}/nmi end when "-h" - cmd_netstat_help + @@netstat_opts.usage return 0 end @@ -163,6 +170,23 @@ class Console::CommandDispatcher::Stdapi::Net # def cmd_arp(*args) arp_table = client.net.config.arp_table + search_term = nil + @@arp_opts.parse(args) { |opt, idx, val| + case opt + when '-S' + search_term = val + if search_term.nil? + print_error("Enter a search term") + return true + else + search_term = /#{search_term}/nmi + end + when "-h" + @@arp_opts.usage + return 0 + + end + } tbl = Rex::Ui::Text::Table.new( 'Header' => "ARP cache", 'Indent' => 4, @@ -171,7 +195,8 @@ class Console::CommandDispatcher::Stdapi::Net "IP address", "MAC address", "Interface" - ]) + ], + 'SearchTerm' => search_term) arp_table.each { |arp| tbl << [ arp.ip_addr, arp.mac_addr, arp.interface ]