Skip to content

Commit 42462f0

Browse files
committed
Land rapid7#7219, ps -c listing of child processes
Awesome work by @wvu-r7 to help with identifying processes started by the meterpreter session.
2 parents 3eb3c5a + 3d4d7aa commit 42462f0

File tree

1 file changed

+9
-0
lines changed
  • lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class Console::CommandDispatcher::Stdapi::Sys
6767
"-h" => [ false, "Help menu." ],
6868
"-A" => [ true, "Filters processes on architecture" ],
6969
"-s" => [ false, "Show only SYSTEM processes" ],
70+
"-c" => [ false, "Show only child processes of the current shell" ],
7071
"-U" => [ true, "Filters processes on the user using the supplied RegEx"])
7172

7273
#
@@ -458,6 +459,14 @@ def cmd_ps(*args)
458459
searched_procs << proc if proc["user"] == "NT AUTHORITY\\SYSTEM"
459460
end
460461
processes = searched_procs
462+
when "-c"
463+
print_line "Filtering on child processes of the current shell..."
464+
current_shell_pid = client.sys.process.getpid
465+
searched_procs = Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessList.new
466+
processes.each do |proc|
467+
searched_procs << proc if proc['ppid'] == current_shell_pid
468+
end
469+
processes = searched_procs
461470
when "-U"
462471
print_line "Filtering on user name..."
463472
searched_procs = Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessList.new

0 commit comments

Comments
 (0)