Skip to content

Commit e9be0d3

Browse files
RageLtManBrent Cook
authored andcommitted
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 ```
1 parent b20c1c5 commit e9be0d3

File tree

1 file changed

+27
-2
lines changed
  • lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi

1 file changed

+27
-2
lines changed

lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ def cleanup
5858
"-h" => [ false, "Help banner." ],
5959
"-S" => [ true, "Search string." ])
6060

61+
#
62+
# Options for ARP command.
63+
#
64+
@@arp_opts = Rex::Parser::Arguments.new(
65+
"-h" => [ false, "Help banner." ],
66+
"-S" => [ true, "Search string." ])
67+
6168
#
6269
# List of supported commands.
6370
#
@@ -126,7 +133,7 @@ def cmd_netstat(*args)
126133
search_term = /#{search_term}/nmi
127134
end
128135
when "-h"
129-
cmd_netstat_help
136+
@@netstat_opts.usage
130137
return 0
131138

132139
end
@@ -163,6 +170,23 @@ def cmd_netstat(*args)
163170
#
164171
def cmd_arp(*args)
165172
arp_table = client.net.config.arp_table
173+
search_term = nil
174+
@@arp_opts.parse(args) { |opt, idx, val|
175+
case opt
176+
when '-S'
177+
search_term = val
178+
if search_term.nil?
179+
print_error("Enter a search term")
180+
return true
181+
else
182+
search_term = /#{search_term}/nmi
183+
end
184+
when "-h"
185+
@@arp_opts.usage
186+
return 0
187+
188+
end
189+
}
166190
tbl = Rex::Ui::Text::Table.new(
167191
'Header' => "ARP cache",
168192
'Indent' => 4,
@@ -171,7 +195,8 @@ def cmd_arp(*args)
171195
"IP address",
172196
"MAC address",
173197
"Interface"
174-
])
198+
],
199+
'SearchTerm' => search_term)
175200

176201
arp_table.each { |arp|
177202
tbl << [ arp.ip_addr, arp.mac_addr, arp.interface ]

0 commit comments

Comments
 (0)