Skip to content

Commit 283f36f

Browse files
committed
Compare headers w/process keys instead of themselves
Also clarifies a bunch of old bad variable names
1 parent 32fbad7 commit 283f36f

File tree

1 file changed

+11
-11
lines changed
  • lib/rex/post/meterpreter/extensions/stdapi/sys

1 file changed

+11
-11
lines changed

lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,31 @@ def to_table(opts={})
390390
return Rex::Text::Table.new(opts)
391391
end
392392

393-
cols = [ "PID", "PPID", "Name", "Arch", "Session", "User", "Path" ]
394-
cols.delete_if do |c|
395-
none? {|r| r.has_key?(c.downcase)} ||
396-
all? {|r| r[c.downcase].nil?}
393+
column_headers = [ "PID", "PPID", "Name", "Arch", "Session", "User", "Path" ]
394+
column_headers.delete_if do |h|
395+
none? { |process| process.has_key?(h.downcase) } ||
396+
all? { |process| process[h.downcase].nil? }
397397
end
398398

399399
opts = {
400400
'Header' => 'Process List',
401401
'Indent' => 1,
402-
'Columns' => cols
402+
'Columns' => column_headers
403403
}.merge(opts)
404404

405405
tbl = Rex::Text::Table.new(opts)
406-
each { |process|
407-
tbl << cols.map { |c|
408-
next unless cols.any? {|h| h.downcase == c.downcase}
409-
col = c.downcase
406+
each do |process|
407+
tbl << column_headers.map do |header|
408+
col = header.downcase
409+
next unless process.keys.any? { |process_header| process_header == col }
410410
val = process[col]
411411
if col == 'session'
412412
val == 0xFFFFFFFF ? '' : val.to_s
413413
else
414414
val
415415
end
416-
}
417-
}
416+
end
417+
end
418418

419419
tbl
420420
end

0 commit comments

Comments
 (0)