Class: Ronin::Vulns::ReflectedXSS::TestString Private
- Inherits:
-
Object
- Object
- Ronin::Vulns::ReflectedXSS::TestString
- Defined in:
- lib/ronin/vulns/reflected_xss/test_string.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A test string of characters to determine which special characters are escaped/filtered and which are passed through.
Constant Summary collapse
- ESCAPED_CHARS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Special characters and their common escaped equivalents.
{ "'" => ['%27', ''', "\\'"], '"' => ['%22', '"', "\\\""], ' ' => ['+', '%20', ' '], '=' => ['%3D'], '/' => ['%2F'], '<' => ['%3C', '<'], '>' => ['%3E', '>'], '&' => ['%26', '&'] }
Instance Attribute Summary collapse
-
#regexp ⇒ Regexp
readonly
private
The test regexp to determine which special characters were escaped/filtered and which were passed through unescaped.
-
#string ⇒ String
readonly
private
The test string.
Class Method Summary collapse
-
.build(chars) ⇒ TestString
private
Builds a test string from a mapping of characters and their HTML escaped equivalents.
Instance Method Summary collapse
-
#initialize(string, regexp) ⇒ TestString
constructor
private
Initializes the test string.
-
#match(body) ⇒ MatchData?
private
Matches the response body against #regexp.
-
#to_s ⇒ String
private
Converts the test string to a String.
-
#wrap(prefix, suffix) ⇒ TestString
private
Wraps the test string with a prefix and suffix.
Constructor Details
#initialize(string, regexp) ⇒ TestString
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the test string.
55 56 57 58 |
# File 'lib/ronin/vulns/reflected_xss/test_string.rb', line 55 def initialize(string,regexp) @string = string @regexp = regexp end |
Instance Attribute Details
#regexp ⇒ Regexp (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The test regexp to determine which special characters were escaped/filtered and which were passed through unescaped.
43 44 45 |
# File 'lib/ronin/vulns/reflected_xss/test_string.rb', line 43 def regexp @regexp end |
#string ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The test string.
37 38 39 |
# File 'lib/ronin/vulns/reflected_xss/test_string.rb', line 37 def string @string end |
Class Method Details
.build(chars) ⇒ TestString
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds a test string from a mapping of characters and their HTML escaped equivalents.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ronin/vulns/reflected_xss/test_string.rb', line 82 def self.build(chars) string = String.new regexp = String.new chars.each_char do |char| string << char regexp << "(?:(#{Regexp.escape(char)})" if (escaped_chars = ESCAPED_CHARS[char]) escaped_chars.each do |string| regexp << "|#{Regexp.escape(string)}" end end regexp << ')?' end return new(string,Regexp.new(regexp)) end |
Instance Method Details
#match(body) ⇒ MatchData?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Matches the response body against #regexp.
131 132 133 |
# File 'lib/ronin/vulns/reflected_xss/test_string.rb', line 131 def match(body) body.match(@regexp) end |
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts the test string to a String.
141 142 143 |
# File 'lib/ronin/vulns/reflected_xss/test_string.rb', line 141 def to_s @string end |
#wrap(prefix, suffix) ⇒ TestString
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wraps the test string with a prefix and suffix.
115 116 117 118 119 120 |
# File 'lib/ronin/vulns/reflected_xss/test_string.rb', line 115 def wrap(prefix,suffix) self.class.new( "#{prefix}#{@string}#{suffix}", /#{Regexp.escape(prefix)}#{@regexp}#{Regexp.escape(suffix)}/ ) end |