lib/ronin/fuzzing/fuzzing.rb in ronin-support-0.4.1 vs lib/ronin/fuzzing/fuzzing.rb in ronin-support-0.5.0.rc1
- old
+ new
@@ -64,10 +64,12 @@
if (!Object.respond_to?(name) && respond_to?(name))
enum_for(name)
end
end
+ module_function
+
#
# Various bad-strings.
#
# @yield [string]
# The given block will be passed each bad-string.
@@ -75,11 +77,11 @@
# @yieldparam [String] string
# A bad-string containing known control characters, deliminators
# or null-bytes (see {NULL_BYTES}), of varying length
# (see {SHORT_LENGTHS} and {LONG_LENGTHS}).
#
- def self.bad_strings(&block)
+ def bad_strings(&block)
yield ''
chars = [
'A', 'a', '1', '<', '>', '"', "'", '/', "\\", '?', '=', 'a=', '&',
'.', ',', '(', ')', ']', '[', '%', '*', '-', '+', '{', '}',
@@ -116,11 +118,11 @@
# The given block will be passed each format-string.
#
# @yieldparam [String] fmt_string
# A format-string containing format operators (see {FORMAT_STRINGS}).
#
- def self.format_strings(&block)
+ def format_strings(&block)
FORMAT_STRINGS.each do |fmt|
yield fmt
yield fmt * 100
yield fmt * 500
yield "\"#{fmt}\"" * 500
@@ -134,11 +136,11 @@
# The given block will be passed each path.
#
# @yieldparam [String] path
# A known bad path.
#
- def self.bad_paths(&block)
+ def bad_paths(&block)
padding = 'A' * 5_000
yield "/.:/#{padding}\x00\x00"
yield "/.../#{padding}\x00\x00"
@@ -164,11 +166,11 @@
# The given block will be passed each bit-field.
#
# @yieldparam [String] bitfield
# A bit-field (8bit - 64bit).
#
- def self.bit_fields(&block)
+ def bit_fields(&block)
("\x00".."\xff").each do |c|
yield c
yield c << c # x2
yield c << c # x4
yield c << c # x8
@@ -182,11 +184,11 @@
# The given block will be passed each bit-field.
#
# @yieldparam [String] bitfield
# A signed bit-field (8bit - 64bit).
#
- def self.signed_bit_fields(&block)
+ def signed_bit_fields(&block)
("\x80".."\xff").each do |c|
yield c
yield c << c # x2
yield c << c # x4
yield c << c # x8
@@ -200,11 +202,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A unsigned 8bit integer.
#
- def self.uint8(&block)
+ def uint8(&block)
("\x00".."\xff").each(&block)
end
#
# The range of unsigned 16bit integers.
@@ -213,11 +215,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A unsigned 16bit integer.
#
- def self.uint16
+ def uint16
uint8 { |c| yield c * 2 }
end
#
# The range of unsigned 32bit integers.
@@ -226,11 +228,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A unsigned 32bit integer.
#
- def self.uint32
+ def uint32
uint8 { |c| yield c * 4 }
end
#
# The range of unsigned 64bit integers.
@@ -239,11 +241,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A unsigned 64bit integer.
#
- def self.uint64
+ def uint64
uint8 { |c| yield c * 8 }
end
#
# The range of signed 8bit integers.
@@ -252,11 +254,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A signed 8bit integer.
#
- def self.int8(&block)
+ def int8(&block)
("\x00".."\x70").each(&block)
end
#
# The range of signed 16bit integers.
@@ -265,11 +267,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A signed 16bit integer.
#
- def self.int16
+ def int16
int8 { |c| yield c * 2 }
end
#
# The range of signed 32bit integers.
@@ -278,11 +280,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A signed 32bit integer.
#
- def self.int32
+ def int32
int8 { |c| yield c * 4 }
end
#
# The range of signed 64bit integers.
@@ -291,11 +293,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A signed 64bit integer.
#
- def self.int64
+ def int64
int8 { |c| yield c * 8 }
end
#
# The range of negative-signed 8bit integers.
@@ -304,11 +306,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A negative-signed 8bit integer.
#
- def self.sint8(&block)
+ def sint8(&block)
("\x80".."\xff").each(&block)
end
#
# The range of negative-signed 16bit integers.
@@ -317,11 +319,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A negative-signed 16bit integer.
#
- def self.sint16
+ def sint16
sint8 { |c| yield c * 2 }
end
#
# The range of negative-signed 32bit integers.
@@ -330,11 +332,11 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A negative-signed 32bit integer.
#
- def self.sint32
+ def sint32
sint8 { |c| yield c * 4 }
end
#
# The range of negative-signed 64bit integers.
@@ -343,10 +345,10 @@
# The given block will be passed each integer.
#
# @yieldparam [String] int
# A negative-signed 64bit integer.
#
- def self.sint64
+ def sint64
sint8 { |c| yield c * 8 }
end
end
end