remove deprecated db_add_* and db_del_* commands see #4963
git-svn-id: file:///home/svn/framework3/trunk@13231 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
c066ee0a90
commit
8a9eb35c54
|
@ -57,8 +57,6 @@ class Db
|
||||||
"db_exploited" => "List all exploited hosts in the database",
|
"db_exploited" => "List all exploited hosts in the database",
|
||||||
"db_add_port" => "Add a port to a host",
|
"db_add_port" => "Add a port to a host",
|
||||||
"db_add_cred" => "Add a credential to a host:port",
|
"db_add_cred" => "Add a credential to a host:port",
|
||||||
"db_del_host" => "Delete one or more hosts from the database",
|
|
||||||
"db_del_port" => "Delete one port from the database",
|
|
||||||
"db_autopwn" => "Automatically exploit everything",
|
"db_autopwn" => "Automatically exploit everything",
|
||||||
"db_import" => "Import a scan result file (filetype will be auto-detected)",
|
"db_import" => "Import a scan result file (filetype will be auto-detected)",
|
||||||
"db_export" => "Export a file containing the contents of the database",
|
"db_export" => "Export a file containing the contents of the database",
|
||||||
|
@ -327,7 +325,7 @@ class Db
|
||||||
col_search = ['port', 'proto', 'name', 'state', 'info']
|
col_search = ['port', 'proto', 'name', 'state', 'info']
|
||||||
default_columns = ::Msf::DBManager::Service.column_names.sort
|
default_columns = ::Msf::DBManager::Service.column_names.sort
|
||||||
default_columns.delete_if {|v| (v[-2,2] == "id")}
|
default_columns.delete_if {|v| (v[-2,2] == "id")}
|
||||||
addrlist = []
|
hostlist = []
|
||||||
while (arg = args.shift)
|
while (arg = args.shift)
|
||||||
case arg
|
case arg
|
||||||
when '-a','--add'
|
when '-a','--add'
|
||||||
|
@ -400,13 +398,13 @@ class Db
|
||||||
print_line
|
print_line
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
addrlist << arg
|
hostlist << arg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
case mode
|
case mode
|
||||||
when :add
|
when :add
|
||||||
addrlist.each { |addr|
|
hostlist.each { |addr|
|
||||||
# XXX: Can only deal with one port and one service name at
|
# XXX: Can only deal with one port and one service name at
|
||||||
# a time right now. Them's the breaks.
|
# a time right now. Them's the breaks.
|
||||||
host = framework.db.find_or_create_host(:host => addr)
|
host = framework.db.find_or_create_host(:host => addr)
|
||||||
|
@ -423,10 +421,10 @@ class Db
|
||||||
}
|
}
|
||||||
|
|
||||||
when :delete
|
when :delete
|
||||||
addrlist.each { |addr|
|
hostlist.each { |addr|
|
||||||
host = framework.db.workspace.hosts.find_by_address(addr)
|
host = framework.db.workspace.hosts.find_by_address(addr)
|
||||||
next if not host
|
next if not host
|
||||||
svc = host.services.find_by_port(port)
|
svc = host.services.find_by_port_and_proto(port, proto||'tcp')
|
||||||
next if not svc
|
next if not svc
|
||||||
print_status("Time: #{svc.created_at} Note: host=#{svc.host.address} port=#{svc.port} proto=#{svc.proto} name=#{svc.name}")
|
print_status("Time: #{svc.created_at} Note: host=#{svc.host.address} port=#{svc.port} proto=#{svc.proto} name=#{svc.name}")
|
||||||
svc.destroy
|
svc.destroy
|
||||||
|
@ -443,11 +441,11 @@ class Db
|
||||||
})
|
})
|
||||||
# The user didn't give us any addresses to search for, so
|
# The user didn't give us any addresses to search for, so
|
||||||
# switch to nil so ActiveRecord will return all of them.
|
# switch to nil so ActiveRecord will return all of them.
|
||||||
if addrlist.empty?
|
if hostlist.empty?
|
||||||
addrlist = nil
|
hostlist = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
framework.db.services(framework.db.workspace, onlyup, proto, addrlist, ports, names).each do |service|
|
framework.db.services(framework.db.workspace, onlyup, proto, hostlist, ports, names).each do |service|
|
||||||
host = service.host
|
host = service.host
|
||||||
columns = [host.address] + col_names.map { |n| service[n].to_s || "" }
|
columns = [host.address] + col_names.map { |n| service[n].to_s || "" }
|
||||||
tbl << columns
|
tbl << columns
|
||||||
|
@ -814,40 +812,6 @@ class Db
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cmd_db_add_port(*args)
|
|
||||||
return unless active?
|
|
||||||
if (not args or args.length < 2 or args.length > 4)
|
|
||||||
print_status("Usage: db_add_port <host> <port> [proto] [name]")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
host = framework.db.find_or_create_host(:host => args[0])
|
|
||||||
return if not host
|
|
||||||
info = {
|
|
||||||
:host => host,
|
|
||||||
:port => args[1].to_i
|
|
||||||
}
|
|
||||||
info[:proto] = args[2].downcase if args[2]
|
|
||||||
info[:name] = args[3].downcase if args[3]
|
|
||||||
|
|
||||||
service = framework.db.find_or_create_service(info)
|
|
||||||
return if not service
|
|
||||||
|
|
||||||
print_status("Time: #{service.created_at} Service: host=#{service.host.address} port=#{service.port} proto=#{service.proto} state=#{service.state}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def cmd_db_del_port(*args)
|
|
||||||
return unless active?
|
|
||||||
if (not args or args.length < 3)
|
|
||||||
print_status("Usage: db_del_port [host] [port] [proto]")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if framework.db.del_service(framework.db.workspace, args[0], args[2].downcase, args[1].to_i)
|
|
||||||
print_status("Service: host=#{args[0]} port=#{args[1].to_i} proto=#{args[2].downcase} deleted")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def cmd_db_add_cred(*args)
|
def cmd_db_add_cred(*args)
|
||||||
return unless active?
|
return unless active?
|
||||||
if (!args || args.length < 3)
|
if (!args || args.length < 3)
|
||||||
|
@ -867,15 +831,6 @@ class Db
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cmd_db_del_host(*args)
|
|
||||||
return unless active?
|
|
||||||
args.each do |address|
|
|
||||||
if framework.db.del_host(framework.db.workspace, address)
|
|
||||||
print_status("Host #{address} deleted")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# A shotgun approach to network-wide exploitation
|
# A shotgun approach to network-wide exploitation
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue