1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00

add -l and -f flag simulation for pgrep, XXX rex handles flag opts poorly

This commit is contained in:
Brent Cook 2017-03-16 23:48:39 -05:00
parent 70bbacf7ed
commit dd6e75986d

View File

@ -421,9 +421,20 @@ class Console::CommandDispatcher::Stdapi::Sys
return true
end
pids = processes.collect { |p| p['pid'] }
pids.each do | pid |
print_line(pid.to_s)
# XXX fix Rex parser to properly handle adjacent short flags
f_flag = args.include?('-f') || args.include?('-lf') || args.include?('-fl')
l_flag = args.include?('-l') || args.include?('-lf') || args.include?('-fl')
processes.each do |p|
if l_flag
if f_flag
print_line("#{p['pid']} #{p['path']}")
else
print_line("#{p['pid']} #{p['name']}")
end
else
print_line("#{p['pid']}")
end
end
true
end