├── composer.json
├── logout.php
├── trigger_fake_admin.php
├── mysql.php
├── dbdata.sql
├── trigger_fake_admin_2.php
├── app.json
├── authenticate.php
├── composer.lock
├── README.md
├── setup_mysql.php
├── fake_admin_browser.js
├── register.php
├── login.php
└── index.php
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "ext-mysql": "*",
4 | "ext-mbstring":"*"
5 | }
6 | }
--------------------------------------------------------------------------------
/logout.php:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/mysql.php:
--------------------------------------------------------------------------------
1 |
";
7 | print "We caught an admin! Our XSS caught this information via alert():";
8 | print "
";
9 | print nl2br($results);
10 | print "
";
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "CTF_FLAG": "PUT-FLAG-HERE"
4 | },
5 | "addons": [
6 | "papertrail",
7 | "cleardb"
8 | ],
9 | "success_url": "/index.php",
10 | "scripts": {
11 | "postdeploy": "php setup_mysql.php"
12 | },
13 | "buildpacks": [
14 | {
15 | "url": "https://github.com/heroku/heroku-buildpack-php"
16 | },
17 | {
18 | "url": "https://github.com/stomita/heroku-buildpack-phantomjs"
19 | }
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/authenticate.php:
--------------------------------------------------------------------------------
1 | > Back");
11 | }
12 | else
13 | {
14 | $mem = mysql_fetch_assoc($uq);
15 | $_SESSION['id'] = $mem['id'];
16 | setcookie("hint", 'use-these-cookies-to-login-as-admin', time()+36000);
17 | header("Location: /index.php");
18 | exit;
19 | }
20 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 | "This file is @generated automatically"
6 | ],
7 | "hash": "4032f9a7678ad10ae1a13e7369f85d34",
8 | "content-hash": "a243a4e7654fee2a753e9fd9e0f4aec1",
9 | "packages": [],
10 | "packages-dev": [],
11 | "aliases": [],
12 | "minimum-stability": "stable",
13 | "stability-flags": [],
14 | "prefer-stable": false,
15 | "prefer-lowest": false,
16 | "platform": {
17 | "ext-mysql": "*",
18 | "ext-mbstring": "*"
19 | },
20 | "platform-dev": []
21 | }
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # XSS Cookie Stealing Challenge
2 |
3 | Challenge: See if you can become logged in as the "admin" user.
4 |
5 | Note that to do so, you'll need to create your own account and create an XSS attack on your user profile.
6 |
7 | 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)
8 |
9 | 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).
10 |
11 | [](https://heroku.com/deploy)
12 |
13 | 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.
14 |
--------------------------------------------------------------------------------
/setup_mysql.php:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 | breakthenet
11 |
12 |
13 |
14 |
15 | if ($_POST['username'])
16 | {
17 | $username = mysql_real_escape_string($_POST['username']);
18 | $q = mysql_query("SELECT * FROM users WHERE username='$username'");
19 | if (mysql_num_rows($q))
20 | {
21 | print "Username already in use. Choose another.";
22 | }
23 | else
24 | {
25 | mysql_query("INSERT INTO users (username, password) VALUES( '{$username}', md5('{$_POST['password']}'))");
26 | print "You have signed up, enjoy the game.
> Login";
27 | }
28 | }
29 | else
30 | {
31 | ?>
32 |
33 | Register
34 |
35 |
41 | > Go Back
42 |
43 | }
44 | ?>
45 |
46 |
47 |
--------------------------------------------------------------------------------
/login.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BreakTheNet
6 |
7 |
8 |
9 | > BreakTheNet Log-In
10 |
11 |
12 |
13 | |
14 |
21 | |
22 |
23 |
31 | |
32 |
33 |
34 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 |
25 |
31 |
32 | |
33 |
59 |
60 | |
61 |
62 |
70 |
71 |
72 |
77 |
78 |
79 |
80 | > LOGOUT
81 | |
82 |
83 |
--------------------------------------------------------------------------------