Skip to content

Commit 26785b3

Browse files
committed
Land rapid7#5483 : Use the correct help output for the ps command
2 parents 23df66b + 346ea40 commit 26785b3

File tree

1 file changed

+11
-17
lines changed
  • lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi

1 file changed

+11
-17
lines changed

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -429,20 +429,15 @@ def cmd_ps(*args)
429429
# Parse opts
430430
@@ps_opts.parse(args) { |opt, idx, val|
431431
case opt
432-
when '-S'
433-
search_term = val
434-
if search_term.nil?
435-
print_error("Enter a search term")
436-
return true
437-
end
438-
when '-h'
439-
print_line "Usage: ps [ options ]"
440-
print_line
441-
print_line "OPTIONS:"
442-
print_line " -S Search string to filter by"
443-
print_line " -h This help menu"
444-
print_line
445-
return 0
432+
when '-S'
433+
search_term = val
434+
if search_term.nil?
435+
print_error("Enter a search term")
436+
return true
437+
end
438+
when '-h'
439+
cmd_ps_help
440+
return true
446441
when "-A"
447442
print_line "Filtering on arch..."
448443
searched_procs = Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessList.new
@@ -491,7 +486,6 @@ def cmd_ps(*args)
491486
'SearchTerm' => search_term)
492487

493488
processes.each { |ent|
494-
495489
session = ent['session'] == 0xFFFFFFFF ? '' : ent['session'].to_s
496490
arch = ent['arch']
497491

@@ -503,8 +497,6 @@ def cmd_ps(*args)
503497
row = [ ent['pid'].to_s, ent['name'], arch, session, ent['user'], ent['path'] ]
504498

505499
tbl << row #if (search_term.nil? or row.join(' ').to_s.match(search_term))
506-
507-
508500
}
509501

510502
if (processes.length == 0)
@@ -518,6 +510,8 @@ def cmd_ps(*args)
518510
end
519511

520512
def cmd_ps_help
513+
print_line "Usage: ps [ options ]"
514+
print_line
521515
print_line "Use the command with no arguments to see all running processes."
522516
print_line "The following options can be used to filter those results:"
523517

0 commit comments

Comments
 (0)