Please choose the username, password and signature you wish to use:
-
User Name:
-
Password:
-
Password Confirm:
-
Signature:
-
+
Please register by entering all fields:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
"") {
if ($password == $passwordconfirm ) {
- $query = "INSERT INTO accounts (username, password, mysignature) VALUES
- ('" . $username ."', '" . $password . "', '" . $mysignature ."')";
- //echo $query;
- $result = $conn->query($query);
+ $query = "INSERT INTO accounts (username, password, first_name, last_name, department, hire_date, mysignature) VALUES
+ ('" . db_escape_string($conn, $username) . "',
+ '" . db_escape_string($conn, $password) . "',
+ '" . db_escape_string($conn, $first_name) . "',
+ '" . db_escape_string($conn, $last_name) . "',
+ '" . $department . "',
+ " . db_now() . ",
+ '" . $mysignature . "')";
+ $result = db_query($conn, $query);
echo mysqli_error($conn);
echo "Account Made";
} else {
@@ -45,8 +113,8 @@
for more ways you can encode XSS attacks that may allow you to get around
some filters.
- For SQL Injection: Mostly errors, but they reveal too much information about
- the application.
+ For SQL Injection: Check all the fields. Some may not be vulnerable
+ but perhaps controls for some others were missed.
';
}
// End hints section
diff --git a/src/basic/reset-db.php b/src/basic/reset-db.php
index 77906bb..eda0b95 100644
--- a/src/basic/reset-db.php
+++ b/src/basic/reset-db.php
@@ -9,51 +9,72 @@
Dropping database...");
-$conn = new mysqli($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
-$conn->query("DROP DATABASE IF EXISTS $dbname");
-echo mysqli_error($conn);
+// Function to execute queries and handle errors for both MySQL and SQLite
+function execute_query($conn, $query) {
+ if ($GLOBALS['db_type'] === 'mysql') {
+ $result = $conn->query($query);
+ echo mysqli_error($conn);
+ } else {
+ $result = $conn->exec($query);
+ echo $conn->lastErrorMsg();
+ }
+ return $result;
+}
-echo(" Creating database...");
-$conn->query("CREATE DATABASE $dbname");
-echo mysqli_error($conn);
+if ($db_type === 'mysql') {
+ echo(" Connecting to MySQL...");
+ $conn = new mysqli($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
+
+ echo(" Dropping database...");
+ execute_query($conn, "DROP DATABASE IF EXISTS $dbname");
+
+ echo(" Creating database...");
+ execute_query($conn, "CREATE DATABASE $dbname");
+
+ $conn->select_db($dbname);
+} else {
+ echo(" Setting up SQLite...");
+ $db_file = '/var/www/html/db/' . $dbname . '.sqlite';
+
+ // Delete the existing database file if it exists
+ if (file_exists($db_file)) {
+ echo(" Removing existing SQLite database...");
+ unlink($db_file);
+ }
+
+ echo(" Creating new SQLite database...");
+ $conn = new SQLite3($db_file);
+}
echo(" Creating blogs table...");
-include 'opendb.inc';
$query = 'CREATE TABLE blogs_table( '.
- 'cid INT NOT NULL AUTO_INCREMENT, '.
+ 'cid INTEGER PRIMARY KEY ' . ($db_type === 'mysql' ? 'AUTO_INCREMENT' : 'AUTOINCREMENT') . ', '.
'blogger_name TEXT, '.
'comment TEXT, '.
- 'date DATETIME, '.
- 'PRIMARY KEY(cid))';
-$result = $conn->query($query);
-echo mysqli_error($conn );
+ 'date DATETIME)';
+execute_query($conn, $query);
echo(" Creating accounts table...");
$query = 'CREATE TABLE accounts( '.
- 'cid INT NOT NULL AUTO_INCREMENT, '.
+ 'cid INTEGER PRIMARY KEY ' . ($db_type === 'mysql' ? 'AUTO_INCREMENT' : 'AUTOINCREMENT') . ', '.
'username TEXT, '.
'password TEXT, '.
'mysignature TEXT, '.
'first_name TEXT, '.
'last_name TEXT, '.
'department TEXT, '.
- 'hire_date DATE, '.
- 'PRIMARY KEY(cid))';
-$result = $conn->query($query);
-echo mysqli_error($conn );
+ 'hire_date DATE)';
+execute_query($conn, $query);
echo(" Creating hitlog table...");
$query = 'CREATE TABLE hitlog( '.
- 'cid INT NOT NULL AUTO_INCREMENT, '.
+ 'cid INTEGER PRIMARY KEY ' . ($db_type === 'mysql' ? 'AUTO_INCREMENT' : 'AUTOINCREMENT') . ', '.
'hostname TEXT, '.
'ip TEXT, '.
- 'browser TEXT, '.
- 'referer TEXT, '.
- 'date DATETIME, '.
- 'PRIMARY KEY(cid))';
-$result = $conn->query($query);
-echo mysqli_error($conn );
+ 'browser TEXT, '.
+ 'referer TEXT, '.
+ 'date DATETIME)';
+execute_query($conn, $query);
echo(" Populating accounts table...");
$query = "INSERT INTO accounts (username, password, mysignature, first_name, last_name, department, hire_date) VALUES
@@ -65,41 +86,43 @@
('micwg', 'cim', 'Maple-flavored client-side security, eh?', 'Mic', 'Northguard', 'Engineering', '2019-11-30'),
('jasong', 'pentest', 'Extending security one suite at a time', 'Jason', 'Ideasmith', 'Engineering', '2020-09-22'),
('kevin', 'force42', 'May the security be with you, always', 'Kevin', 'Skyguard', 'Management', '2015-05-04')";
-//echo $query;
-$result = $conn->query($query);
-echo mysqli_error($conn );
+execute_query($conn, $query);
echo(" Populating blogs table...");
-$query ="INSERT INTO `blogs_table` (`cid`, `blogger_name`, `comment`, `date`) VALUES
- (1, 'adrian', 'Well, I''ve been working on this for a bit. Welcome to my crappy blog software. :)', '2009-03-01 22:26:12'),
- (2, 'adrian', 'Looks like I got a lot more work to do. Fun, Fun, Fun!!!', '2009-03-01 22:26:54'),
- (3, 'anonymous', 'An anonymous blog? Huh? ', '2009-03-01 22:27:11'),
- (4, 'ed', 'I love me some Netcat!!!', '2009-03-01 22:27:48'),
- (5, 'john', 'Listen to Pauldotcom!', '2009-03-01 22:29:04'),
- (6, 'john', 'Why give users the ability to get to the unfiltered Internet? It''s just asking for trouble. ', '2009-03-01 22:29:49'),
- (7, 'john', 'Chocolate is GOOD!!!', '2009-03-01 22:30:06'),
- (8, 'admin', 'Fear me, for I am ROOT!', '2009-03-01 22:31:13'),
- (9, 'ed', 'Hack the planet!', '2024-07-19 10:15:00'),
- (10, 'justin', 'Remember: it''s not a bug, it''s an undocumented feature.', '2024-07-19 11:30:00'),
- (11, 'micwg', 'Just spent 3 hours debugging. It was DNS. It''s always DNS!', '2024-07-19 14:45:00'),
- (12, 'jasong', 'Did you hear about the Olympic size swimming pool on the roof?', '2024-07-19 16:20:00'),
- (13, 'adrian', 'I''m not arguing, I''m just explaining why I''m right.', '2024-07-19 18:00:00'),
- (14, 'john', 'There are 10 types of people in this world: those who understand binary and those who don''t.', '2024-07-19 20:30:00'),
- (15, 'micwg', 'I''m not antisocial, I just like my space... 127.0.0.1 is where the heart is.', '2024-07-20 09:15:00'),
- (16, 'justin', 'Keep calm and sudo on!', '2024-07-20 11:45:00'),
- (17, 'ed', 'I don''t always test my code, but when I do, I do it in production.', '2024-07-20 14:00:00'),
- (18, 'jasong', 'Life is short, use Python.', '2024-07-20 16:30:00'),
- (19, 'kevin', 'Just found a way to bypass the firewall. Don''t tell the admin!', '2024-07-21 09:15:00'),
- (20, 'kevin', 'Pro tip: \"P@ssw0rd\" is not a strong password, no matter how many times you use it.', '2024-07-21 11:30:00'),
- (21, 'kevin', 'Today''s goal: Stay away from the cookie jar. And by cookie jar, I mean other people''s session cookies.', '2024-07-21 14:45:00'),
- (22, 'kevin', 'Remember, kids: SQL injection is like adding hot sauce. A little goes a long way, but too much and you''ll regret it.', '2024-07-22 10:00:00'),
- (23, 'kevin', 'Breaking news: I found a security flaw in our coffee machine. It''s now brewing espresso for everyone. You''re welcome.', '2024-07-22 16:45:00')";
-//echo $query;
-$result = $conn->query($query);
-echo mysqli_error($conn );
+$query ="INSERT INTO `blogs_table` (`blogger_name`, `comment`, `date`) VALUES
+ ('adrian', 'Well, I''ve been working on this for a bit. Welcome to my crappy blog software. :)', '2009-03-01 22:26:12'),
+ ('adrian', 'Looks like I got a lot more work to do. Fun, Fun, Fun!!!', '2009-03-01 22:26:54'),
+ ('anonymous', 'An anonymous blog? Huh? ', '2009-03-01 22:27:11'),
+ ('ed', 'I love me some Netcat!!!', '2009-03-01 22:27:48'),
+ ('john', 'Listen to Pauldotcom!', '2009-03-01 22:29:04'),
+ ('john', 'Why give users the ability to get to the unfiltered Internet? It''s just asking for trouble. ', '2009-03-01 22:29:49'),
+ ('john', 'Chocolate is GOOD!!!', '2009-03-01 22:30:06'),
+ ('admin', 'Fear me, for I am ROOT!', '2009-03-01 22:31:13'),
+ ('ed', 'Hack the planet!', '2024-07-19 10:15:00'),
+ ('justin', 'Remember: it''s not a bug, it''s an undocumented feature.', '2024-07-19 11:30:00'),
+ ('micwg', 'Just spent 3 hours debugging. It was DNS. It''s always DNS!', '2024-07-19 14:45:00'),
+ ('jasong', 'Did you hear about the Olympic size swimming pool on the roof?', '2024-07-19 16:20:00'),
+ ('adrian', 'I''m not arguing, I''m just explaining why I''m right.', '2024-07-19 18:00:00'),
+ ('john', 'There are 10 types of people in this world: those who understand binary and those who don''t.', '2024-07-19 20:30:00'),
+ ('micwg', 'I''m not antisocial, I just like my space... 127.0.0.1 is where the heart is.', '2024-07-20 09:15:00'),
+ ('justin', 'Keep calm and sudo on!', '2024-07-20 11:45:00'),
+ ('ed', 'I don''t always test my code, but when I do, I do it in production.', '2024-07-20 14:00:00'),
+ ('jasong', 'Life is short, use Python.', '2024-07-20 16:30:00'),
+ ('kevin', 'Just found a way to bypass the firewall. Don''t tell the admin!', '2024-07-21 09:15:00'),
+ ('kevin', 'Pro tip: \"P@ssw0rd\" is not a strong password, no matter how many times you use it.', '2024-07-21 11:30:00'),
+ ('kevin', 'Today''s goal: Stay away from the cookie jar. And by cookie jar, I mean other people''s session cookies.', '2024-07-21 14:45:00'),
+ ('kevin', 'Remember, kids: SQL injection is like adding hot sauce. A little goes a long way, but too much and you''ll regret it.', '2024-07-22 10:00:00'),
+ ('kevin', 'Breaking news: I found a security flaw in our coffee machine. It''s now brewing espresso for everyone. You''re welcome.', '2024-07-22 16:45:00')";
+execute_query($conn, $query);
+if ($db_type === 'mysql') {
+ $conn->close();
+} else {
+ $conn->close();
+ unset($conn);
+}
echo "