Skip to content

Commit b9e9d97

Browse files
committed
Add -O (order_by) to services (cmd_services)
1 parent 7aa743b commit b9e9d97

File tree

1 file changed

+9
-2
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+9
-2
lines changed

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,11 @@ def cmd_services(*args)
586586
return
587587
end
588588
output_file = ::File.expand_path(output_file)
589+
when '-O'
590+
if (order_by = args.shift.to_i - 1) == -1
591+
print_error('Please specify a column number starting from 1')
592+
return
593+
end
589594
when '-R', '--rhosts'
590595
set_rhosts = true
591596
when '-S', '--search'
@@ -604,6 +609,7 @@ def cmd_services(*args)
604609
print_line " -r <protocol> Only show [tcp|udp] services"
605610
print_line " -u,--up Only show services which are up"
606611
print_line " -o <file> Send output to a file in csv format"
612+
print_line " -O <column> Order rows by specified column number"
607613
print_line " -R,--rhosts Set RHOSTS from the results of the search"
608614
print_line " -S,--search Search string to filter by"
609615
print_line
@@ -651,8 +657,9 @@ def cmd_services(*args)
651657
col_names = col_search
652658
end
653659
tbl = Rex::Text::Table.new({
654-
'Header' => "Services",
655-
'Columns' => ['host'] + col_names,
660+
'Header' => "Services",
661+
'Columns' => ['host'] + col_names,
662+
'SortIndex' => order_by
656663
})
657664

658665
# Sentinal value meaning all

0 commit comments

Comments
 (0)