Module: Ronin::Exploits::Helpers::Padding

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

Overview

Adds methods to exploits for adding additional padding to date.

Parameters

  • padding ('A') - Padding string.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(obj) ⇒ Object


36
37
38
39
40
41
42
43
44
# File 'lib/ronin/exploits/helpers/padding.rb', line 36

def self.extended(obj)
  obj.instance_eval do
    # String to pad extra space with
    parameter :padding,
              type: String,
              default: 'A',
              description: 'padding string'
  end
end

Instance Method Details

#pad(max_length) ⇒ String (protected)

Creates padding out to a maximum length, using the padding parameter.

Examples:

pad(28)
# => "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"

Parameters:

  • max_length (Integer)

    The maximum length to pad out to.

Returns:

  • (String)

    A padded string.


62
63
64
# File 'lib/ronin/exploits/helpers/padding.rb', line 62

def pad(max_length)
  ''.pad(@padding.to_s,max_length)
end

#pad_left(data, max_length) ⇒ String (protected)

Pads the a string on the right-hand side out to a maximum length, using the padding parameter.

Examples:

pad_left("\xff\xff",48)
# => "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\xff\xff"

Parameters:

  • data (String)

    The string to add padding to.

  • max_length (Integer)

    The amount of padding to add.

Returns:

  • (String)

    The left-hand side padded string.


83
84
85
# File 'lib/ronin/exploits/helpers/padding.rb', line 83

def pad_left(data,max_length)
  pad(max_length - data.length) + data
end

#pad_right(data, max_length) ⇒ String (protected)

Pads the a string on the right-hand side out to a maximum length, using the padding parameter.

Examples:

pad_right("\xff\xff",48)
# => "\xff\xffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

Parameters:

  • data (String)

    The string to add padding to.

  • max_length (Integer)

    The amount of padding to add.

Returns:

  • (String)

    The right-hand side padded string.


104
105
106
# File 'lib/ronin/exploits/helpers/padding.rb', line 104

def pad_right(data,max_length)
  data.to_s.pad(@padding,max_length)
end