Class HostMap::Discovery::HostDiscovery::Host
In: lib/discovery/host.rb
Parent: Object

Host model

Methods

new   to_maltego   to_txt   to_xml  

Attributes

alias  [RW]  List of hostnames for this IP.
domains  [RW]  List of domains for this host.
ip  [R]  Host IP address.
mx  [RW]  List of host mail exchanges servers.
ns  [RW]  List of nameservers that handle names for this host.

Public Class methods

[Source]

# File lib/discovery/host.rb, line 223
        def initialize(ip)
          @ip = ip
          @mx = Set.new
          @ns = Set.new
          @alias = Set.new
          @domains = Set.new
        end

Public Instance methods

Returns host status in Maltego format.

[Source]

# File lib/discovery/host.rb, line 280
        def to_maltego(out = "")
          out << "<MaltegoMessage>"
          out << "<MaltegoTransformResponseMessage>"
          out << "<Entities>"

          if @ns.size > 0
            @ns.each { |a|
              out << "<Entity Type=\"NSrecord\">"
              out << "<Value>#{a}</Value>"
              out << "<Weight>100</Weight>"
              out << "</Entity>"
            }
          end

          if @mx.size > 0
            @mx.each { |a|
              out << "<Entity Type=\"MXrecord\">"
              out << "<Value>#{a}</Value>"
              out << "<Weight>100</Weight>"
              out << "</Entity>"
            }
          end

          if @alias.size > 0
            @alias.each { |a|
              out << "<Entity Type=\"DNSName\">"
              out << "<Value>#{a}</Value>"
              out << "<Weight>100</Weight>"
              out << "</Entity>"
            }
          end

          out << "</Entities>"
          out << "<UIMessages>" 
          out << "</UIMessages>"
          out << "</MaltegoTransformResponseMessage>"
          out << "</MaltegoMessage>"
        end

Return host status in formatted text.

[Source]

# File lib/discovery/host.rb, line 252
        def to_txt(out = "")
          out << "Results for #{@ip}\n"
          out << "Served by name server (probably)\n"
          if @ns.size > 0
            @ns.each {|a| out << "\t#{a}\n" }
          else
            out << "No results found."
          end
          out << "Served by mail exchange (probably)\n"
          if @mx.size > 0
            @mx.each {|a| out << "\t#{a}\n" }
          else
            out << "No results found."
          end
          #out << "Part of domain (probably)\n"
          #@domains.each {|a| out << "\t#{a}\n" }
          out << "Hostnames:\n"
          if @alias.size > 0
            @alias.each {|a| out << "\t#{a}\n" }
          else
            out << "No results found."
          end
          out
        end

Return host status as XML.

[Source]

# File lib/discovery/host.rb, line 234
        def to_xml
          doc = REXML::Document.new
          root = doc.add_element('host', { 'ip' => @ip, 'time' => Time.now})
          {'mail server' => @ms, 'name server' => @ns, 'domain' => @domains, 'hostname' => @alias}.each do |key, value|
            if value.nil?
              next
            end
            value.each do |val|
              node = root.add_element(key)
              node.text = val
            end
          end
          doc
        end

[Validate]