Skip to content

Commit ea1ac3d

Browse files
authored
rapid7#9108: added -C option to change default hosts columns
The -C option saves the column list the user provided and uses that as the default column list until msfconsole is restarted
1 parent 9658776 commit ea1ac3d

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
@@ -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 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"

0 commit comments

Comments
 (0)