Skip to content

Commit 92e4358

Browse files
committed
Missed a file in the merge somehow
1 parent 4aac8f5 commit 92e4358

File tree

1 file changed

+19
-5
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+19
-5
lines changed

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ def delete_host_tag(rws, tag_name)
434434

435435
end
436436

437+
@@hosts_columns = [ 'address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', 'comments']
438+
437439
def cmd_hosts(*args)
438440
return unless active?
439441
onlyup = false
@@ -477,7 +479,7 @@ def cmd_hosts(*args)
477479
default_columns << 'tags' # Special case
478480
virtual_columns = [ 'svcs', 'vulns', 'workspace', 'tags' ]
479481

480-
col_search = [ 'address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', 'comments']
482+
col_search = @@hosts_columns
481483

482484
default_columns.delete_if {|v| (v[-2,2] == "id")}
483485
while (arg = args.shift)
@@ -486,7 +488,7 @@ def cmd_hosts(*args)
486488
mode << :add
487489
when '-d','--delete'
488490
mode << :delete
489-
when '-c'
491+
when '-c','-C'
490492
list = args.shift
491493
if(!list)
492494
print_error("Invalid column list")
@@ -500,6 +502,10 @@ def cmd_hosts(*args)
500502
return
501503
end
502504
}
505+
if (arg == '-C')
506+
@@hosts_columns = col_search
507+
end
508+
503509
when '-u','--up'
504510
onlyup = true
505511
when '-o'
@@ -532,6 +538,7 @@ def cmd_hosts(*args)
532538
print_line " -a,--add Add the hosts instead of searching"
533539
print_line " -d,--delete Delete the hosts instead of searching"
534540
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)"
535542
print_line " -h,--help Show this help information"
536543
print_line " -u,--up Only show hosts which are up"
537544
print_line " -o <file> Send output to a file in csv format"
@@ -1219,7 +1226,7 @@ def make_sortable(input)
12191226
def cmd_loot_help
12201227
print_line "Usage: loot <options>"
12211228
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]"
12231230
print_line " Del: loot -d [addr1 addr2 ...]"
12241231
print_line
12251232
print_line " -a,--add Add loot to the list of addresses, instead of listing"
@@ -1295,6 +1302,10 @@ def cmd_loot(*args)
12951302
host_ranges.push(nil) if host_ranges.empty?
12961303

12971304
if mode == :add
1305+
if host_ranges.compact.empty?
1306+
print_error('Address list required')
1307+
return
1308+
end
12981309
if info.nil?
12991310
print_error("Info required")
13001311
return
@@ -1309,17 +1320,18 @@ def cmd_loot(*args)
13091320
end
13101321
type = types.first
13111322
name = File.basename(filename)
1323+
file = File.open(filename, "rb")
1324+
contents = file.read
13121325
host_ranges.each do |range|
13131326
range.each do |host|
1314-
file = File.open(filename, "rb")
1315-
contents = file.read
13161327
lootfile = framework.db.find_or_create_loot(:type => type, :host => host, :info => info, :data => contents, :path => filename, :name => name)
13171328
print_status("Added loot for #{host} (#{lootfile})")
13181329
end
13191330
end
13201331
return
13211332
end
13221333

1334+
13231335
each_host_range_chunk(host_ranges) do |host_search|
13241336
framework.db.hosts(framework.db.workspace, false, host_search).each do |host|
13251337
loots = framework.db.loots(framework.db.workspace, {:host_id => host.id})
@@ -1928,6 +1940,8 @@ def db_parse_db_uri_postgresql(path)
19281940
if (path)
19291941
auth, dest = path.split('@')
19301942
(dest = auth and auth = nil) if not dest
1943+
# remove optional scheme in database url
1944+
auth = auth.sub(/^\w+:\/\//, "") if auth
19311945
res[:user],res[:pass] = auth.split(':') if auth
19321946
targ,name = dest.split('/')
19331947
(name = targ and targ = nil) if not name

0 commit comments

Comments
 (0)