Last active
October 18, 2016 20:24
-
-
Save kckrinke/d9953eac0042d408286100cc272294c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
iframe-test.php - Test for iframe-based site vulnerabilities. | |
author: Kevin C. Krinke <kevin@krinke.ca> | |
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. | |
In jurisdictions that recognize copyright laws, the author or authors | |
of this software dedicate any and all copyright interest in the | |
software to the public domain. We make this dedication for the benefit | |
of the public at large and to the detriment of our heirs and | |
successors. We intend this dedication to be an overt act of | |
relinquishment in perpetuity of all present and future rights to this | |
software under copyright law. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
OTHER DEALINGS IN THE SOFTWARE. | |
For more information, please refer to <http://unlicense.org/> | |
*/ | |
$page_title = basename(__FILE__,".php"); | |
echo '<html>'; | |
echo '<head>'; | |
echo '<title>'.$page_title.'</title>'; | |
echo '<style>iframe {border:1px dotted red;width:100%;height:300px;} em {color:red} label {font-weight:bold;}</style>'; | |
echo '<style id="antiClickjack">body{display:none !important;}</style>'; | |
echo '<script type="text/javascript">if (self === top) { var antiClickjack = document.getElementById("antiClickjack"); antiClickjack.parentNode.removeChild(antiClickjack); } else { top.location = self.location; }</script>'; | |
echo '</head>'; | |
echo '<body>'; | |
echo '<h1>'.$page_title.'</h1>'; | |
echo '<hr/>'; | |
echo '<p>Try to load a site using the form below. The URL entered will be placed as the <em>src</em> attribute of an <em>iframe</em> tag so that you can test for iframe-based attack vectors. See the OWASP “Clickjacking Defense Cheat Sheet” for more info: <u>https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet</u></p>'; | |
echo '<form method="POST">'; | |
echo '<label for="target">Target URL: </label>'; | |
echo '<input type="text" name="target" placeholder="http://..." />'; | |
echo '<button type="submit">Submit</button>'; | |
echo '</form>'; | |
if (!empty($_POST)) { | |
echo '<hr/>'; | |
echo '<p><em>If you can read this; the target site did not break out of the iframe. If you can interact or otherwise use the website within the iframe below; the website is vulerable to clickjacking. If you are still reading this, and the iframe below is blank; the site is most likely using just the <em>X-Frame-Options</em> header defense (which only works with “modern” browsers).</em></p>'; | |
echo '<p>Target URL: '.$_POST['target'].'</p>'; | |
echo '<iframe src="'.$_POST['target'].'" />'; | |
} | |
echo '<hr/>'; | |
echo '<p>Sources can be found <a href="https://gist.github.com/kckrinke/d9953eac0042d408286100cc272294c7">here</a>.</p>'; | |
echo '</body>'; | |
echo '</html>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment