Module: Rex::Proto::DNS::Packet::Raw

Defined in:
lib/rex/proto/dns/packet.rb

Class Method Summary collapse

Class Method Details

.from_int_be(data) ⇒ Array

Convert data from big endian unsigned int

Parameters:

  • data (String)

    Input for conversion

Returns:

  • (Array)

    Integer array output


267
268
269
# File 'lib/rex/proto/dns/packet.rb', line 267

def self.from_int_be(data)
  data.unpack('I>*')
end

.from_int_le(data) ⇒ Array

Convert data from little endian unsigned int

Parameters:

  • data (String)

    Input for conversion

Returns:

  • (Array)

    Integer array output


207
208
209
# File 'lib/rex/proto/dns/packet.rb', line 207

def self.from_int_le(data)
  data.unpack('I*')
end

.from_long_be(data) ⇒ Array

Convert data from big endian unsigned long

Parameters:

  • data (String)

    Input for conversion

Returns:

  • (Array)

    Integer array output


287
288
289
# File 'lib/rex/proto/dns/packet.rb', line 287

def self.from_long_be(data)
  data.unpack('L>*')
end

.from_long_le(data) ⇒ Array

Convert data from little endian unsigned long

Parameters:

  • data (String)

    Input for conversion

Returns:

  • (Array)

    Integer array output


227
228
229
# File 'lib/rex/proto/dns/packet.rb', line 227

def self.from_long_le(data)
  data.unpack('L*')
end

.from_short_be(data) ⇒ Array

Convert data from big endian unsigned short

Parameters:

  • data (String)

    Input for conversion

Returns:

  • (Array)

    Integer array output


247
248
249
# File 'lib/rex/proto/dns/packet.rb', line 247

def self.from_short_be(data)
  data.unpack('S>*')
end

.from_short_le(data) ⇒ Array

Convert data from little endian unsigned short

Parameters:

  • data (String)

    Input for conversion

Returns:

  • (Array)

    Integer array output


187
188
189
# File 'lib/rex/proto/dns/packet.rb', line 187

def self.from_short_le(data)
  data.unpack('S*')
end

.request_id(data) ⇒ Fixnum

Returns request ID from raw packet skipping parsing

Parameters:

  • data (String)

    Request data

Returns:

  • (Fixnum)

    Request ID


297
298
299
# File 'lib/rex/proto/dns/packet.rb', line 297

def self.request_id(data)
  self.from_short_be(data[0..1])[0]
end

.request_length(data) ⇒ Fixnum

Returns request length from raw packet skipping parsing

Parameters:

  • data (String)

    Request data

Returns:

  • (Fixnum)

    Request Length


307
308
309
# File 'lib/rex/proto/dns/packet.rb', line 307

def self.request_length(data)
  self.from_short_le(data[0..2])[0]
end

.to_int_be(data) ⇒ String

Convert data to big endian unsigned int

Parameters:

  • data (Fixnum, Float, Array)

    Input for conversion

Returns:

  • (String)

    Raw output


257
258
259
# File 'lib/rex/proto/dns/packet.rb', line 257

def self.to_int_be(data)
  [data].flatten.pack('I>*')
end

.to_int_le(data) ⇒ String

Convert data to little endian unsigned int

Parameters:

  • data (Fixnum, Float, Array)

    Input for conversion

Returns:

  • (String)

    Raw output


197
198
199
# File 'lib/rex/proto/dns/packet.rb', line 197

def self.to_int_le(data)
  [data].flatten.pack('I*')
end

.to_long_be(data) ⇒ String

Convert data to big endian unsigned long

Parameters:

  • data (Fixnum, Float, Array)

    Input for conversion

Returns:

  • (String)

    Raw output


277
278
279
# File 'lib/rex/proto/dns/packet.rb', line 277

def self.to_long_be(data)
  [data].flatten.pack('L>*')
end

.to_long_le(data) ⇒ String

Convert data to little endian unsigned long

Parameters:

  • data (Fixnum, Float, Array)

    Input for conversion

Returns:

  • (String)

    Raw output


217
218
219
# File 'lib/rex/proto/dns/packet.rb', line 217

def self.to_long_le(data)
  [data].flatten.pack('L*')
end

.to_short_be(data) ⇒ String

Convert data to big endian unsigned short

Parameters:

  • data (Fixnum, Float, Array)

    Input for conversion

Returns:

  • (String)

    Raw output


237
238
239
# File 'lib/rex/proto/dns/packet.rb', line 237

def self.to_short_be(data)
  [data].flatten.pack('S>*')
end

.to_short_le(data) ⇒ String

Convert data to little endian unsigned short

Parameters:

  • data (Fixnum, Float, Array)

    Input for conversion

Returns:

  • (String)

    Raw output


177
178
179
# File 'lib/rex/proto/dns/packet.rb', line 177

def self.to_short_le(data)
  [data].flatten.pack('S*')
end