Module: Rex::Proto::NTP

Defined in:
lib/rex/proto/ntp/modes.rb,
lib/rex/proto/ntp/constants.rb

Defined Under Namespace

Classes: NTPControl, NTPGeneric, NTPPrivate

Constant Summary collapse

VERSIONS =
(0..7).to_a
MODES =
(0..7).to_a
MODE_6_OPERATIONS =
(0..31).to_a
MODE_7_IMPLEMENTATIONS =
(0..255).to_a
MODE_7_REQUEST_CODES =
(0..255).to_a

Class Method Summary collapse

Class Method Details

.describe(message) ⇒ Object

Parses the given message and provides a description about the NTP message inside



124
125
126
127
# File 'lib/rex/proto/ntp/modes.rb', line 124

def self.describe(message)
  ntp = NTPGeneric.new(message)
  "#{message.size}-byte version #{ntp.version} mode #{ntp.mode} reply"
end

.ntp_control(version, operation, payload = nil) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/rex/proto/ntp/modes.rb', line 95

def self.ntp_control(version, operation, payload = nil)
  n = NTPControl.new
  n.version = version
  n.operation = operation
  if payload
    n.payload_offset = 0
    n.payload_size = payload.size
    n.payload = payload
  end
  n
end

.ntp_generic(version, mode) ⇒ Object



116
117
118
119
120
121
# File 'lib/rex/proto/ntp/modes.rb', line 116

def self.ntp_generic(version, mode)
  n = NTPGeneric.new
  n.version = version
  n.mode = mode
  n
end

.ntp_private(version, implementation, request_code, payload = nil) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/rex/proto/ntp/modes.rb', line 107

def self.ntp_private(version, implementation, request_code, payload = nil)
  n = NTPPrivate.new
  n.version = version
  n.implementation = implementation
  n.request_code = request_code
  n.payload = payload if payload
  n
end