Module: Ronin::Exploits::Helpers::Binary

Defined in:
lib/ronin/exploits/helpers/binary.rb

Overview

Adds methods to exploits for formatting binary data.

Constant Summary collapse

UINTS =
{
  little: {
    1 => :uchar,
    2 => :uint16_le,
    4 => :uint32_le,
    8 => :uint64_le
  },

  big: {
    1 => :uchar,
    2 => :uint16_be,
    4 => :uint32_be,
    8 => :uint64_be
  }
}

Instance Method Summary collapse

Instance Method Details

#pack(integer, type = nil) ⇒ String

Packs an integer using the current targeted architecture and the address-length.

Parameters:

  • integer (Integer)

    The integer to pack.

  • type (Symbol) (defaults to: nil)

    The optional type to pack the integer as.

Returns:

  • (String)

    The packed integer.

See Also:


64
65
66
67
68
69
70
# File 'lib/ronin/exploits/helpers/binary.rb', line 64

def pack(integer,type=nil)
  test_arch!

  type ||= UINTS.fetch(arch.endian.to_sym).fetch(arch.address_length)

  return integer.pack(type)
end