PHP code
<?php
ob_start();
session_start();
include "sql_and_php_debug.php";
mysql_connect("localhost", "login1", "login1");
mysql_select_db("login1");
?>
<h1>Please login (e.g. under 'admin' : 'admin')</h1>
Flag is in `flag`.flag, and it's not 32 hexes this time - it's a phrase<br/>
(here SQL query can return two results: login OK and login NOT ok. Btw you can use SQLmap)<br/><br/>
<?php
if (isset($_SESSION['loggedIn'])) {
if (isset($_GET['logout'])) {
unset($_SESSION['loggedIn']);
ob_end_clean();
header("Location: ?", true, 302);
exit;
}
echo "Welcome, user! The page is under construction<p/><a href='?logout'>Log out »</a>";
} else {
if (isset($_POST['login'])) {
$login = $_POST['login'];
$password = $_POST['password'];
$res = mysql_query("SELECT * FROM users WHERE login = '$login' AND password = '$password'");
if (mysql_num_rows($res) > 0) {
$_SESSION['loggedIn'] = true;
ob_end_clean();
header("Location: ?", true, 302);
exit;
} else {
echo "Bad username or password! Hope this does not give you information you need ;)";
}
}
?>
<form method="POST">Login: <input type="text" name="login" /><br/>
Password: <input type="password" name="password" /><br/>
<input type="submit" value="Login »" /></form>
<?php
}
SQL debug
Please login (e.g. under 'admin' : 'admin')
Flag is in `flag`.flag, and it's not 32 hexes this time - it's a phrase
(here SQL query can return two results: login OK and login NOT ok. Btw you can use SQLmap)