Class: Ronin::Fuzzing::Repeater

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/fuzzing/repeater.rb

Overview

Fuzzing class that generates repeated data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lengths) ⇒ Repeater

Initializes a new Repeater.

Parameters:

  • lengths (Enumerable, Integer)

    The lengths to repeat the data by.

Raises:

  • (TypeError)

    lengths must either be Enumerable or an Integer.



43
44
45
46
47
48
49
50
51
52
# File 'lib/ronin/fuzzing/repeater.rb', line 43

def initialize(lengths)
  @lengths = case lengths
             when Integer
               [lengths]
             when Enumerable
               lengths
             else
               raise(TypeError,"argument must be Enumerable or an Integer")
             end
end

Instance Attribute Details

#lengthsObject (readonly)

The lengths to repeat the data by



32
33
34
# File 'lib/ronin/fuzzing/repeater.rb', line 32

def lengths
  @lengths
end

Instance Method Details

#each(repeatable) {|repeated| ... } ⇒ Enumerator

Enumerates through each length of repeated data.

Parameters:

  • repeatable (#*)

    The repeatable data.

Yields:

  • (repeated)

    The given block will be passed every repeated String.

Yield Parameters:

  • repeated (String)

    A repeated version of the String.

Returns:

  • (Enumerator)

    If no block is given, an Enumerator will be returned.



69
70
71
72
73
74
75
76
77
# File 'lib/ronin/fuzzing/repeater.rb', line 69

def each(repeatable)
  return enum_for(__method__,repeatable) unless block_given?

  @lengths.each do |length|
    yield(repeatable * length)
  end

  return nil
end