Normalize the syntax and output of db.rb
parent
bd17e67f75
commit
bb02cc8509
|
@ -8,6 +8,7 @@ module Msf
|
|||
module Ui
|
||||
module Console
|
||||
module CommandDispatcher
|
||||
|
||||
class Db
|
||||
|
||||
require 'tempfile'
|
||||
|
@ -334,7 +335,7 @@ class Db
|
|||
}
|
||||
else
|
||||
print_line
|
||||
print_line tbl.to_s
|
||||
print_line(tbl.to_s)
|
||||
end
|
||||
|
||||
# Finally, handle the case where the user wants the resulting list
|
||||
|
@ -342,8 +343,6 @@ class Db
|
|||
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
|
||||
print_status("Deleted #{delete_count} hosts") if delete_count > 0
|
||||
}
|
||||
##
|
||||
##
|
||||
end
|
||||
|
||||
def cmd_services_help
|
||||
|
@ -517,7 +516,7 @@ class Db
|
|||
|
||||
print_line
|
||||
if (output_file == nil)
|
||||
print_line tbl.to_s
|
||||
print_line(tbl.to_s)
|
||||
else
|
||||
# create the output file
|
||||
::File.open(output_file, "wb") { |f| f.write(tbl.to_csv) }
|
||||
|
@ -679,6 +678,7 @@ class Db
|
|||
port_ranges = []
|
||||
rhosts = []
|
||||
svcs = []
|
||||
delete_count = 0
|
||||
search_term = nil
|
||||
|
||||
user = nil
|
||||
|
@ -822,6 +822,7 @@ class Db
|
|||
tbl << row
|
||||
if mode == :delete
|
||||
cred.destroy
|
||||
delete_count += 1
|
||||
end
|
||||
if set_rhosts
|
||||
addr = (cred.service.host.scope ? cred.service.host.address + '%' + cred.service.host.scope : cred.service.host.address )
|
||||
|
@ -832,7 +833,7 @@ class Db
|
|||
|
||||
print_line
|
||||
if (output_file == nil)
|
||||
print_line tbl.to_s
|
||||
print_line(tbl.to_s)
|
||||
else
|
||||
# create the output file
|
||||
::File.open(output_file, "wb") { |f| f.write(tbl.to_csv) }
|
||||
|
@ -840,7 +841,7 @@ class Db
|
|||
end
|
||||
|
||||
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
|
||||
print_status "Found #{creds_returned} credential#{creds_returned == 1 ? "" : "s"}."
|
||||
print_status("Deleted #{delete_count} credentials") if delete_count > 0
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -1011,7 +1012,7 @@ class Db
|
|||
# of hosts to go into RHOSTS.
|
||||
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
|
||||
|
||||
print_status("Deleted #{delete_count} note#{delete_count == 1 ? "" : "s"}") if delete_count > 0
|
||||
print_status("Deleted #{delete_count} notes") if delete_count > 0
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -1129,7 +1130,7 @@ class Db
|
|||
file = File.open(filename, "rb")
|
||||
contents = file.read
|
||||
lootfile = framework.db.find_or_create_loot(:type => type, :host => host,:info => info, :data => contents,:path => filename,:name => name)
|
||||
print_status "Added loot #{host}"
|
||||
print_status("Added loot #{host}")
|
||||
end
|
||||
end
|
||||
return
|
||||
|
@ -1189,8 +1190,8 @@ class Db
|
|||
end
|
||||
|
||||
print_line
|
||||
print_line tbl.to_s
|
||||
print_status "Deleted #{delete_count} loots" if delete_count > 0
|
||||
print_line(tbl.to_s)
|
||||
print_status("Deleted #{delete_count} loots") if delete_count > 0
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -1314,11 +1315,11 @@ class Db
|
|||
when :record_count
|
||||
print_status("Import: #{data[1]} records processed")
|
||||
when :warning
|
||||
print_error("")
|
||||
print_error
|
||||
data.split("\n").each do |line|
|
||||
print_error(line)
|
||||
end
|
||||
print_error("")
|
||||
print_error
|
||||
warnings += 1
|
||||
end
|
||||
end
|
||||
|
@ -1334,7 +1335,7 @@ class Db
|
|||
next
|
||||
rescue REXML::ParseException => e
|
||||
print_error("Failed to import #{filename} due to malformed XML:")
|
||||
print_error "#{$!.class}: #{$!}"
|
||||
print_error("#{$!.class}: #{$!}")
|
||||
elog("Failed to import #{filename}: #{$!.class}: #{$!}")
|
||||
dlog("Call stack: #{$@.join("\n")}", LEV_3)
|
||||
next
|
||||
|
@ -1364,9 +1365,9 @@ class Db
|
|||
while (arg = args.shift)
|
||||
case arg
|
||||
when '-h','--help'
|
||||
print_line("Usage:")
|
||||
print_line(" db_export -f <format> [-a] [filename]")
|
||||
print_line(" Format can be one of: #{export_formats.join(", ")}")
|
||||
print_line "Usage:"
|
||||
print_line " db_export -f <format> [-a] [filename]"
|
||||
print_line " Format can be one of: #{export_formats.join(", ")}"
|
||||
when '-f','--format'
|
||||
format = args.shift.to_s.downcase
|
||||
else
|
||||
|
@ -1452,14 +1453,14 @@ class Db
|
|||
temp_nmap_threads << framework.threads.spawn("db_nmap-Stdout", false, nmap_pipe[1]) do |np_1|
|
||||
np_1.each_line do |nmap_out|
|
||||
next if nmap_out.strip.empty?
|
||||
print_status "Nmap: #{nmap_out.strip}"
|
||||
print_status("Nmap: #{nmap_out.strip}")
|
||||
end
|
||||
end
|
||||
|
||||
temp_nmap_threads << framework.threads.spawn("db_nmap-Stderr", false, nmap_pipe[2]) do |np_2|
|
||||
np_2.each_line do |nmap_err|
|
||||
next if nmap_err.strip.empty?
|
||||
print_status "Nmap: '#{nmap_err.strip}'"
|
||||
print_status("Nmap: '#{nmap_err.strip}'")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1474,7 +1475,7 @@ class Db
|
|||
if save
|
||||
fd.rewind
|
||||
saved_path = report_store_local("nmap.scan.xml", "text/xml", fd.read, "nmap_#{Time.now.utc.to_i}")
|
||||
print_status "Saved NMAP XML results to #{saved_path}"
|
||||
print_status("Saved NMAP XML results to #{saved_path}")
|
||||
end
|
||||
fd.close(true)
|
||||
}
|
||||
|
@ -1609,7 +1610,7 @@ class Db
|
|||
#
|
||||
def set_rhosts_from_addrs(rhosts)
|
||||
if rhosts.empty?
|
||||
print_status "The list is empty, cowardly refusing to set RHOSTS"
|
||||
print_status("The list is empty, cowardly refusing to set RHOSTS")
|
||||
return
|
||||
end
|
||||
if active_module
|
||||
|
@ -1746,7 +1747,7 @@ class Db
|
|||
begin
|
||||
host_ranges << Rex::Socket::RangeWalker.new(arg)
|
||||
rescue
|
||||
print_error "Invalid host parameter, #{arg}."
|
||||
print_error("Invalid host parameter, #{arg}.")
|
||||
return
|
||||
end
|
||||
return true
|
||||
|
@ -1767,7 +1768,7 @@ class Db
|
|||
begin
|
||||
port_ranges << Rex::Socket.portspec_to_portlist(arg)
|
||||
rescue
|
||||
print_error "Invalid port parameter, #{arg}."
|
||||
print_error("Invalid port parameter, #{arg}.")
|
||||
return
|
||||
end
|
||||
return true
|
||||
|
@ -1811,7 +1812,5 @@ class Db
|
|||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end end end end
|
||||
|
|
Loading…
Reference in New Issue