Skip to content

Commit 5738d80

Browse files
David MaloneyDavid Maloney
authored andcommitted
Add a bunch of extra filter options
1 parent 14c94e4 commit 5738d80

File tree

1 file changed

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

1 file changed

+38
-2
lines changed

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

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ class Console::CommandDispatcher::Stdapi::Sys
4747

4848
@@ps_opts = Rex::Parser::Arguments.new(
4949
"-h" => [false, "Help menu."],
50-
"-S" => [true, "RegEx term(s) to filter results with "])
50+
"-S" => [true, "RegEx term to filter on process name with "],
51+
"-A" => [true, "Arch to filter on (x86 or x86_64"],
52+
"-s" =>[false, "Show only SYSTEM processes"],
53+
"-U" => [true, "RegEx term to filter on user name with"])
5154

5255
#
5356
# List of supported commands.
@@ -284,7 +287,7 @@ def cmd_ps(*args)
284287
cmd_ps_help
285288
return true
286289
when "-S"
287-
print_line "Performing Search..."
290+
print_line "Filtering on process name..."
288291
searched_procs = Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessList.new
289292
processes.each do |proc|
290293
if val.nil? or val.empty?
@@ -294,6 +297,36 @@ def cmd_ps(*args)
294297
searched_procs << proc if proc["name"].match(/#{val}/)
295298
end
296299
processes = searched_procs
300+
when "-A"
301+
print_line "Filtering on arch..."
302+
searched_procs = Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessList.new
303+
processes.each do |proc|
304+
next if proc['arch'].nil? or proc['arch'].empty?
305+
if val.nil? or val.empty? or !(val == "x86" or val == "x86_64")
306+
print_line "You must select either x86 or x86_64"
307+
return false
308+
end
309+
searched_procs << proc if proc["arch"] == val
310+
end
311+
processes = searched_procs
312+
when "-s"
313+
print_line "Filtering on SYSTEM processes..."
314+
searched_procs = Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessList.new
315+
processes.each do |proc|
316+
searched_procs << proc if proc["user"] == "NT AUTHORITY\\SYSTEM"
317+
end
318+
processes = searched_procs
319+
when "-U"
320+
print_line "Filtering on user name..."
321+
searched_procs = Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessList.new
322+
processes.each do |proc|
323+
if val.nil? or val.empty?
324+
print_line "You must supply a search term!"
325+
return false
326+
end
327+
searched_procs << proc if proc["user"].match(/#{val}/)
328+
end
329+
processes = searched_procs
297330
end
298331
end
299332
if (processes.length == 0)
@@ -316,6 +349,8 @@ def cmd_ps_help
316349
print_line "Would return any processes with 'svc' in the name"
317350
end
318351

352+
353+
319354
#
320355
# Reboots the remote computer.
321356
#
@@ -627,6 +662,7 @@ def cmd_shutdown(*args)
627662
client.sys.power.shutdown
628663
end
629664

665+
630666
end
631667

632668
end

0 commit comments

Comments
 (0)