Skip to content

Commit dd6e759

Browse files
author
Brent Cook
committed
add -l and -f flag simulation for pgrep, XXX rex handles flag opts poorly
1 parent 70bbacf commit dd6e759

File tree

1 file changed

+14
-3
lines changed
  • lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi

1 file changed

+14
-3
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,20 @@ def cmd_pgrep(*args)
421421
return true
422422
end
423423

424-
pids = processes.collect { |p| p['pid'] }
425-
pids.each do | pid |
426-
print_line(pid.to_s)
424+
# XXX fix Rex parser to properly handle adjacent short flags
425+
f_flag = args.include?('-f') || args.include?('-lf') || args.include?('-fl')
426+
l_flag = args.include?('-l') || args.include?('-lf') || args.include?('-fl')
427+
428+
processes.each do |p|
429+
if l_flag
430+
if f_flag
431+
print_line("#{p['pid']} #{p['path']}")
432+
else
433+
print_line("#{p['pid']} #{p['name']}")
434+
end
435+
else
436+
print_line("#{p['pid']}")
437+
end
427438
end
428439
true
429440
end

0 commit comments

Comments
 (0)