-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.php
122 lines (106 loc) · 2.94 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
function mysql_fquery($mysqli, $query, $params) {
return mysqli_query($mysqli, vsprintf($query, $params));
}
if (isset($_POST['username']) && isset($_POST['password'])) {
$mysqli = mysqli_connect(getenv('DB_HOST'), 'challuser', 'challpass', 'challenge');
$username = strtr($_POST['username'], ['"' => '\\"', '\\' => '\\\\']);
$password = sha1($_POST['password']);
$res = mysql_fquery($mysqli, 'SELECT * FROM users WHERE username = "%s"', [$username]);
if (!mysqli_fetch_assoc($res)) {
$message = "Username not found.";
goto fail;
}
$res = mysql_fquery($mysqli, 'SELECT * FROM users WHERE username = "'.$username.'" AND password = "%s"', [$password]);
if (!mysqli_fetch_assoc($res)) {
$message = "Invalid password.";
goto fail;
}
$htmlsafe_username = htmlspecialchars($username, ENT_COMPAT | ENT_SUBSTITUTE);
$greeting = $username === "admin"
? "Hello $htmlsafe_username, the server time is %s and the flag is %s"
: "Hello $htmlsafe_username, the server time is %s";
$message = vsprintf($greeting, [date('Y-m-d H:i:s'), getenv('FLAG')]);
fail:
}
?>
<!DOCTYPE html>
<html>
<head>
<title>🎷 Smooth Jazz</title>
<style>
body {
background-color: #f8f8f8;
font-family: Arial, sans-serif;
}
.container {
max-width: 400px;
margin: 100px auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
color: #333;
}
form {
margin-top: 20px;
}
label, input {
display: block;
margin-bottom: 10px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4287f5;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.music-player {
margin-top: 20px;
}
h2 {
color: #333;
}
audio {
width: 100%;
margin-top: 10px;
}
.message {
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>Smooth Jazz</h1>
<form method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Enter your username">
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter your password">
<input type="submit" value="Login">
</form>
<div class="music-player">
<audio src="/offering-larry-stephens.mp3" id="audio"></audio>
If you are stuck, you can <a href="javascript:document.getElementById('audio').play()">listen to some smooth jazz</a>.
</div>
<div id="message" class="message">
<p><?= $message ?? '' ?></p>
</div>
</div>
</body>
</html>