-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
162 lines (131 loc) · 3.93 KB
/
install.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
<html>
<title>
VSDb Client
</title>
<body><center><tt>
<BR><BR>
<img src="head.png">
<BR><BR><BR>
<?php
$user = $_POST["user"];
$pass = $_POST["pass"];
$db = $_POST["db"];
$key = $_POST["key"];
$key2 = $_POST["key2"];
if (empty($user) && empty($pass) && empty($db) && empty($key) && empty($key2)) {
show_form();
} elseif (empty($user) || empty($pass) || empty($db)) {
echo '<b><font color="red">ERROR: Please enter your SQL information!</b></font><BR><BR>';
show_form();
} elseif (empty($key)) {
echo '<b><font color="red">ERROR: Key can not be blank!</b></font><BR><BR>';
show_form();
} elseif ($key != $key2) {
echo '<b><font color="red">ERROR: Keys do not match!</b></font><BR><BR>';
show_form();
} else {
// GENERATE PHP FILES
if (!copy("read_template.php", "read.php")) {
echo "FAILED TO COPY READ.PHP...<BR>";
} else {
echo "COPIED READ.PHP...<BR>";
}
if (!copy("add_template.php", "add.php")) {
echo "FAILED TO COPY ADD.PHP...<BR>";
} else {
echo "COPIED ADD.PHP...<BR>";
}
chmod("read.php", 0660);
chmod("add.php", 0660);
// CREATE IMG DIRECTORY
if (!file_exists('img')) {
mkdir('img', 0664, true);
echo "DIRECTORY CREATED...<BR>";
} else {
echo "DIRECTORY EXISTS...<BR>";
}
// CREATE DATABASES
$conn = new mysqli("localhost", $user, $pass);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "CREATE DATABASE " . $db;
if ($conn->query($sql) === TRUE) {
echo "DATABASE CREATED...<BR>";
} else {
echo "Error creating database: " . $conn->error;
die();
}
$conn->close();
$conn = new mysqli("localhost", $user, $pass, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "CREATE TABLE data (
ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
N TEXT,
P TEXT,
A TEXT,
C TEXT,
S TEXT,
R TEXT,
G TEXT
)";
if ($conn->query($sql) === TRUE) {
echo "DATA TABLE CREATED...<BR>";
} else {
echo "Error creating table: " . $conn->error;
die();
}
$sql = "CREATE TABLE ver (A VARCHAR(100))";
if ($conn->query($sql) === TRUE) {
echo "KEY TABLE CREATED...<BR>";
} else {
echo "Error creating table: " . $conn->error;
die();
}
// ADD KEY
$iv = "3450691827364523";
$key_en = openssl_encrypt("new_key", "aes-128-cbc", $key, 0, $iv);
$sql = "INSERT INTO ver (A)
VALUES ('$key_en')";
if ($conn->query($sql) === TRUE) {
echo "KEY ADDED...<BR>";
} else {
echo "Error adding key: " . $sql . "<br>" . $conn->error;
die();
}
$conn->close();
// CONFIGURE PHP FILES
$read_php = file_get_contents('read.php');
$read_php = str_replace("##USERNAME##", $user, $read_php);
$read_php = str_replace("##PASSWORD##", $pass, $read_php);
$read_php = str_replace("##DATABASE##", $db, $read_php);
file_put_contents('read.php', $read_php);
$add_php = file_get_contents('add.php');
$add_php = str_replace("##USERNAME##", $user, $add_php);
$add_php = str_replace("##PASSWORD##", $pass, $add_php);
$add_php = str_replace("##DATABASE##", $db, $add_php);
file_put_contents('add.php', $add_php);
echo "<BR>SUCCESS!<BR><BR>";
// REDIRECT
echo '<a href="index.html">CLICK HERE TO LOGIN</a>';
// ERASE THE EVIDENCE
unlink("read_template.php");
unlink("add_template.php");
unlink(__FILE__);
}
function show_form() {
printf('<form name="input" action="install.php" method="POST">
<b>INSTALLATION SCRIPT</b><BR><BR>
<label for="user">SQL Username:</label><BR><input name="user" id="user" type="text" class="formbox" /><BR><BR>
<label for="pass">SQL Password:</label><BR><input name="pass" id="pass" type="password" class="formbox" /><BR><BR>
<label for="db">New Database Name:</label><BR><input name="db" id="db" type="text" class="formbox" /><BR><BR>
<label for="key">Key:</label><BR><input name="key" id="key" type="password" class="formbox" /><BR><BR>
<label for="key2">Retype Key:</label><BR><input name="key2" id="key2" type="password" class="formbox" /><BR><BR>
<input name="submit" id="submit" type="submit" value="INSTALL" /></form>
</tt></center></body>
</html>');
die();
}
?>