Skip to content

Commit 55f56a5

Browse files
committed
Land rapid7#9110, added -C option to change default hosts columns
2 parents 51a18b6 + 636551a commit 55f56a5

File tree

2 files changed

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

2 files changed

+10
-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
@@ -354,6 +354,8 @@ def delete_host_tag(rws, tag_name)
354354
end
355355
end
356356

357+
@@hosts_columns = [ 'address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', 'comments']
358+
357359
def cmd_hosts(*args)
358360
return unless active?
359361
::ActiveRecord::Base.connection_pool.with_connection {
@@ -371,7 +373,7 @@ def cmd_hosts(*args)
371373
default_columns << 'tags' # Special case
372374
virtual_columns = [ 'svcs', 'vulns', 'workspace', 'tags' ]
373375

374-
col_search = [ 'address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', 'comments']
376+
col_search = @@hosts_columns
375377

376378
default_columns.delete_if {|v| (v[-2,2] == "id")}
377379
while (arg = args.shift)
@@ -380,7 +382,7 @@ def cmd_hosts(*args)
380382
mode << :add
381383
when '-d','--delete'
382384
mode << :delete
383-
when '-c'
385+
when '-c','-C'
384386
list = args.shift
385387
if(!list)
386388
print_error("Invalid column list")
@@ -394,6 +396,10 @@ def cmd_hosts(*args)
394396
return
395397
end
396398
}
399+
if (arg == '-C')
400+
@@hosts_columns = col_search
401+
end
402+
397403
when '-u','--up'
398404
onlyup = true
399405
when '-o'
@@ -426,6 +432,7 @@ def cmd_hosts(*args)
426432
print_line " -a,--add Add the hosts instead of searching"
427433
print_line " -d,--delete Delete the hosts instead of searching"
428434
print_line " -c <col1,col2> Only show the given columns (see list below)"
435+
print_line " -C <col1,col2> Only show the given columns until the next restart (see list below)"
429436
print_line " -h,--help Show this help information"
430437
print_line " -u,--up Only show hosts which are up"
431438
print_line " -o <file> Send output to a file in csv format"

spec/lib/msf/ui/console/command_dispatcher/db_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
" -a,--add Add the hosts instead of searching",
126126
" -d,--delete Delete the hosts instead of searching",
127127
" -c <col1,col2> Only show the given columns (see list below)",
128+
" -C <col1,col2> Only show the given columns until the next restart (see list below)",
128129
" -h,--help Show this help information",
129130
" -u,--up Only show hosts which are up",
130131
" -o <file> Send output to a file in csv format",

0 commit comments

Comments
 (0)