Class: Nmap::XML::Service

Inherits:
Object
  • Object
show all
Includes:
CPE
Defined in:
lib/nmap/xml/service.rb

Overview

Wraps a service XML element.

Since:

  • 1.0.0

Instance Method Summary collapse

Methods included from CPE

#cpe, #each_cpe

Constructor Details

#initialize(node) ⇒ Service

Creates a new OS object.

Parameters:

  • node (Nokogiri::XML::Node)

    The node that contains the OS guessing information.

Since:

  • 1.0.0



22
23
24
# File 'lib/nmap/xml/service.rb', line 22

def initialize(node)
  @node = node
end

Instance Method Details

#confidenceInteger

The confidence score of the service fingerprinting.

Returns:

  • (Integer)

    The confidence score.

Since:

  • 1.0.0



154
155
156
# File 'lib/nmap/xml/service.rb', line 154

def confidence
  @confidence ||= @node.get_attribute('conf').to_i
end

#device_typeString

The reported device type.

Returns:

  • (String)

    The devicetype XML attribute.

Since:

  • 0.7.0



122
123
124
# File 'lib/nmap/xml/service.rb', line 122

def device_type
  @device_type ||= @node['devicetype']
end

#extra_infoString

The extra information from the service scan.

Returns:

  • (String)

    The extrainfo XML attribute.

Since:

  • 0.7.0



88
89
90
# File 'lib/nmap/xml/service.rb', line 88

def extra_info
  @extra_info ||= @node['extrainfo']
end

#fingerprintString

The actual fingerprint

Returns:

  • (String)

    The fingerprint

Since:

  • 0.7.0



144
145
146
# File 'lib/nmap/xml/service.rb', line 144

def fingerprint
  @fingerprint ||= @node.get_attribute('servicefp')
end

#fingerprint_methodSymbol

The fingerprint method used to identify the service.

Returns:

  • (Symbol)

    The fingerprint method.

Since:

  • 1.0.0



132
133
134
# File 'lib/nmap/xml/service.rb', line 132

def fingerprint_method
  @fingerprint_method ||= @node.get_attribute('method').to_sym
end

#hostnameString

The hostname reported by the service.

Returns:

  • (String)

    The reported hostname.

Since:

  • 1.0.0



98
99
100
# File 'lib/nmap/xml/service.rb', line 98

def hostname
  @hostname ||= @node.get_attribute('hostname')
end

#nameString

The name of the service.

Returns:

  • (String)

    The service name.

Since:

  • 1.0.0



32
33
34
# File 'lib/nmap/xml/service.rb', line 32

def name
  @name ||= @node.get_attribute('name')
end

#os_typeString

The reported OS type.

Returns:

  • (String)

    The ostype XML attribute.

Since:

  • 0.7.0



110
111
112
# File 'lib/nmap/xml/service.rb', line 110

def os_type
  @os_type ||= @node['ostype']
end

#productString

The product of the service.

Returns:

  • (String)

    The product name.

Since:

  • 1.0.0



66
67
68
# File 'lib/nmap/xml/service.rb', line 66

def product
  @product ||= @node.get_attribute('product')
end

#protocolString

The application protocol used by the service.

Returns:

  • (String)

    The proto XML attribute.

Since:

  • 0.7.0



56
57
58
# File 'lib/nmap/xml/service.rb', line 56

def protocol
  @protocol ||= @node['proto']
end

#ssl?Boolean

Determines if the service requires SSL.

Returns:

  • (Boolean)

    Checks whether the tunnel XML attribute is ssl.

Since:

  • 0.7.0



44
45
46
# File 'lib/nmap/xml/service.rb', line 44

def ssl?
  (@ssl ||= @node['tunnel']) == 'ssl'
end

#to_sString

Converts the service to a String.

Returns:

Since:

  • 1.0.0



164
165
166
167
168
169
170
# File 'lib/nmap/xml/service.rb', line 164

def to_s
  if (product && version)
    "#{product} #{version}"
  else
    name
  end
end

#versionString

The version of the service.

Returns:

  • (String)

    The service version.

Since:

  • 1.0.0



76
77
78
# File 'lib/nmap/xml/service.rb', line 76

def version
  @version ||= @node.get_attribute('version')
end