Module: Ronin::Exploits::Mixins::Binary

Included in:
FormatString, SEH, StackOverflow
Defined in:
lib/ronin/exploits/mixins/binary.rb

Overview

Adds methods for packing binary data.

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#pack(type, value) ⇒ String

Packs a binary value for the given type.

Parameters:

  • type (Symbol)

    The type name to pack for.

  • value (Integer, Float, String)

    The value to pack.

Returns:

  • (String)

    The packed value.

Since:

  • 1.0.0



104
105
106
# File 'lib/ronin/exploits/mixins/binary.rb', line 104

def pack(type,value)
  platform[type].pack(value)
end

#perform_validateObject

Validates that the exploit defines an arch method and that all required params are set.

Raises:

Since:

  • 1.0.0



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ronin/exploits/mixins/binary.rb', line 49

def perform_validate
  unless respond_to?(:arch)
    raise(ValidationError,"exploit #{self.class} did not include Ronin::Exploits::Metadata::Arch or Ronin::Exploits::Mixins::HasTargets")
  end

  unless arch
    raise(ValidationError,"exploit #{self.class} did not include define an architecture")
  end

  super()
end

#platformRonin::Support::Binary::CTypes, ...

The target platform.

Returns:

  • (Ronin::Support::Binary::CTypes, Ronin::Support::Binary::CTypes::LittleEndian, Ronin::Support::Binary::CTypes::BigEndian, Ronin::Support::Binary::CTypes::Network, Ronin::Support::Binary::CTypes::Arch::ARM, Ronin::Support::Binary::CTypes::Arch::ARM::BigEndian, Ronin::Support::Binary::CTypes::Arch::ARM64, Ronin::Support::Binary::CTypes::Arch::ARM64::BigEndian, Ronin::Support::Binary::CTypes::Arch::MIPS, Ronin::Support::Binary::CTypes::Arch::MIPS::LittleEndian, Ronin::Support::Binary::CTypes::Arch::MIPS64, Ronin::Support::Binary::CTypes::Arch::MIPS64::LittleEndian, Ronin::Support::Binary::CTypes::Arch::PPC, Ronin::Support::Binary::CTypes::Arch::PPC64, Ronin::Support::Binary::CTypes::Arch::X86, Ronin::Support::Binary::CTypes::Arch::X86_64, Ronin::Support::Binary::CTypes::OS)

Raises:

  • (ArgumentError)

    The exploit defined an unknown arch or os value.

Since:

  • 1.0.0



85
86
87
88
89
90
# File 'lib/ronin/exploits/mixins/binary.rb', line 85

def platform
  @platform ||= Support::Binary::CTypes.platform(
                  arch: arch,
                  os:   (os if respond_to?(:os))
                )
end