Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once 'config.php'; ?>
- <!doctype html>
- <html lang="en">
- <head>
- <title>Little Bobby Tables</title>
- <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"
- integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
- <meta charset="utf8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <div class="container" style="max-width: 600px; margin-top: 2em;">
- <?php
- $user = $_REQUEST['user'];
- $pwd = $_REQUEST['pwd'];
- $token = $_COOKIE["token_web1"];
- if (empty($token) || !check_token($token)){
- ?>
- <div class="alert alert-warning"><b>Warning </b>You need to be logged in to the dashboard! If the error persists, try to reactivate the challenge.</div>
- <?php
- }
- $login_ok = FALSE;
- if (!empty($user) && !empty($pwd)) {
- $decoded_user = base64_decode($user);
- // We store the password in plaintext to keep the homework's code short.
- // For anything even remotely real, use a proper password storage scheme.
- $decoded_pwd = base64_decode($pwd);
- if($decoded_user === FALSE || $decoded_pwd === FALSE) {
- echo '<div class="alert alert-danger">Please insert your credentials!</div>';
- } else {
- $query = "SELECT user_id FROM users WHERE username='$decoded_user' and password='$decoded_pwd'";
- $result = mysqli_query($vuln_db, $query);
- if ($result && (mysqli_num_rows($result)>0) && verify_user($token, $decoded_user)) {
- $login_ok = TRUE;
- echo "<h1>Hi " . htmlentities($decoded_user) . ", you are logged in!</h1>";
- echo "<img style='width: 100%' src='exploits_of_a_mom.png'";
- }
- else {
- echo '<div class="alert alert-danger">Wrong username or password</div>';
- }
- }
- }
- if(!$login_ok) {
- ?>
- <h1 style="text-align: center;">Access Restricted</h1>
- <form method="post" id="login_form" class="form-horizontal" style="max-width: 75%; margin: 0 auto;">
- <div class="form-group">
- <label for="name">Name: </label>
- <input type="text" name="user" class="form-control">
- </div>
- <div class="form-group">
- <label for="name">Password: </label>
- <input type="password" name="pwd" class="form-control">
- </div>
- <input type="submit" value="Login" class="btn btn-primary" style="display: block; margin: 0 auto; min-width: 50%">
- </form>
- <script type="text/javascript" src="formutils.js"></script>
- <?php
- }
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement