diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/btn_xss_challenge.pp b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/btn_xss_challenge.pp new file mode 100644 index 000000000..620986a04 --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/btn_xss_challenge.pp @@ -0,0 +1 @@ +require btn_xss_challenge \ No newline at end of file diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/README.md b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/README.md new file mode 100755 index 000000000..540efe0ac --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/README.md @@ -0,0 +1,13 @@ +# XSS Cookie Stealing Challenge + +Challenge: See if you can become logged in as the "admin" user. + +Note that to do so, you'll need to create your own account and create an XSS attack on your user profile. + +For purposes of this challenge, anything you successfully "alert()" in the admin's browser will be passed along to you. (Admin browser is simulated using phantomjs) + +Deploy to your own Heroku instance with this button below, or try out our live demo [HERE](https://ctf-xss-challenge.herokuapp.com/) (not guaranteed to be up). + +[](https://heroku.com/deploy) + +Note that useful information for testing and debugging will be logged to the Papertrail app in your heroku instance. Open papertrail to view those streaming logs. diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/app.json b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/app.json new file mode 100755 index 000000000..ed3f15b6c --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/app.json @@ -0,0 +1,21 @@ +{ + "env": { + "CTF_FLAG": "PUT-FLAG-HERE" + }, + "addons": [ + "papertrail", + "cleardb" + ], + "success_url": "/index.php", + "scripts": { + "postdeploy": "php setup_mysql.php" + }, + "buildpacks": [ + { + "url": "https://github.com/heroku/heroku-buildpack-php" + }, + { + "url": "https://github.com/stomita/heroku-buildpack-phantomjs" + } + ] +} diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/authenticate.php b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/authenticate.php new file mode 100755 index 000000000..74e5f8a21 --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/authenticate.php @@ -0,0 +1,19 @@ +> Back"); +} +else +{ + $mem = mysql_fetch_assoc($uq); + $_SESSION['id'] = $mem['id']; + setcookie("hint", 'use-these-cookies-to-login-as-admin', time()+36000); + header("Location: /index.php"); + exit; +} diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/composer.json b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/composer.json new file mode 100755 index 000000000..e09c14372 --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/composer.json @@ -0,0 +1,6 @@ +{ + "require": { + "ext-mysql": "*", + "ext-mbstring":"*" + } +} \ No newline at end of file diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/composer.lock b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/composer.lock new file mode 100755 index 000000000..19e8d772f --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/composer.lock @@ -0,0 +1,21 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "4032f9a7678ad10ae1a13e7369f85d34", + "content-hash": "a243a4e7654fee2a753e9fd9e0f4aec1", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "ext-mysql": "*", + "ext-mbstring": "*" + }, + "platform-dev": [] +} diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/dbdata.sql b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/dbdata.sql new file mode 100755 index 000000000..bc8e43a6c --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/dbdata.sql @@ -0,0 +1,8 @@ +DROP TABLE IF EXISTS `users`; +CREATE TABLE `users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(20) NOT NULL DEFAULT '', + `password` varchar(255) NOT NULL DEFAULT '', + `profile_desc` longtext NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/fake_admin_browser.js b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/fake_admin_browser.js new file mode 100644 index 000000000..db87452bd --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/fake_admin_browser.js @@ -0,0 +1,41 @@ +// Locally: phantomjs fake_admin_browser.js --url test.com +// Heroku: /app/vendor/phantomjs/bin/phantomjs fake_admin_browser.js --url test.com + +var system = require('system'); +var base_url = "http://localhost:8888/"; +var password = ""; +var profileid = 0; + +if (system.args.length === 1) { + console.log('Try to pass some args when invoking this script!'); +} else { + system.args.forEach(function (arg, i) { + if (i == 2) { + base_url = arg; + } + if (i == 4) { + password = arg; + } + if (i == 6) { + profileid = arg; + } + }); +} + +function open_target_profile(profileid) { + var userprofilepage = require('webpage').create(); + userprofilepage.onAlert = function(alertmsg) { + console.log(alertmsg); + } + userprofilepage.open(base_url+"index.php?id="+profileid, function (status) { + setTimeout(function(){ + phantom.exit(0); + }, 3000); + }); +} + +var loginpage = require('webpage').create(); +loginpage.open(base_url+'authenticate.php', 'post', 'username=admin&password='+password+'&save=OFF', function (status) { + + open_target_profile(profileid); +}); diff --git a/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/index.php b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/index.php new file mode 100755 index 000000000..faaea2dea --- /dev/null +++ b/modules/vulnerabilities/unix/webapp/btn_xss_challenge/files/index.php @@ -0,0 +1,82 @@ + + +
| + + + |
+
+
+
+ + + + + + > LOGOUT + |
| + + | ++ + | +