Import OS and hostname information
git-svn-id: file:///home/svn/framework3/trunk@8491 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
ca4b9bbd52
commit
bfa3ae28cb
|
@ -1113,9 +1113,19 @@ class DBManager
|
|||
end
|
||||
data[:host] = addr
|
||||
if (h["addrs"].has_key?("mac"))
|
||||
data[:host_mac] = h["addrs"]["mac"]
|
||||
data[:mac] = h["addrs"]["mac"]
|
||||
end
|
||||
data[:state] = (h["status"] == "up") ? Msf::HostState::Alive : Msf::HostState::Dead
|
||||
|
||||
if (h["os_accuracy"] and h["os_accuracy"].to_i > 75)
|
||||
data[:os_name] = h["os_vendor"]
|
||||
data[:os_sp] = h["os_version"]
|
||||
end
|
||||
|
||||
if ( h["reverse_dns"] )
|
||||
data[:name] = h["reverse_dns"]
|
||||
end
|
||||
|
||||
report_host(data)
|
||||
|
||||
# Put all the ports, regardless of state, into the db.
|
||||
|
|
|
@ -12,24 +12,24 @@ module Parser
|
|||
# {
|
||||
# "status" => "up",
|
||||
# "addrs" => { "ipv4" => "192.168.0.1", "mac" => "00:0d:87:a1:df:72" },
|
||||
# "ports" => [
|
||||
# "ports" => [
|
||||
# { "portid" => "22", "state" => "closed", ... },
|
||||
# { "portid" => "80", "state" => "open", ... },
|
||||
# ...
|
||||
# ...
|
||||
# ]
|
||||
# }
|
||||
#
|
||||
# Usage:
|
||||
# <tt>
|
||||
# parser = NmapXMLStreamParser.new { |host|
|
||||
# parser = NmapXMLStreamParser.new { |host|
|
||||
# # do stuff with the host
|
||||
# }
|
||||
# REXML::Document.parse_stream(File.new(nmap_xml), parser)
|
||||
# </tt>
|
||||
# -- or --
|
||||
# <tt>
|
||||
# parser = NmapXMLStreamParser.new
|
||||
# parser.on_found_host = Proc.new { |host|
|
||||
# parser = NmapXMLStreamParser.new
|
||||
# parser.on_found_host = Proc.new { |host|
|
||||
# # do stuff with the host
|
||||
# }
|
||||
# REXML::Document.parse_stream(File.new(nmap_xml), parser)
|
||||
|
@ -59,6 +59,17 @@ class NmapXMLStreamParser
|
|||
if (attributes["addrtype"] =~ /ipv[46]/)
|
||||
@host["addr"] = attributes["addr"]
|
||||
end
|
||||
when "osclass"
|
||||
@host["os_vendor"] = attributes["vendor"]
|
||||
@host["os_family"] = attributes["osfamily"]
|
||||
@host["os_version"] = attributes["osgen"]
|
||||
@host["os_accuracy"] = attributes["accuracy"]
|
||||
when "uptime"
|
||||
@host["last_boot"] = attributes["lastboot"]
|
||||
when "hostname"
|
||||
if(attributes["type"] == "PTR")
|
||||
@host["reverse_dns"] = attributes["name"]
|
||||
end
|
||||
when "status"
|
||||
# <status> refers to the liveness of the host; values are "up" or "down"
|
||||
@host["status"] = attributes["state"]
|
||||
|
|
Loading…
Reference in New Issue