@@ -434,6 +434,8 @@ def delete_host_tag(rws, tag_name)
434
434
435
435
end
436
436
437
+ @@hosts_columns = [ 'address' , 'mac' , 'name' , 'os_name' , 'os_flavor' , 'os_sp' , 'purpose' , 'info' , 'comments' ]
438
+
437
439
def cmd_hosts ( *args )
438
440
return unless active?
439
441
onlyup = false
@@ -477,7 +479,7 @@ def cmd_hosts(*args)
477
479
default_columns << 'tags' # Special case
478
480
virtual_columns = [ 'svcs' , 'vulns' , 'workspace' , 'tags' ]
479
481
480
- col_search = [ 'address' , 'mac' , 'name' , 'os_name' , 'os_flavor' , 'os_sp' , 'purpose' , 'info' , 'comments' ]
482
+ col_search = @@hosts_columns
481
483
482
484
default_columns . delete_if { |v | ( v [ -2 , 2 ] == "id" ) }
483
485
while ( arg = args . shift )
@@ -486,7 +488,7 @@ def cmd_hosts(*args)
486
488
mode << :add
487
489
when '-d' , '--delete'
488
490
mode << :delete
489
- when '-c'
491
+ when '-c' , '-C'
490
492
list = args . shift
491
493
if ( !list )
492
494
print_error ( "Invalid column list" )
@@ -500,6 +502,10 @@ def cmd_hosts(*args)
500
502
return
501
503
end
502
504
}
505
+ if ( arg == '-C' )
506
+ @@hosts_columns = col_search
507
+ end
508
+
503
509
when '-u' , '--up'
504
510
onlyup = true
505
511
when '-o'
@@ -532,6 +538,7 @@ def cmd_hosts(*args)
532
538
print_line " -a,--add Add the hosts instead of searching"
533
539
print_line " -d,--delete Delete the hosts instead of searching"
534
540
print_line " -c <col1,col2> Only show the given columns (see list below)"
541
+ print_line " -C <col1,col2> Only show the given columns until the next restart (see list below)"
535
542
print_line " -h,--help Show this help information"
536
543
print_line " -u,--up Only show hosts which are up"
537
544
print_line " -o <file> Send output to a file in csv format"
@@ -1219,7 +1226,7 @@ def make_sortable(input)
1219
1226
def cmd_loot_help
1220
1227
print_line "Usage: loot <options>"
1221
1228
print_line " Info: loot [-h] [addr1 addr2 ...] [-t <type1,type2>]"
1222
- print_line " Add: loot -f [fname] -i [info] -a [addr1 addr2 ...] [ -t [type]"
1229
+ print_line " Add: loot -f [fname] -i [info] -a [addr1 addr2 ...] -t [type]"
1223
1230
print_line " Del: loot -d [addr1 addr2 ...]"
1224
1231
print_line
1225
1232
print_line " -a,--add Add loot to the list of addresses, instead of listing"
@@ -1295,6 +1302,10 @@ def cmd_loot(*args)
1295
1302
host_ranges . push ( nil ) if host_ranges . empty?
1296
1303
1297
1304
if mode == :add
1305
+ if host_ranges . compact . empty?
1306
+ print_error ( 'Address list required' )
1307
+ return
1308
+ end
1298
1309
if info . nil?
1299
1310
print_error ( "Info required" )
1300
1311
return
@@ -1309,17 +1320,18 @@ def cmd_loot(*args)
1309
1320
end
1310
1321
type = types . first
1311
1322
name = File . basename ( filename )
1323
+ file = File . open ( filename , "rb" )
1324
+ contents = file . read
1312
1325
host_ranges . each do |range |
1313
1326
range . each do |host |
1314
- file = File . open ( filename , "rb" )
1315
- contents = file . read
1316
1327
lootfile = framework . db . find_or_create_loot ( :type => type , :host => host , :info => info , :data => contents , :path => filename , :name => name )
1317
1328
print_status ( "Added loot for #{ host } (#{ lootfile } )" )
1318
1329
end
1319
1330
end
1320
1331
return
1321
1332
end
1322
1333
1334
+
1323
1335
each_host_range_chunk ( host_ranges ) do |host_search |
1324
1336
framework . db . hosts ( framework . db . workspace , false , host_search ) . each do |host |
1325
1337
loots = framework . db . loots ( framework . db . workspace , { :host_id => host . id } )
@@ -1928,6 +1940,8 @@ def db_parse_db_uri_postgresql(path)
1928
1940
if ( path )
1929
1941
auth , dest = path . split ( '@' )
1930
1942
( dest = auth and auth = nil ) if not dest
1943
+ # remove optional scheme in database url
1944
+ auth = auth . sub ( /^\w +:\/ \/ / , "" ) if auth
1931
1945
res [ :user ] , res [ :pass ] = auth . split ( ':' ) if auth
1932
1946
targ , name = dest . split ( '/' )
1933
1947
( name = targ and targ = nil ) if not name
0 commit comments