@@ -47,7 +47,10 @@ class Console::CommandDispatcher::Stdapi::Sys
47
47
48
48
@@ps_opts = Rex ::Parser ::Arguments . new (
49
49
"-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" ] )
51
54
52
55
#
53
56
# List of supported commands.
@@ -284,7 +287,7 @@ def cmd_ps(*args)
284
287
cmd_ps_help
285
288
return true
286
289
when "-S"
287
- print_line "Performing Search ..."
290
+ print_line "Filtering on process name ..."
288
291
searched_procs = Rex ::Post ::Meterpreter ::Extensions ::Stdapi ::Sys ::ProcessList . new
289
292
processes . each do |proc |
290
293
if val . nil? or val . empty?
@@ -294,6 +297,36 @@ def cmd_ps(*args)
294
297
searched_procs << proc if proc [ "name" ] . match ( /#{ val } / )
295
298
end
296
299
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
297
330
end
298
331
end
299
332
if ( processes . length == 0 )
@@ -316,6 +349,8 @@ def cmd_ps_help
316
349
print_line "Would return any processes with 'svc' in the name"
317
350
end
318
351
352
+
353
+
319
354
#
320
355
# Reboots the remote computer.
321
356
#
@@ -627,6 +662,7 @@ def cmd_shutdown(*args)
627
662
client . sys . power . shutdown
628
663
end
629
664
665
+
630
666
end
631
667
632
668
end
0 commit comments