bug/bundler_fix
jvazquez-r7 2013-06-18 09:16:11 -05:00
commit 8a770d9022
1 changed files with 1653 additions and 1658 deletions

View File

@ -1,5 +1,5 @@
# -*- coding: binary -*-
#
require 'rexml/document'
require 'rex/parser/nmap_xml'
require 'msf/core/db_export'
@ -8,6 +8,7 @@ module Msf
module Ui
module Console
module CommandDispatcher
class Db
require 'tempfile'
@ -286,7 +287,6 @@ class Db
end
# If we got here, we're searching. Delete implies search
tbl = Rex::Ui::Text::Table.new(
{
'Header' => "Hosts",
@ -334,16 +334,15 @@ 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
# of hosts to go into RHOSTS.
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
print_status("Deleted #{delete_count} hosts") if delete_count > 0
}
##
##
end
def cmd_services_help
@ -476,7 +475,6 @@ class Db
end
# If we got here, we're searching. Delete implies search
col_names = default_columns
if col_search
col_names = col_search
@ -517,7 +515,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) }
@ -527,12 +525,12 @@ class Db
# Finally, handle the case where the user wants the resulting list
# of hosts to go into RHOSTS.
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
print_status("Deleted #{delete_count} services") if delete_count > 0
}
end
def cmd_vulns_help
print_line "Print all vulnerabilities in the database"
print_line
@ -550,7 +548,6 @@ class Db
print_line
end
def cmd_vulns(*args)
return unless active?
::ActiveRecord::Base.connection_pool.with_connection {
@ -634,7 +631,6 @@ class Db
}
end
def cmd_creds_help
print_line "Usage: creds [addr range]"
print_line "Usage: creds -a <addr range> -p <port> -t <type> -u <user> -P <pass>"
@ -679,6 +675,7 @@ class Db
port_ranges = []
rhosts = []
svcs = []
delete_count = 0
search_term = nil
user = nil
@ -774,7 +771,6 @@ class Db
end
# If we get here, we're searching. Delete implies search
if user
user_regex = Regexp.compile(user)
end
@ -822,6 +818,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 +829,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 +837,8 @@ 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
@ -932,9 +930,11 @@ class Db
note_list = []
delete_count = 0
if host_ranges.empty? # No host specified - collect all notes
# No host specified - collect all notes
if host_ranges.empty?
note_list = framework.db.notes.dup
else # Collect notes of specified hosts
# Collect notes of specified hosts
else
each_host_range_chunk(host_ranges) do |host_search|
framework.db.hosts(framework.db.workspace, false, host_search).each do |host|
note_list.concat(host.notes)
@ -1011,7 +1011,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 +1129,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 +1189,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
@ -1218,6 +1218,7 @@ class Db
# :category: Deprecated Commands
def cmd_db_autopwn(*args); deprecated_cmd; end
#
# :category: Deprecated Commands
#
# This one deserves a little more explanation than standard deprecation
@ -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,23 +1475,22 @@ 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)
}
end
#
# Store some locally-generated data as a file, similiar to store_loot.
#
def report_store_local(ltype=nil, ctype=nil, data=nil, filename=nil)
store_local(ltype,ctype,data,filename)
end
#
# Database management
#
def db_check_driver
if(not framework.db.driver)
print_error("No database driver installed. Try 'gem install pg'")
@ -1578,7 +1578,6 @@ class Db
end
end
def cmd_db_rebuild_cache
unless framework.db.active
print_error("The database is not connected")
@ -1609,7 +1608,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
@ -1636,7 +1635,6 @@ class Db
print_line
end
def db_find_tools(tools)
found = true
missed = []
@ -1726,10 +1724,9 @@ class Db
res
end
##
#
# Miscellaneous option helpers
##
#
#
# Parse +arg+ into a RangeWalker and append the result into +host_ranges+
@ -1746,7 +1743,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 +1764,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 +1808,5 @@ class Db
end
end
end
end
end
end
end end end end