Class: Ncrack::XML::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/ncrack/xml/service.rb

Overview

Represents a service XML element.

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Service

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the service object.

Parameters:

  • node (Nokogiri::XML::Node)

    The XML node for the service XML element.



20
21
22
# File 'lib/ncrack/xml/service.rb', line 20

def initialize(node)
  @node = node
end

Instance Method Details

#addressAddress

The address information of the service.

Returns:

  • (Address)

    The address XML child element.



50
51
52
# File 'lib/ncrack/xml/service.rb', line 50

def address
  @address ||= Address.new(@node.at_xpath('address'))
end

#credentialCredential?

The first bruteforced credential.

Returns:

  • (Credential, nil)


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

def credential
  each_credentials.first
end

#credentialsArray<Credential>

The bruteforced credentials.

Returns:

  • (Array<Credential>)


89
90
91
# File 'lib/ncrack/xml/service.rb', line 89

def credentials
  each_credentials.to_a
end

#each_credentials {|credential| ... } ⇒ Enumerator

Enumerates over every bruteforced credential.

Yields:

  • (credential)

    If a block is given it will be passed each bruteforced credential.

Yield Parameters:

  • credential (Credential)

    A bruteforced credential.

Returns:

  • (Enumerator)

    If no block is given, an Enumerator will be returned.



76
77
78
79
80
81
82
# File 'lib/ncrack/xml/service.rb', line 76

def each_credentials
  return enum_for(__method__) unless block_given?

  @node.xpath('credentials').each do |node|
    yield Credentials.new(node)
  end
end

#end_timeTime

When bruteforcing of the service stopped.

Returns:

  • (Time)

    The parsed value of the endtime attribute.



40
41
42
# File 'lib/ncrack/xml/service.rb', line 40

def end_time
  @end_time ||= Time.at(@node['endtime'].to_i)
end

#portPort

The port information of the service.

Returns:

  • (Port)

    The port XML child element.



60
61
62
# File 'lib/ncrack/xml/service.rb', line 60

def port
  @port ||= Port.new(@node.at_xpath('port'))
end

#start_timeTime

When bruteforcing of the service begin.

Returns:

  • (Time)

    The parsed value of the starttime attribute.



30
31
32
# File 'lib/ncrack/xml/service.rb', line 30

def start_time
  @start_time ||= Time.at(@node['starttime'].to_i)
end