Module: Ronin::Exploits::Tests

Included in:
Exploit
Defined in:
lib/ronin/exploits/tests.rb

Overview

The Tests module contains convenience methods to be called when a built Exploit is tested.

Instance Method Summary collapse

Instance Method Details

#is_restricted?(text) ⇒ Boolean

Reviews the text for restricted characters.


110
111
112
113
114
115
116
# File 'lib/ronin/exploits/tests.rb', line 110

def is_restricted?(text)
  text.each_byte do |b|
    return true if @restricted_chars.include?(b)
  end

  return false
end

#test_arch!true

Tests that the selected target has an arch property.

Raises:


57
58
59
60
61
62
63
# File 'lib/ronin/exploits/tests.rb', line 57

def test_arch!
  if arch.nil?
    raise(TargetDataMissing,"no suitable arch was specified")
  end

  return true
end

#test_os!true

Tests that the selected target has an os property.

Raises:


75
76
77
78
79
80
81
# File 'lib/ronin/exploits/tests.rb', line 75

def test_os!
  if os.nil?
    raise(TargetDataMissing,"no suitable os was specified")
  end

  return true
end

#test_restricted!(text) ⇒ true

Reviews text for restricted characters.

Raises:

  • (RestrictedChar)

    A restricted character was found in the specified text.


130
131
132
133
134
135
136
137
138
139
140
# File 'lib/ronin/exploits/tests.rb', line 130

def test_restricted!(text)
  found = @restricted_chars.select { |char| text.include?(char) }

  found.map! { |char| char.dump }

  unless found.empty?
    raise(RestrictedChar,"restricted characters #{found.join(', ')} was detected in #{text.dump}")
  end

  return true
end

#test_software!true

Tests that the selected target has an software property.

Raises:

  • (TargetDataMissing)

    A valid piece of software was expected from the current target.


93
94
95
96
97
98
99
# File 'lib/ronin/exploits/tests.rb', line 93

def test_software!
  if software.nil?
    raise(TargetDataMissing,"no suitable software was specified")
  end

  return true
end

#test_target!true

Tests that a target has been selected.

Raises:


39
40
41
42
43
44
45
# File 'lib/ronin/exploits/tests.rb', line 39

def test_target!
  if target.nil?
    raise(TargetUnspecified,"no suitable target specified")
  end

  return true
end