forked from OWASP/Vulnerable-Web-Application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
252 lines (221 loc) · 8.43 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html>
<html>
<head>
<title>SETUP</title>
<link rel="shortcut icon" href="Resources/hmbct.png" />
</head>
<body>
<link rel="stylesheet" href="Resources/button.css">
<div class="button" align="center" style="background-color:#757575;padding:10px;border-radius:80px 80px 0px 0px">
<button type="button" name="homepagebutton" onclick="location.href='homepage.html'">Home Page</button>
</div>
</link>
<div align="center" style="background-color:#c9c9c9;padding:150px;">
<form method="POST">
<label style="font-size:24px;font-family:'Georgia'">Create Database: </label>
<input type="submit" name="submit" value="Enter" style="padding:8px;font-family:'Georgia'"></form>
<form method="POST">
<label style="font-size:24px;font-family:'Georgia'">Restore Database:</label>
<input type="submit" name="submit1" value="Enter" style="padding:8px;font-family:'Georgia'"></form>
</div>
<div align="center" style="background-color:#afafaf;padding:60px;border-radius:0px 0px 80px 80px">
<?php
if (isset($_POST["submit"])) {
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysqli_error( $conn));
}
else
echo 'Connected successfully </br>';
create_database($conn);
create_tables($conn, "1ccb8097d0e9ce9f154608be60224c7c");
mysqli_close($conn);
}
if (isset($_POST["submit1"])) {
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if ($conn) {
echo "Connected successfully <br>";
}
else {
die('Could not connect: ' . mysqli_error( $conn));
}
remove_database($conn);
create_database($conn);
create_tables($conn, "1ccb8097d0e9ce9f154608be60224c7c");
mysqli_close($conn);
}
function create_database($conn){
$sql = 'CREATE Database 1ccb8097d0e9ce9f154608be60224c7c';
$retval = mysqli_query( $conn, $sql);
if(! $retval ) {
die('Could not create database: ' . mysqli_error( $conn));
}
echo "Database 1ccb8097d0e9ce9f154608be60224c7c created successfully </br>";
}
function create_tables($conn, $db_name){
$sql = 'CREATE TABLE books( '.
'number INT NOT NULL , '.
'bookname VARCHAR(50) NOT NULL, '.
'authorname VARCHAR(50) NOT NULL)';
mysqli_select_db($conn,$db_name);
$retval = mysqli_query( $conn , $sql);
if(! $retval ) {
die('Could not create table: ' . mysqli_error( $conn));
}
#-------------------------------------------------
echo "Table books created successfully </br>";
$sql = 'CREATE TABLE flags( '.
'flag VARCHAR(50) NOT NULL)';
mysqli_select_db($conn, $db_name);
$retval = mysqli_query( $conn , $sql );
if(! $retval ) {
die('Could not create table: ' . mysqli_error( $conn));
}
echo "Table flags created successfully </br>";
#---------------------------------------------------
$sql = 'CREATE TABLE secret( '.
'username VARCHAR(56) NOT NULL , '.
'password VARCHAR(56) NOT NULL)';
mysqli_select_db($conn,$db_name);
$retval = mysqli_query( $conn, $sql );
if(! $retval ) {
die('Could not create table: ' . mysqli_error( $conn));
}
echo "Table secret created successfully </br>";
#---------------------------------------------------
$sql = 'CREATE TABLE users( '.
'firstname VARCHAR(50) NOT NULL , '.
'lastname VARCHAR(50) NOT NULL, '.
'username VARCHAR(50) NOT NULL, '.
'password VARCHAR(50) NOT NULL )';
mysqli_select_db($conn, $db_name);
$retval = mysqli_query( $conn , $sql);
if(! $retval ) {
die('Could not create table: ' . mysqli_error( $conn));
}
echo "Table users created successfully </br>";
#---------------------------------------------------
$sql = 'INSERT INTO books (number, bookname, authorname) VALUES (1, "SILMARILLION", "J.R.R TOLKIEN")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO books (number, bookname, authorname) VALUES (2, "DUNE", "FRANK HERBERT")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO books (number, bookname, authorname) VALUES (3, "THE HUNGER GAMES", "SUZANNE COLLINS")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO books (number, bookname, authorname) VALUES (4, "HARRY POTTER \AND THE ORDER OF THE PHONEIX", "J.K ROWLING")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO books (number, bookname, authorname) VALUES (5, "TO KILL A MOCKINGBIRD", "HARPER LEE")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO books (number, bookname, authorname) VALUES (6, "TWILIGHT", "STEPHEINE MEYER")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO books (number, bookname, authorname) VALUES (7, "THE MICE MAN", "GEORGE COCKCROFT")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
#--------------------------------------------------------------------------------------------
$sql = 'INSERT INTO flags (flag) VALUES ("You hacked me!")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO flags (flag) VALUES ("SQL Injection is easy?")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
#----------------------------------------------------------------------------------------------
$sql = 'INSERT INTO secret (username, password) VALUES ("admin", "password")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
#--------------------------------------------------------------------------------------------------
$sql = 'INSERT INTO users (firstname, lastname, username, password) VALUES ("John","Doe", "Admin", "password")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO users (firstname, lastname, username, password) VALUES ("Alice","Carrol", "Rabbit", "White")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO users (firstname, lastname, username, password) VALUES ("Bruce","Batman", "Alfred", "Batmobile")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = 'INSERT INTO users (firstname, lastname, username, password) VALUES ("Dare","Devil", "HackMe", "IfY0UC4N")';
if (mysqli_query($conn, $sql)) {
echo "New record created successfully </br>";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
function remove_database($conn){
$sql = 'DROP DATABASE 1ccb8097d0e9ce9f154608be60224c7c';
$retval = mysqli_query($conn, $sql);
if($retval){
echo "<br>The database deleted successfully.<br>";
}
else{
echo "Error: ".$sql."<br>". mysqli_error($conn);
}
}
?>
</div>
<img src="Resources/hmb.png" align="left" style="width:40%" alt="HummingbirdsCyberTeam">
<img src="Resources/gazicyber.jpg" align="right" style="width:15%" alt="GaziCyber">
</body>
</html>