From 574ebd07d7d9d0c8c568083ca94ce4296bddc249 Mon Sep 17 00:00:00 2001 From: William Vu Date: Tue, 20 Dec 2016 23:32:10 -0600 Subject: [PATCH] Update cmd_hosts --- lib/msf/ui/console/command_dispatcher/db.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/msf/ui/console/command_dispatcher/db.rb b/lib/msf/ui/console/command_dispatcher/db.rb index bacc21dcd4..a022d009e8 100644 --- a/lib/msf/ui/console/command_dispatcher/db.rb +++ b/lib/msf/ui/console/command_dispatcher/db.rb @@ -360,6 +360,11 @@ class Db onlyup = true when '-o' output = args.shift + when '-O' + if (order_by = args.shift.to_i - 1) < 0 + print_error('Please specify a column number starting from 1') + return + end when '-R', '--rhosts' set_rhosts = true when '-S', '--search' @@ -386,6 +391,7 @@ class Db print_line " -h,--help Show this help information" print_line " -u,--up Only show hosts which are up" print_line " -o Send output to a file in csv format" + print_line " -O Order rows by specified column number" print_line " -R,--rhosts Set RHOSTS from the results of the search" print_line " -S,--search Search string to filter by" print_line " -i,--info Change the info of a host" @@ -425,8 +431,9 @@ class Db # If we got here, we're searching. Delete implies search tbl = Rex::Text::Table.new( { - 'Header' => "Hosts", - 'Columns' => col_names, + 'Header' => "Hosts", + 'Columns' => col_names, + 'SortIndex' => order_by }) # Sentinal value meaning all