ronin-sql 0.2.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +4 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/COPYING.txt +623 -288
- data/{History.txt → ChangeLog.md} +33 -35
- data/Gemfile +25 -0
- data/README.md +110 -0
- data/Rakefile +30 -20
- data/bin/ronin-sql +18 -5
- data/gemspec.yml +16 -0
- data/lib/ronin/formatting/extensions/sql.rb +4 -3
- data/lib/ronin/formatting/extensions/sql/string.rb +83 -10
- data/lib/ronin/formatting/sql.rb +4 -3
- data/lib/ronin/sql.rb +5 -12
- data/lib/ronin/{code/sql/create_index.rb → sql/binary_expr.rb} +25 -18
- data/lib/ronin/sql/clause.rb +72 -0
- data/lib/ronin/sql/clauses.rb +297 -0
- data/lib/ronin/sql/emittable.rb +84 -0
- data/lib/ronin/sql/emitter.rb +375 -0
- data/lib/ronin/sql/field.rb +106 -0
- data/lib/ronin/{code/sql/as.rb → sql/fields.rb} +36 -17
- data/lib/ronin/{code/sql/binary_expr.rb → sql/function.rb} +27 -27
- data/lib/ronin/sql/functions.rb +989 -0
- data/lib/ronin/sql/injection.rb +125 -157
- data/lib/ronin/{code/sql/default_values_clause.rb → sql/literal.rb} +13 -11
- data/lib/ronin/sql/literals.rb +72 -0
- data/lib/ronin/sql/operators.rb +332 -0
- data/lib/ronin/sql/sql.rb +86 -0
- data/lib/ronin/sql/statement.rb +70 -0
- data/lib/ronin/sql/statement_list.rb +110 -0
- data/lib/ronin/sql/statements.rb +115 -0
- data/lib/ronin/{code/sql/desc.rb → sql/unary_expr.rb} +11 -11
- data/lib/ronin/sql/version.rb +5 -4
- data/ronin-sql.gemspec +61 -0
- data/spec/formatting/sql/string_spec.rb +172 -0
- data/spec/spec_helper.rb +1 -4
- data/spec/sql/binary_expr.rb +5 -0
- data/spec/sql/binary_expr_examples.rb +25 -0
- data/spec/sql/clause_examples.rb +43 -0
- data/spec/sql/clause_spec.rb +31 -0
- data/spec/sql/clauses_spec.rb +43 -0
- data/spec/sql/emittable_spec.rb +41 -0
- data/spec/sql/emitter_spec.rb +472 -0
- data/spec/sql/field_spec.rb +103 -0
- data/spec/sql/fields_spec.rb +40 -0
- data/spec/sql/function_examples.rb +30 -0
- data/spec/sql/function_spec.rb +25 -0
- data/spec/sql/functions_spec.rb +110 -0
- data/spec/sql/injection_spec.rb +233 -0
- data/spec/sql/literal_spec.rb +5 -0
- data/spec/sql/literals_spec.rb +46 -0
- data/spec/sql/operators_spec.rb +44 -0
- data/spec/sql/sql_spec.rb +18 -0
- data/spec/sql/statement_examples.rb +39 -0
- data/spec/sql/statement_list_spec.rb +48 -0
- data/spec/sql/statement_sql.rb +38 -0
- data/spec/sql/statements_spec.rb +22 -0
- data/spec/sql/unary_expr.rb +5 -0
- data/spec/sql/unary_expr_examples.rb +20 -0
- metadata +116 -217
- data.tar.gz.sig +0 -0
- data/Manifest.txt +0 -108
- data/README.txt +0 -112
- data/lib/ronin/code/sql.rb +0 -22
- data/lib/ronin/code/sql/add_column_clause.rb +0 -42
- data/lib/ronin/code/sql/alter_table.rb +0 -52
- data/lib/ronin/code/sql/asc.rb +0 -36
- data/lib/ronin/code/sql/between.rb +0 -66
- data/lib/ronin/code/sql/clause.rb +0 -35
- data/lib/ronin/code/sql/code.rb +0 -35
- data/lib/ronin/code/sql/common_dialect.rb +0 -66
- data/lib/ronin/code/sql/create.rb +0 -74
- data/lib/ronin/code/sql/create_table.rb +0 -44
- data/lib/ronin/code/sql/create_view.rb +0 -41
- data/lib/ronin/code/sql/delete.rb +0 -52
- data/lib/ronin/code/sql/dialect.rb +0 -282
- data/lib/ronin/code/sql/drop.rb +0 -55
- data/lib/ronin/code/sql/drop_index.rb +0 -41
- data/lib/ronin/code/sql/drop_table.rb +0 -41
- data/lib/ronin/code/sql/drop_view.rb +0 -41
- data/lib/ronin/code/sql/emittable.rb +0 -100
- data/lib/ronin/code/sql/exceptions.rb +0 -24
- data/lib/ronin/code/sql/exceptions/unknown_clause.rb +0 -29
- data/lib/ronin/code/sql/exceptions/unknown_dialect.rb +0 -29
- data/lib/ronin/code/sql/exceptions/unknown_statement.rb +0 -29
- data/lib/ronin/code/sql/expr.rb +0 -102
- data/lib/ronin/code/sql/field.rb +0 -101
- data/lib/ronin/code/sql/fields_clause.rb +0 -46
- data/lib/ronin/code/sql/from_clause.rb +0 -42
- data/lib/ronin/code/sql/function.rb +0 -53
- data/lib/ronin/code/sql/group_by_clause.rb +0 -46
- data/lib/ronin/code/sql/having_clause.rb +0 -46
- data/lib/ronin/code/sql/in.rb +0 -47
- data/lib/ronin/code/sql/injected_statement.rb +0 -100
- data/lib/ronin/code/sql/injection.rb +0 -203
- data/lib/ronin/code/sql/insert.rb +0 -54
- data/lib/ronin/code/sql/intersect_clause.rb +0 -42
- data/lib/ronin/code/sql/join_clause.rb +0 -123
- data/lib/ronin/code/sql/like.rb +0 -73
- data/lib/ronin/code/sql/limit_clause.rb +0 -42
- data/lib/ronin/code/sql/modifier.rb +0 -48
- data/lib/ronin/code/sql/offset_clause.rb +0 -42
- data/lib/ronin/code/sql/on_clause.rb +0 -55
- data/lib/ronin/code/sql/order_by_clause.rb +0 -42
- data/lib/ronin/code/sql/program.rb +0 -225
- data/lib/ronin/code/sql/rename_to_clause.rb +0 -42
- data/lib/ronin/code/sql/replace.rb +0 -54
- data/lib/ronin/code/sql/select.rb +0 -103
- data/lib/ronin/code/sql/set_clause.rb +0 -42
- data/lib/ronin/code/sql/statement.rb +0 -180
- data/lib/ronin/code/sql/token.rb +0 -62
- data/lib/ronin/code/sql/unary_expr.rb +0 -47
- data/lib/ronin/code/sql/union_all_clause.rb +0 -42
- data/lib/ronin/code/sql/union_clause.rb +0 -42
- data/lib/ronin/code/sql/update.rb +0 -52
- data/lib/ronin/code/sql/values_clause.rb +0 -46
- data/lib/ronin/code/sql/where_clause.rb +0 -42
- data/lib/ronin/sql/error.rb +0 -26
- data/lib/ronin/sql/error/error.rb +0 -62
- data/lib/ronin/sql/error/extensions.rb +0 -22
- data/lib/ronin/sql/error/extensions/string.rb +0 -77
- data/lib/ronin/sql/error/message.rb +0 -62
- data/lib/ronin/sql/error/pattern.rb +0 -104
- data/lib/ronin/sql/error/patterns.rb +0 -99
- data/lib/ronin/sql/extensions.rb +0 -22
- data/lib/ronin/sql/extensions/uri.rb +0 -22
- data/lib/ronin/sql/extensions/uri/http.rb +0 -107
- data/spec/code/sql/common_dialect_spec.rb +0 -205
- data/spec/code/sql/create_examples.rb +0 -19
- data/spec/code/sql/create_index_spec.rb +0 -25
- data/spec/code/sql/create_table_spec.rb +0 -27
- data/spec/code/sql/create_view_spec.rb +0 -16
- data/spec/code/sql/delete_spec.rb +0 -14
- data/spec/code/sql/drop_examples.rb +0 -10
- data/spec/code/sql/drop_index_spec.rb +0 -16
- data/spec/code/sql/drop_table_spec.rb +0 -16
- data/spec/code/sql/drop_view_spec.rb +0 -16
- data/spec/code/sql/has_default_values_clause_examples.rb +0 -10
- data/spec/code/sql/has_fields_clause_examples.rb +0 -15
- data/spec/code/sql/has_from_clause_examples.rb +0 -13
- data/spec/code/sql/has_values_clause_examples.rb +0 -15
- data/spec/code/sql/has_where_clause_examples.rb +0 -15
- data/spec/code/sql/insert_spec.rb +0 -21
- data/spec/code/sql/replace_spec.rb +0 -21
- data/spec/code/sql/select_spec.rb +0 -105
- data/spec/code/sql/update_spec.rb +0 -26
- data/spec/helpers/code.rb +0 -14
- data/spec/sql/error_spec.rb +0 -24
- data/spec/sql/extensions/uri/http_spec.rb +0 -34
- data/spec/sql_spec.rb +0 -9
- data/tasks/spec.rb +0 -10
- data/tasks/yard.rb +0 -13
- metadata.gz.sig +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of Ronin SQL.
|
|
7
|
+
#
|
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with this program; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require 'ronin/sql/statement_list'
|
|
24
|
+
require 'ronin/sql/injection'
|
|
25
|
+
|
|
26
|
+
module Ronin
|
|
27
|
+
module SQL
|
|
28
|
+
|
|
29
|
+
#
|
|
30
|
+
# Creates a new SQL statement list.
|
|
31
|
+
#
|
|
32
|
+
# @yield [(statements)]
|
|
33
|
+
# If a block is given, it will be evaluated within the statement list.
|
|
34
|
+
# If the block accepts an argument, the block will be called with the
|
|
35
|
+
# new statement list.
|
|
36
|
+
#
|
|
37
|
+
# @yieldparam [StatementList] statements
|
|
38
|
+
# The new statement list.
|
|
39
|
+
#
|
|
40
|
+
# @return [StatementList]
|
|
41
|
+
# The new SQL statement list.
|
|
42
|
+
#
|
|
43
|
+
# @example
|
|
44
|
+
# sql { select(1,2,3,4,id).from(users) }
|
|
45
|
+
# # => #<Ronin::SQL::StatementList: SELECT (1,2,3,4,id) FROM users>
|
|
46
|
+
#
|
|
47
|
+
def sql(&block)
|
|
48
|
+
StatementList.new(&block)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# Creates a new SQL injection (SQLi)
|
|
53
|
+
#
|
|
54
|
+
# @param [Hash] options
|
|
55
|
+
# Additional injection options.
|
|
56
|
+
#
|
|
57
|
+
# @option options [:integer, :decimal, :string, :column] :escape
|
|
58
|
+
# The type of element to escape out of.
|
|
59
|
+
#
|
|
60
|
+
# @option options [Boolean] :terminate
|
|
61
|
+
# Specifies whether to terminate the SQLi with a comment.
|
|
62
|
+
#
|
|
63
|
+
# @option options [String, Symbol, Integer] :place_holder
|
|
64
|
+
# Place-holder data.
|
|
65
|
+
#
|
|
66
|
+
# @yield [(injection)]
|
|
67
|
+
# If a block is given, it will be evaluated within the injection.
|
|
68
|
+
# If the block accepts an argument, the block will be called with the
|
|
69
|
+
# new injection.
|
|
70
|
+
#
|
|
71
|
+
# @yieldparam [Injection] injection
|
|
72
|
+
# The new injection.
|
|
73
|
+
#
|
|
74
|
+
# @return [Injection]
|
|
75
|
+
# The new SQL injection.
|
|
76
|
+
#
|
|
77
|
+
# @example
|
|
78
|
+
# sqli { self.and { 1 == 1 }.select(1,2,3,4,id).from(users) }
|
|
79
|
+
# # => #<Ronin::SQL::Injection: 1 AND 1=1; SELECT (1,2,3,4,id) FROM users; SELECT (1,2,3,4,id) FROM users>
|
|
80
|
+
#
|
|
81
|
+
def sqli(options={},&block)
|
|
82
|
+
Injection.new(options,&block)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of Ronin SQL.
|
|
7
|
+
#
|
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with this program; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require 'ronin/sql/literals'
|
|
24
|
+
require 'ronin/sql/clause'
|
|
25
|
+
require 'ronin/sql/clauses'
|
|
26
|
+
require 'ronin/sql/operators'
|
|
27
|
+
require 'ronin/sql/emittable'
|
|
28
|
+
|
|
29
|
+
module Ronin
|
|
30
|
+
module SQL
|
|
31
|
+
#
|
|
32
|
+
# Represents a SQL Statement.
|
|
33
|
+
#
|
|
34
|
+
class Statement < Struct.new(:keyword,:argument)
|
|
35
|
+
|
|
36
|
+
include Literals
|
|
37
|
+
include Operators
|
|
38
|
+
include Clauses
|
|
39
|
+
include Emittable
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Initializes a new SQL statement.
|
|
43
|
+
#
|
|
44
|
+
# @param [Symbol, Array<Symbol>] keyword
|
|
45
|
+
# Name of the statement.
|
|
46
|
+
#
|
|
47
|
+
# @param [Object] argument
|
|
48
|
+
# Additional argument for the statement.
|
|
49
|
+
#
|
|
50
|
+
# @yield [(statement)]
|
|
51
|
+
# If a block is given, it will be called.
|
|
52
|
+
#
|
|
53
|
+
# @yieldparam [Statement] statement
|
|
54
|
+
# If the block accepts an argument, it will be passed the new statement.
|
|
55
|
+
# Otherwise the block will be evaluated within the statement.
|
|
56
|
+
#
|
|
57
|
+
def initialize(keyword,argument=nil,&block)
|
|
58
|
+
super(keyword,argument)
|
|
59
|
+
|
|
60
|
+
if block
|
|
61
|
+
case block.arity
|
|
62
|
+
when 0 then instance_eval(&block)
|
|
63
|
+
else block.call(self)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of Ronin SQL.
|
|
7
|
+
#
|
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with this program; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require 'ronin/sql/field'
|
|
24
|
+
require 'ronin/sql/fields'
|
|
25
|
+
require 'ronin/sql/unary_expr'
|
|
26
|
+
require 'ronin/sql/binary_expr'
|
|
27
|
+
require 'ronin/sql/functions'
|
|
28
|
+
require 'ronin/sql/statement'
|
|
29
|
+
require 'ronin/sql/statements'
|
|
30
|
+
require 'ronin/sql/emittable'
|
|
31
|
+
|
|
32
|
+
module Ronin
|
|
33
|
+
module SQL
|
|
34
|
+
#
|
|
35
|
+
# Represents a list of SQL {Statements Statement}.
|
|
36
|
+
#
|
|
37
|
+
class StatementList
|
|
38
|
+
|
|
39
|
+
include Fields
|
|
40
|
+
include Functions
|
|
41
|
+
include Statements
|
|
42
|
+
include Emittable
|
|
43
|
+
|
|
44
|
+
# The list of statements
|
|
45
|
+
attr_reader :statements
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Initializes a new SQL statement list.
|
|
49
|
+
#
|
|
50
|
+
# @yield [(statements)]
|
|
51
|
+
# If a block is given, it will be evaluated within the statement list.
|
|
52
|
+
# If the block accepts an argument, the block will be called with the
|
|
53
|
+
# new statement list.
|
|
54
|
+
#
|
|
55
|
+
# @yieldparam [StatementList] statements
|
|
56
|
+
# The new statement list.
|
|
57
|
+
#
|
|
58
|
+
def initialize(&block)
|
|
59
|
+
@statements = []
|
|
60
|
+
|
|
61
|
+
if block
|
|
62
|
+
case block.arity
|
|
63
|
+
when 0 then instance_eval(&block)
|
|
64
|
+
else block.call(self)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
#
|
|
70
|
+
# Appends a statement.
|
|
71
|
+
#
|
|
72
|
+
# @param [Statement] statement
|
|
73
|
+
# The SQL statement.
|
|
74
|
+
#
|
|
75
|
+
# @return [self]
|
|
76
|
+
#
|
|
77
|
+
def <<(statement)
|
|
78
|
+
@statements << statement
|
|
79
|
+
return self
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
#
|
|
83
|
+
# Appends an arbitrary statement.
|
|
84
|
+
#
|
|
85
|
+
# @param [Symbol] keyword
|
|
86
|
+
# Name of the statement.
|
|
87
|
+
#
|
|
88
|
+
# @param [Object] argument
|
|
89
|
+
# Additional argument for the statement.
|
|
90
|
+
#
|
|
91
|
+
# @yield [(statement)]
|
|
92
|
+
# If a block is given, it will be called.
|
|
93
|
+
#
|
|
94
|
+
# @yieldparam [Statement] statement
|
|
95
|
+
# If the block accepts an argument, it will be passed the new statement.
|
|
96
|
+
# Otherwise the block will be evaluated within the statement.
|
|
97
|
+
#
|
|
98
|
+
# @return [Statement]
|
|
99
|
+
# The newly created statement.
|
|
100
|
+
#
|
|
101
|
+
def statement(keyword,argument=nil,&block)
|
|
102
|
+
new_statement = super
|
|
103
|
+
|
|
104
|
+
self << new_statement
|
|
105
|
+
return new_statement
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of Ronin SQL.
|
|
7
|
+
#
|
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with this program; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
module Ronin
|
|
24
|
+
module SQL
|
|
25
|
+
#
|
|
26
|
+
# Methods for creating common SQL {Statement Statements}.
|
|
27
|
+
#
|
|
28
|
+
module Statements
|
|
29
|
+
#
|
|
30
|
+
# Creates an arbitrary statement.
|
|
31
|
+
#
|
|
32
|
+
# @param [Symbol] keyword
|
|
33
|
+
# Name of the statement.
|
|
34
|
+
#
|
|
35
|
+
# @param [Object] argument
|
|
36
|
+
# Additional argument for the statement.
|
|
37
|
+
#
|
|
38
|
+
# @yield [(statement)]
|
|
39
|
+
# If a block is given, it will be called.
|
|
40
|
+
#
|
|
41
|
+
# @yieldparam [Statement] statement
|
|
42
|
+
# If the block accepts an argument, it will be passed the new statement.
|
|
43
|
+
# Otherwise the block will be evaluated within the statement.
|
|
44
|
+
#
|
|
45
|
+
# @return [Statement]
|
|
46
|
+
# The new statement.
|
|
47
|
+
#
|
|
48
|
+
def statement(keyword,argument=nil,&block)
|
|
49
|
+
Statement.new(keyword,argument,&block)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
#
|
|
53
|
+
# Creates a new `SELECT` statement.
|
|
54
|
+
#
|
|
55
|
+
# @param [Array<Field, Symbol>] columns
|
|
56
|
+
# The columns to select.
|
|
57
|
+
#
|
|
58
|
+
# @return [Statement]
|
|
59
|
+
# The new statement.
|
|
60
|
+
#
|
|
61
|
+
def select(*columns,&block)
|
|
62
|
+
statement(:SELECT,columns,&block)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
#
|
|
66
|
+
# Creates a new `INSERT` statement.
|
|
67
|
+
#
|
|
68
|
+
# @return [Statement]
|
|
69
|
+
# The new statement.
|
|
70
|
+
#
|
|
71
|
+
def insert(&block)
|
|
72
|
+
statement(:INSERT,&block)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#
|
|
76
|
+
# Creates a new `UPDATE` statement.
|
|
77
|
+
#
|
|
78
|
+
# @param [Field, Symbol] table
|
|
79
|
+
# The table to update.
|
|
80
|
+
#
|
|
81
|
+
# @return [Statement]
|
|
82
|
+
# The new statement.
|
|
83
|
+
#
|
|
84
|
+
def update(table,&block)
|
|
85
|
+
statement(:UPDATE,table,&block)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
#
|
|
89
|
+
# Creates a new `DELETE` statement.
|
|
90
|
+
#
|
|
91
|
+
# @param [Field, Symbol] table
|
|
92
|
+
# The table to delete from.
|
|
93
|
+
#
|
|
94
|
+
# @return [Statement]
|
|
95
|
+
# The new statement.
|
|
96
|
+
#
|
|
97
|
+
def delete(table,&block)
|
|
98
|
+
statement([:DELETE, :FROM],table,&block)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
#
|
|
102
|
+
# Creates a new `DROP TABLE` statement.
|
|
103
|
+
#
|
|
104
|
+
# @param [Field, Symbol] table
|
|
105
|
+
# The table to drop.
|
|
106
|
+
#
|
|
107
|
+
# @return [Statement]
|
|
108
|
+
# The new statement.
|
|
109
|
+
#
|
|
110
|
+
def drop_table(table,&block)
|
|
111
|
+
statement([:DROP, :TABLE],table,&block)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Ronin SQL - A
|
|
3
|
-
# tasks.
|
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
|
4
3
|
#
|
|
5
|
-
# Copyright (c) 2007-
|
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of Ronin SQL.
|
|
6
7
|
#
|
|
7
8
|
# This program is free software; you can redistribute it and/or modify
|
|
8
9
|
# it under the terms of the GNU General Public License as published by
|
|
@@ -19,18 +20,17 @@
|
|
|
19
20
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
21
|
#
|
|
21
22
|
|
|
22
|
-
require 'ronin/
|
|
23
|
+
require 'ronin/sql/emittable'
|
|
23
24
|
|
|
24
25
|
module Ronin
|
|
25
|
-
module
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
module SQL
|
|
27
|
+
#
|
|
28
|
+
# Represents a unary-expression in SQL.
|
|
29
|
+
#
|
|
30
|
+
class UnaryExpr < Struct.new(:operator,:operand)
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
super(expr,'DESC')
|
|
31
|
-
end
|
|
32
|
+
include Emittable
|
|
32
33
|
|
|
33
|
-
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|
data/lib/ronin/sql/version.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Ronin SQL - A
|
|
3
|
-
# tasks.
|
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
|
4
3
|
#
|
|
5
|
-
# Copyright (c) 2007-
|
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of Ronin SQL.
|
|
6
7
|
#
|
|
7
8
|
# This program is free software; you can redistribute it and/or modify
|
|
8
9
|
# it under the terms of the GNU General Public License as published by
|
|
@@ -22,6 +23,6 @@
|
|
|
22
23
|
module Ronin
|
|
23
24
|
module SQL
|
|
24
25
|
# Ronin SQL version
|
|
25
|
-
VERSION = '0.
|
|
26
|
+
VERSION = '1.0.0'
|
|
26
27
|
end
|
|
27
28
|
end
|
data/ronin-sql.gemspec
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |gem|
|
|
6
|
+
gemspec = YAML.load_file('gemspec.yml')
|
|
7
|
+
|
|
8
|
+
gem.name = gemspec.fetch('name')
|
|
9
|
+
gem.version = gemspec.fetch('version') do
|
|
10
|
+
lib_dir = File.join(File.dirname(__FILE__),'lib')
|
|
11
|
+
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
|
12
|
+
|
|
13
|
+
require 'ronin/sql/version'
|
|
14
|
+
Ronin::SQL::VERSION
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
gem.summary = gemspec['summary']
|
|
18
|
+
gem.description = gemspec['description']
|
|
19
|
+
gem.licenses = Array(gemspec['license'])
|
|
20
|
+
gem.authors = Array(gemspec['authors'])
|
|
21
|
+
gem.email = gemspec['email']
|
|
22
|
+
gem.homepage = gemspec['homepage']
|
|
23
|
+
|
|
24
|
+
glob = lambda { |patterns| gem.files & Dir[*patterns] }
|
|
25
|
+
|
|
26
|
+
gem.files = `git ls-files`.split($/)
|
|
27
|
+
gem.files = glob[gemspec['files']] if gemspec['files']
|
|
28
|
+
gem.files += Array(gemspec['generated_files'])
|
|
29
|
+
|
|
30
|
+
gem.executables = gemspec.fetch('executables') do
|
|
31
|
+
glob['bin/*'].map { |path| File.basename(path) }
|
|
32
|
+
end
|
|
33
|
+
gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
|
|
34
|
+
|
|
35
|
+
gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
|
|
36
|
+
gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
|
|
37
|
+
gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
|
|
38
|
+
|
|
39
|
+
gem.require_paths = Array(gemspec.fetch('require_paths') {
|
|
40
|
+
%w[ext lib].select { |dir| File.directory?(dir) }
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
gem.requirements = gemspec['requirements']
|
|
44
|
+
gem.required_ruby_version = gemspec['required_ruby_version']
|
|
45
|
+
gem.required_rubygems_version = gemspec['required_rubygems_version']
|
|
46
|
+
gem.post_install_message = gemspec['post_install_message']
|
|
47
|
+
|
|
48
|
+
split = lambda { |string| string.split(/,\s*/) }
|
|
49
|
+
|
|
50
|
+
if gemspec['dependencies']
|
|
51
|
+
gemspec['dependencies'].each do |name,versions|
|
|
52
|
+
gem.add_dependency(name,split[versions])
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if gemspec['development_dependencies']
|
|
57
|
+
gemspec['development_dependencies'].each do |name,versions|
|
|
58
|
+
gem.add_development_dependency(name,split[versions])
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|