Class: Ronin::Code::SQL::Injection
- Defined in:
- lib/ronin/code/sql/injection.rb
Instance Attribute Summary collapse
-
#case_evasion ⇒ Object
Swapcase-Obfusciation.
-
#close_parens ⇒ Object
Specifies whether or not to close an open parenthesis.
-
#close_string ⇒ Object
Specifies whether or not to close an open string.
-
#comment_evasion ⇒ Object
Comment-Obfustication.
-
#end_statement ⇒ Object
Specifies whether or not to end a previous statement.
-
#escape ⇒ Object
Data to escape a previous expression with.
Attributes inherited from Program
#dialect, #less_parenthesis, #lowercase, #multiline, #newline, #space
Instance Method Summary collapse
- #compile ⇒ Object (also: #to_s)
-
#expression(&block) ⇒ Object
Returns the expression that will be injected into the effected statement.
-
#initialize(options = {}, &block) ⇒ Injection
constructor
A new instance of Injection.
- #sql(&block) ⇒ Object
Methods inherited from Program
Constructor Details
#initialize(options = {}, &block) ⇒ Injection
Returns a new instance of Injection.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ronin/code/sql/injection.rb', line 49 def initialize(={},&block) if .has_key?(:comment_evasion) @comment_evasion = [:comment_evasion] else @comment_evasion = false end if .has_key?(:case_evasion) @case_evasion = [:case_evasion] else @case_evasion = false end @escape = [:escape] if .has_key?(:close_string) @close_string = [:close_string] else @close_string = false end if .has_key?(:close_parens) @close_parens = [:close_parens] else @close_parens = false end if .has_key?(:end_statement) @end_statement = [:end_statement] else @end_statement = false end super() do @expression = InjectedStatement.new(@dialect) end instance_eval(&block) if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arguments, &block) ⇒ Object (protected)
Relays missed method calls to the injected expression.
192 193 194 195 196 197 198 |
# File 'lib/ronin/code/sql/injection.rb', line 192 def method_missing(name,*arguments,&block) if @expression.public_methods(false).include?(name.to_s) return @expression.send(name,*arguments,&block) end return super(name,*arguments,&block) end |
Instance Attribute Details
#case_evasion ⇒ Object
Swapcase-Obfusciation
35 36 37 |
# File 'lib/ronin/code/sql/injection.rb', line 35 def case_evasion @case_evasion end |
#close_parens ⇒ Object
Specifies whether or not to close an open parenthesis
44 45 46 |
# File 'lib/ronin/code/sql/injection.rb', line 44 def close_parens @close_parens end |
#close_string ⇒ Object
Specifies whether or not to close an open string
41 42 43 |
# File 'lib/ronin/code/sql/injection.rb', line 41 def close_string @close_string end |
#comment_evasion ⇒ Object
Comment-Obfustication
32 33 34 |
# File 'lib/ronin/code/sql/injection.rb', line 32 def comment_evasion @comment_evasion end |
#end_statement ⇒ Object
Specifies whether or not to end a previous statement
47 48 49 |
# File 'lib/ronin/code/sql/injection.rb', line 47 def end_statement @end_statement end |
#escape ⇒ Object
Data to escape a previous expression with
38 39 40 |
# File 'lib/ronin/code/sql/injection.rb', line 38 def escape @escape end |
Instance Method Details
#compile ⇒ Object Also known as: to_s
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ronin/code/sql/injection.rb', line 103 def compile injection = super.rstrip comment = lambda { [injection, '--'].join(space_token) } if (@close_parens && @close_string) if injection =~ /'\s*\)$/ return injection.gsub(/'\s*\)$/,'') else return comment.call end end if @close_string if injection[-1..-1] == "'" return injection.chop else return comment.call end end return injection end |
#expression(&block) ⇒ Object
Returns the expression that will be injected into the effected statement. If a block is given, it will be evaluated within the expression.
94 95 96 97 |
# File 'lib/ronin/code/sql/injection.rb', line 94 def expression(&block) @expression.instance_eval(&block) if block return @expression end |
#sql(&block) ⇒ Object
99 100 101 |
# File 'lib/ronin/code/sql/injection.rb', line 99 def sql(&block) @dialect.instance_eval(&block) if block end |