add host.imported notes for import types other than nmap, see r9277; don't double-report hosts for nessus and ip360 imports
git-svn-id: file:///home/svn/framework3/trunk@12197 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
6dd44fa516
commit
ae1d3b78bc
|
@ -212,8 +212,10 @@ class DBManager
|
||||||
return address if address.kind_of? Host
|
return address if address.kind_of? Host
|
||||||
end
|
end
|
||||||
wspace = opts.delete(:workspace) || workspace
|
wspace = opts.delete(:workspace) || workspace
|
||||||
host = wspace.hosts.find_by_address(address)
|
if wspace.kind_of? String
|
||||||
return host
|
wspace = find_workspace(wspace)
|
||||||
|
end
|
||||||
|
return wspace.hosts.find_by_address(address)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -2952,6 +2954,7 @@ class DBManager
|
||||||
}
|
}
|
||||||
|
|
||||||
report_host(conf)
|
report_host(conf)
|
||||||
|
report_import_note(wspace, addr)
|
||||||
|
|
||||||
report_note(
|
report_note(
|
||||||
:workspace => wspace,
|
:workspace => wspace,
|
||||||
|
@ -3049,6 +3052,8 @@ class DBManager
|
||||||
parser.callback = Proc.new { |type, value|
|
parser.callback = Proc.new { |type, value|
|
||||||
case type
|
case type
|
||||||
when :host
|
when :host
|
||||||
|
# XXX: Blacklist should be checked here instead of saving a
|
||||||
|
# host we're just going to throw away later
|
||||||
hosts.push(value)
|
hosts.push(value)
|
||||||
when :vuln
|
when :vuln
|
||||||
value["id"] = value["id"].downcase if value["id"]
|
value["id"] = value["id"].downcase if value["id"]
|
||||||
|
@ -3132,6 +3137,7 @@ class DBManager
|
||||||
|
|
||||||
if (data[:state] != Msf::HostState::Dead)
|
if (data[:state] != Msf::HostState::Dead)
|
||||||
report_host(data)
|
report_host(data)
|
||||||
|
report_import_note(wspace, addr)
|
||||||
end
|
end
|
||||||
|
|
||||||
if h["os_family"]
|
if h["os_family"]
|
||||||
|
@ -4003,6 +4009,7 @@ class DBManager
|
||||||
# Record the hostname
|
# Record the hostname
|
||||||
hinfo.merge!(:name => hname.to_s.strip) if hname
|
hinfo.merge!(:name => hname.to_s.strip) if hname
|
||||||
report_host(hinfo)
|
report_host(hinfo)
|
||||||
|
report_import_note(wspace, addr)
|
||||||
|
|
||||||
# Record the OS
|
# Record the OS
|
||||||
os ||= host.elements["os_name"]
|
os ||= host.elements["os_name"]
|
||||||
|
@ -4064,10 +4071,23 @@ class DBManager
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
os = host['os']
|
||||||
|
hname = host['hname']
|
||||||
|
mac = host['mac']
|
||||||
|
|
||||||
|
host_info = {
|
||||||
|
:workspace => wspace,
|
||||||
|
:host => addr,
|
||||||
|
}
|
||||||
|
host_info[:name] = hname.to_s.strip if hname
|
||||||
|
host_info[:mac] = mac.to_s.strip.upcase if mac
|
||||||
|
|
||||||
|
report_host(host_info)
|
||||||
|
report_import_note(wspace, addr)
|
||||||
|
|
||||||
os = host['os']
|
os = host['os']
|
||||||
yield(:os,os) if block
|
yield(:os,os) if block
|
||||||
if os
|
if os
|
||||||
|
|
||||||
report_note(
|
report_note(
|
||||||
:workspace => wspace,
|
:workspace => wspace,
|
||||||
:host => addr,
|
:host => addr,
|
||||||
|
@ -4078,26 +4098,6 @@ class DBManager
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
hname = host['hname']
|
|
||||||
|
|
||||||
if hname
|
|
||||||
report_host(
|
|
||||||
:workspace => wspace,
|
|
||||||
:host => addr,
|
|
||||||
:name => hname.to_s.strip
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
mac = host['mac']
|
|
||||||
|
|
||||||
if mac
|
|
||||||
report_host(
|
|
||||||
:workspace => wspace,
|
|
||||||
:host => addr,
|
|
||||||
:mac => mac.to_s.strip.upcase
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
host['ports'].each do |item|
|
host['ports'].each do |item|
|
||||||
next if item['port'] == 0
|
next if item['port'] == 0
|
||||||
msf = nil
|
msf = nil
|
||||||
|
@ -4183,6 +4183,18 @@ class DBManager
|
||||||
end
|
end
|
||||||
|
|
||||||
os = host['os']
|
os = host['os']
|
||||||
|
hname = host['hname']
|
||||||
|
mac = host['mac']
|
||||||
|
|
||||||
|
host_hash = {
|
||||||
|
:workspace => wspace,
|
||||||
|
:host => addr,
|
||||||
|
}
|
||||||
|
host_hash[:name] = hname.to_s.strip if hname
|
||||||
|
host_hash[:mac] = mac.to_s.strip.upcase if mac
|
||||||
|
|
||||||
|
report_host(host_hash)
|
||||||
|
|
||||||
yield(:os, os) if block
|
yield(:os, os) if block
|
||||||
if os
|
if os
|
||||||
report_note(
|
report_note(
|
||||||
|
@ -4195,26 +4207,6 @@ class DBManager
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
hname = host['hname']
|
|
||||||
|
|
||||||
if hname
|
|
||||||
report_host(
|
|
||||||
:workspace => wspace,
|
|
||||||
:host => addr,
|
|
||||||
:name => hname.to_s.strip
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
mac = host['mac']
|
|
||||||
|
|
||||||
if mac
|
|
||||||
report_host(
|
|
||||||
:workspace => wspace,
|
|
||||||
:host => addr,
|
|
||||||
:mac => mac.to_s.strip.upcase
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
host['apps'].each do |item|
|
host['apps'].each do |item|
|
||||||
port = item['port'].to_s
|
port = item['port'].to_s
|
||||||
proto = item['proto'].to_s
|
proto = item['proto'].to_s
|
||||||
|
@ -4274,6 +4266,7 @@ class DBManager
|
||||||
hname = host.attributes['name'] || ''
|
hname = host.attributes['name'] || ''
|
||||||
|
|
||||||
report_host(:workspace => wspace, :host => addr, :name => hname, :state => Msf::HostState::Alive)
|
report_host(:workspace => wspace, :host => addr, :name => hname, :state => Msf::HostState::Alive)
|
||||||
|
report_import_note(wspace, addr)
|
||||||
|
|
||||||
if host.elements["OS"]
|
if host.elements["OS"]
|
||||||
hos = host.elements["OS"].text
|
hos = host.elements["OS"].text
|
||||||
|
@ -4500,7 +4493,8 @@ protected
|
||||||
p = port.match(/^([^\(]+)\((\d+)\/([^\)]+)\)/)
|
p = port.match(/^([^\(]+)\((\d+)\/([^\)]+)\)/)
|
||||||
return if not p
|
return if not p
|
||||||
|
|
||||||
report_host(:workspace => wspace, :host => addr, :state => Msf::HostState::Alive)
|
# Unnecessary as the caller should already have reported this host
|
||||||
|
#report_host(:workspace => wspace, :host => addr, :state => Msf::HostState::Alive)
|
||||||
name = p[1].strip
|
name = p[1].strip
|
||||||
port = p[2].to_i
|
port = p[2].to_i
|
||||||
proto = p[3].downcase
|
proto = p[3].downcase
|
||||||
|
|
Loading…
Reference in New Issue