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
```
unstable
RageLtMan 2015-05-17 13:42:58 -04:00 committed by Brent Cook
parent b20c1c51b5
commit e9be0d3f7a
1 changed files with 27 additions and 2 deletions

View File

@ -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 ]