@@ -360,6 +360,11 @@ def cmd_hosts(*args)
360
360
onlyup = true
361
361
when '-o'
362
362
output = args . shift
363
+ when '-O'
364
+ if ( order_by = args . shift . to_i - 1 ) < 0
365
+ print_error ( 'Please specify a column number starting from 1' )
366
+ return
367
+ end
363
368
when '-R' , '--rhosts'
364
369
set_rhosts = true
365
370
when '-S' , '--search'
@@ -386,6 +391,7 @@ def cmd_hosts(*args)
386
391
print_line " -h,--help Show this help information"
387
392
print_line " -u,--up Only show hosts which are up"
388
393
print_line " -o <file> Send output to a file in csv format"
394
+ print_line " -O <column> Order rows by specified column number"
389
395
print_line " -R,--rhosts Set RHOSTS from the results of the search"
390
396
print_line " -S,--search Search string to filter by"
391
397
print_line " -i,--info Change the info of a host"
@@ -425,8 +431,9 @@ def cmd_hosts(*args)
425
431
# If we got here, we're searching. Delete implies search
426
432
tbl = Rex ::Text ::Table . new (
427
433
{
428
- 'Header' => "Hosts" ,
429
- 'Columns' => col_names ,
434
+ 'Header' => "Hosts" ,
435
+ 'Columns' => col_names ,
436
+ 'SortIndex' => order_by
430
437
} )
431
438
432
439
# Sentinal value meaning all
@@ -586,6 +593,11 @@ def cmd_services(*args)
586
593
return
587
594
end
588
595
output_file = ::File . expand_path ( output_file )
596
+ when '-O'
597
+ if ( order_by = args . shift . to_i - 1 ) < 0
598
+ print_error ( 'Please specify a column number starting from 1' )
599
+ return
600
+ end
589
601
when '-R' , '--rhosts'
590
602
set_rhosts = true
591
603
when '-S' , '--search'
@@ -604,6 +616,7 @@ def cmd_services(*args)
604
616
print_line " -r <protocol> Only show [tcp|udp] services"
605
617
print_line " -u,--up Only show services which are up"
606
618
print_line " -o <file> Send output to a file in csv format"
619
+ print_line " -O <column> Order rows by specified column number"
607
620
print_line " -R,--rhosts Set RHOSTS from the results of the search"
608
621
print_line " -S,--search Search string to filter by"
609
622
print_line
@@ -651,8 +664,9 @@ def cmd_services(*args)
651
664
col_names = col_search
652
665
end
653
666
tbl = Rex ::Text ::Table . new ( {
654
- 'Header' => "Services" ,
655
- 'Columns' => [ 'host' ] + col_names ,
667
+ 'Header' => "Services" ,
668
+ 'Columns' => [ 'host' ] + col_names ,
669
+ 'SortIndex' => order_by
656
670
} )
657
671
658
672
# Sentinal value meaning all
0 commit comments