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, NTPSymmetric

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


149
150
151
152
# File 'lib/rex/proto/ntp/modes.rb', line 149

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

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


120
121
122
123
124
125
126
127
128
129
130
# File 'lib/rex/proto/ntp/modes.rb', line 120

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


141
142
143
144
145
146
# File 'lib/rex/proto/ntp/modes.rb', line 141

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


132
133
134
135
136
137
138
139
# File 'lib/rex/proto/ntp/modes.rb', line 132

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