From 5dcd6e4e55889179cdc19bfbf855a7b0e110a199 Mon Sep 17 00:00:00 2001 From: avrha Date: Tue, 7 Feb 2023 22:18:00 -0500 Subject: [PATCH 1/8] Removed Fira Font and Money Gif --- index.html | 23 +++++++---------------- index.php | 32 +++++++++----------------------- style.css | 14 ++++---------- 3 files changed, 20 insertions(+), 49 deletions(-) diff --git a/index.html b/index.html index d6b8cc5..36eec2b 100644 --- a/index.html +++ b/index.html @@ -8,14 +8,12 @@

Sorry This Account does not exsist
Return to Sign In

"; +

Sorry This Account does not exsist

Return to Sign In

"; } @@ -53,7 +50,6 @@ - *Your* Secure Info @@ -61,22 +57,12 @@ +


-
- - - - - -
-
+ - \ No newline at end of file + diff --git a/style.css b/style.css index 812df8f..ac3b608 100644 --- a/style.css +++ b/style.css @@ -1,14 +1,8 @@ -@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@300&display=swap'); - body{ width: 100%; - /* height: -webkit-fill-available; */ - min-height: 100%; - background-image: url("https://i.giphy.com/media/9SJ0zZnGVQSajeSMZ2/giphy.webp"); - background-size: cover; - background-position-x: center; + background-image: rgb(65,64,64); color: #f0f0f0; - font-family: 'Fira Sans', sans-serif; + font-family: Arial, Helvetica, sans-serif; box-shadow: 0 20000px rgba(15, 15, 15, .96) inset; } @@ -19,7 +13,7 @@ form, #bankinfo{ margin-right: 20%; margin-left: 20%; border-radius: 1em; - font-family: 'Fira Sans', sans-serif; + font-family: Arial, Helvetica, sans-serif; font-size: 1.5em; } @@ -30,7 +24,7 @@ h1{ input{ - background-color: #868686; + background-color: #f0f0f0; font-size: 1em; border-radius: .25em; } From 54d903bfddb2300b308d587410f94bcc9cb0eb8d Mon Sep 17 00:00:00 2001 From: avrha Date: Tue, 7 Feb 2023 22:39:35 -0500 Subject: [PATCH 2/8] Updated README.md, did some formatting --- .gitignore | 1 - README.md | 13 +++++------ connect.php | 7 ++++++ index.html | 48 +++++++++++++++++--------------------- index.php | 24 +++++++++---------- style.css | 67 +++++++++++++++++++++++++++-------------------------- 6 files changed, 80 insertions(+), 80 deletions(-) delete mode 100644 .gitignore create mode 100644 connect.php diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cd61d06..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -connect.php \ No newline at end of file diff --git a/README.md b/README.md index 44c56c3..c703083 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,20 @@ Build In | Contributors | Live version --- | --- | --- **PHP/SQL/HTML/CSS** | [@philip-hub](https://github.com/philip-hub) | Clone and run with your local SQL server -![SQL Server Hacking](https://i.giphy.com/media/TOWeGr70V2R1K/giphy.webp) - # Description and Setup +A tweaked version of [sql-injectiono-hack-workshop](https://github.com/philip-hub/sql-injection-hack-workshop) to run on a LAMP stack with minimal dependences. -This is a dummy bank website with poor security to teach people about the basics of SQL injection. In order to use this you will need a PHP server and you will need to create a SQL server, database, and table. Both of these tasks can easliy be done with [MAMP](https://www.mamp.info/en/). Once MAMP is instaled clone this repo to the desired path on your machine. MAMP Preferences then Web Server and navigate to the path that you cloned this repo too. Start MAMP up and should bring you to a MAMP homepage on your local host where you can access myPHPAdmin. Use myPHPadmin to create a SQL database and table. This [video](https://www.youtube.com/watch?v=s7p5aS8m57k) is a good guide for this task. Name your table "mhc_bank" without the quotes. In your table create the columns "username" , "password", and "amount" as type TEXT all as those are spelled without the quotes. Use the insert command in the menu bar to add some fake users with passwords and amounts. Then open the your repo path in your favorite a text or code editor. Create a connect.php file. Put the following code in connect.php.
+This is a dummy bank website with poor security to teach people about the basics of SQL injection. In order to use this you will need a PHP server and you will need to create a SQL server, database, and table. Name your table and database "mhc_bank" without the quotes. In your table create the columns "username" , "password", and "amount" as type TEXT all as those are spelled without the quotes. Use the insert command in the menu bar to add some fake users with passwords and amounts. Then open the your repo path in your favorite a text or code editor. Create a connect.php file. Put the following code in connect.php.
``` ``` -

Try signing in to one user's account then refernce the article below and the source code and try some SQL injection commands. +

Try signing in to one user's account then reference the article below and the source code and try some SQL injection commands. W3 Schools has a great article about SQL injection here

--- diff --git a/connect.php b/connect.php new file mode 100644 index 0000000..d8f3df0 --- /dev/null +++ b/connect.php @@ -0,0 +1,7 @@ + + diff --git a/index.html b/index.html index 36eec2b..10e5fd4 100644 --- a/index.html +++ b/index.html @@ -1,38 +1,32 @@ + - - The Secure Bank + The Secure Bank + body { + width: 100%; + min-height: 100%; + background-color: rgb(65, 64, 64); + color: #f0f0f0; + box-shadow: 0 20000px rgba(15, 15, 15, .96) inset; + } + - -
-

Sign into your bank secure account today


-

-


-


-
+
-
- -
-
-
- +

Sign into your bank secure account today


+

+


+


+
+
+
+
- + + \ No newline at end of file diff --git a/index.php b/index.php index fe8ebe8..df4072b 100644 --- a/index.php +++ b/index.php @@ -31,20 +31,20 @@ } } } else { - $bank_info = "

Sorry This Account does not exsist

Return to Sign In

"; + $bank_info = " + +

Sorry This Account does not exsist

Return to Sign In

"; } - ?> diff --git a/style.css b/style.css index ac3b608..a8ebe6c 100644 --- a/style.css +++ b/style.css @@ -1,14 +1,15 @@ -body{ +body { width: 100%; - background-image: rgb(65,64,64); + background-image: rgb(65, 64, 64); color: #f0f0f0; font-family: Arial, Helvetica, sans-serif; - box-shadow: 0 20000px rgba(15, 15, 15, .96) inset; - + box-shadow: 0 20000px rgba(15, 15, 15, .96) inset; + } -form, #bankinfo{ - background-color:#2E2E2E; +form, +#bankinfo { + background-color: #2E2E2E; text-align: center; margin-right: 20%; margin-left: 20%; @@ -17,26 +18,26 @@ form, #bankinfo{ font-size: 1.5em; } -h1{ - +h1 { + text-align: center; } -input{ - +input { + background-color: #f0f0f0; font-size: 1em; border-radius: .25em; } - -p{ + +p { text-align: center; font-size: 1.5em; } -a{ - color:#FF3374; +a { + color: #FF3374; text-align: center; font-size: 1.5em; } @@ -44,29 +45,29 @@ a{ .fa { font-size: 2.5em; text-align: center; - color:#33D1FF; + color: #33D1FF; padding: 20px; font-size: 30px; width: 10px; text-decoration: none; margin: 5px 2px; border-radius: 50%; - - } - - .fa:hover { - opacity: 0.7; - - } - - #money { - color:#FFCB1B; - } - - #name{ - color:#FF3374; - } - #password{ - color:#09FF36; - } +} + +.fa:hover { + opacity: 0.7; + +} + +#money { + color: #FFCB1B; +} + +#name { + color: #FF3374; +} + +#password { + color: #09FF36; +} \ No newline at end of file From fc13194fe161c38860dddd7b96760fc7009bfff4 Mon Sep 17 00:00:00 2001 From: avrha Date: Tue, 7 Feb 2023 23:01:37 -0500 Subject: [PATCH 3/8] Added install.sh, and .gitignor --- .gitignore | 1 + install.sh | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 .gitignore create mode 100755 install.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f6830d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +connect.php diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..d183393 --- /dev/null +++ b/install.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Ensure Script is executed under root privileges. +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit +fi + +cp index.html index.php style.css connect.php /var/www/html/ + +echo "Success! Website installed." + From 08db8f47a8520772d87b05571fd80a5936f176e0 Mon Sep 17 00:00:00 2001 From: Joey Ferenchak <44786848+avrha@users.noreply.github.com> Date: Tue, 7 Feb 2023 23:07:27 -0500 Subject: [PATCH 4/8] Delete .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f6830d0..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -connect.php From eff9e9ed6d6716d62d7ef159940efc08aeefffa0 Mon Sep 17 00:00:00 2001 From: Joey Ferenchak <44786848+avrha@users.noreply.github.com> Date: Tue, 7 Feb 2023 23:07:36 -0500 Subject: [PATCH 5/8] Delete connect.php --- connect.php | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 connect.php diff --git a/connect.php b/connect.php deleted file mode 100644 index d8f3df0..0000000 --- a/connect.php +++ /dev/null @@ -1,7 +0,0 @@ - - From 230303838cc7d24af8e0fcc395cec3839e249f10 Mon Sep 17 00:00:00 2001 From: avrha Date: Wed, 8 Feb 2023 16:32:08 -0500 Subject: [PATCH 6/8] Add install script for website and sql server. Modified README.md --- README.md | 14 +++--- connect.php | 6 +++ install.sh | 110 ++++++++++++++++++++++++++++++++++++++++++++-- setupDatabase.sql | 23 ++++++++++ 4 files changed, 142 insertions(+), 11 deletions(-) create mode 100644 connect.php create mode 100644 setupDatabase.sql diff --git a/README.md b/README.md index c703083..8c546e3 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,20 @@ Build In | Contributors | Live version **PHP/SQL/HTML/CSS** | [@philip-hub](https://github.com/philip-hub) | Clone and run with your local SQL server # Description and Setup -A tweaked version of [sql-injectiono-hack-workshop](https://github.com/philip-hub/sql-injection-hack-workshop) to run on a LAMP stack with minimal dependences. +A tweaked version of [sql-injectiono-hack-workshop](https://github.com/philip-hub/sql-injection-hack-workshop) to run on a Debian or Ubuntu machine hosting a LAMP stack application. -This is a dummy bank website with poor security to teach people about the basics of SQL injection. In order to use this you will need a PHP server and you will need to create a SQL server, database, and table. Name your table and database "mhc_bank" without the quotes. In your table create the columns "username" , "password", and "amount" as type TEXT all as those are spelled without the quotes. Use the insert command in the menu bar to add some fake users with passwords and amounts. Then open the your repo path in your favorite a text or code editor. Create a connect.php file. Put the following code in connect.php.
+This is a dummy bank website with poor security to teach people about the basics of SQL injection. This website requires a PHP server and a SQL server with a database as well as a table both named mhc_bank. The mhc_bank table has three TEXT columns labeled "username" , "password", and "amount". You can setup the website and install all of its dependences by running this repo's installation script. In a terminal, run ```sudo ./install.sh```. After the installation script is done running, modifiy ```connect.php``` in ```/var/www/html``` with your favorite text editor. Edit the following code.
``` ``` -

Try signing in to one user's account then reference the article below and the source code and try some SQL injection commands. -W3 Schools has a great article about SQL injection here

+ +

Verify the website is working by opening a web browser and going to http://localhost/. Once at the login page, try signing in to a user's account. Reference the article below and try some SQL injection commands. W3 Schools has a great article about SQL injection here

--- diff --git a/connect.php b/connect.php new file mode 100644 index 0000000..d0333eb --- /dev/null +++ b/connect.php @@ -0,0 +1,6 @@ + diff --git a/install.sh b/install.sh index d183393..8ffa8f1 100755 --- a/install.sh +++ b/install.sh @@ -1,11 +1,113 @@ #!/bin/bash +# Colors +RED='\033[0;31m' +GREEN='\u001b[32m' +YELLOW='\u001b[33m' +NC='\033[0m' + # Ensure Script is executed under root privileges. if [ "$EUID" -ne 0 ] - then echo "Please run as root" - exit +then echo -e "${RED}-RUN AS ROOT-${NC}" +exit +fi + +# Update & Upgrade System +echo -e "Update System? ${GREEN}Y${YELLOW}/${RED}N${NC}" +read input + +if [[ $input == Y ]] || [[ $input == y ]] || [[ $input == yes ]]; then + apt update && apt upgrade -y + apt autoremove -y + echo -e "${GREEN}-SYSTEM UPDATED-${NC}" +elif [[ $input == N ]] || [[ $input == n ]] || [[ $input == no ]]; then + echo -e "${RED}-SYSTEM NOT UPDATED-${NC}" +else + echo -e "${RED}-INVALID INPUT-${NC}" +fi + +# Install Apache +echo -e "Install Apache? ${GREEN}Y${YELLOW}/${RED}N${NC}" +read input + +if [[ $input == Y ]] || [[ $input == y ]] || [[ $input == yes ]]; then + apt install apache2 apache2-utils -y + systemctl enable apache2 + systemctl start apache2 + echo -e "${GREEN}-APACHE INSTALLED-${NC}" +elif [[ $input == N ]] || [[ $input == n ]] || [[ $input == no ]]; then + echo -e "${RED}-APACHE NOT INSTALLED-${NC}" +else + echo -e "${RED}-INVALID INPUT-${NC}" +fi + + +# Install MySQL (MariaDB) +echo -e "Install MySQL? ${GREEN}Y${YELLOW}/${RED}N${NC}" +read input + +if [[ $input == Y ]] || [[ $input == y ]] || [[ $input == yes ]]; then + apt install mariadb-server -y + systemctl enable mariadb + systemctl start mariadb + echo -e "${GREEN}-MYSQL INSTALLED-${NC}" +elif [[ $input == N ]] || [[ $input == n ]] || [[ $input == no ]]; then + echo -e "${RED}-MYSQL NOT INSTALLED-${NC}" +else + echo -e "${RED}-INVALID INPUT-${NC}" fi -cp index.html index.php style.css connect.php /var/www/html/ +# Configure MySQL Service +echo -e "Configure MySQL Service? ${GREEN}Y${YELLOW}/${RED}N${NC}" +read input -echo "Success! Website installed." +if [[ $input == Y ]] || [[ $input == y ]] || [[ $input == yes ]]; then + mysql_secure_installation + echo -e "${GREEN}-MYSQL SERVICE CONFIGURED-${NC}" +elif [[ $input == N ]] || [[ $input == n ]] || [[ $input == no ]]; then + echo -e "${RED}-MYSQL SERVICE NOT CONFIGURED-${NC}" +else + echo -e "${RED}-INVALID INPUT-${NC}" +fi + +# Configure MySQL Database +echo -e "Configure MySQL Database? ${GREEN}Y${YELLOW}/${RED}N${NC}" +read input + +if [[ $input == Y ]] || [[ $input == y ]] || [[ $input == yes ]]; then + echo "Enter password for MySQL root account." + mysql -u root -p < setupDatabase.sql + echo -e "${GREEN}-MYSQL DATABASE CONFIGURED-${NC}" +elif [[ $input == N ]] || [[ $input == n ]] || [[ $input == no ]]; then + echo -e "${RED}-MYSQL DATABASE NOT CONFIGURED-${NC}" +else + echo -e "${RED}-INVALID INPUT-${NC}" +fi + +# Install PHP +echo -e "Install PHP? ${GREEN}Y${YELLOW}/${RED}N${NC}" +read input + +if [[ $input == Y ]] || [[ $input == y ]] || [[ $input == yes ]]; then + apt install php php-cli php-mysql libapache2-mod-php php-gd php-xml php-curl php-common -y + echo -e "${GREEN}-PHP INSTALLED-${NC}" +elif [[ $input == N ]] || [[ $input == n ]] || [[ $input == no ]]; then + echo -e "${RED}-PHP NOT INSTALLED-${NC}" +else + echo -e "${RED}-INVALID INPUT-${NC}" +fi + +# Install Website +echo -e "Install Website? ${GREEN}Y${YELLOW}/${RED}N${NC}" +read input + +if [[ $input == Y ]] || [[ $input == y ]] || [[ $input == yes ]]; then + # Move files to /var/www/html + echo "cp index.html index.php style.css connect.php /var/www/html/" + cp index.html index.php style.css connect.php /var/www/html/ + echo -e "${GREEN}-WEBSITE INSTALLED-${NC}" +elif [[ $input == N ]] || [[ $input == n ]] || [[ $input == no ]]; then + echo -e "${RED}-WEBSITE NOT INSTALLED-${NC}" +else + echo -e "${RED}-INVALID INPUT-${NC}" +fi diff --git a/setupDatabase.sql b/setupDatabase.sql new file mode 100644 index 0000000..3e38a3a --- /dev/null +++ b/setupDatabase.sql @@ -0,0 +1,23 @@ +-- Create database mhc_bank, and use it. +CREATE DATABASE mhc_bank; +USE mhc_bank; + +-- Create table mhc_bank and three text columns named username, password, amount. +CREATE TABLE mhc_bank ( + username TEXT(255), + password TEXT(255), + amount TEXT(255) +); + +-- Insert data into mhc_bank table. +INSERT INTO mhc_bank (username, password, amount) +VALUES ("alice", "apples123", "500"); + +INSERT INTO mhc_bank (username, password, amount) +VALUES ("bob", "banana321", "250"); + +INSERT INTO mhc_bank (username, password, amount) +VALUES ("carol", "coconut231", "750"); + +-- Showcase data in mhc_bank. +SELECT * FROM mhc_bank; From f05262428fd857b55cd35ff8c89f958f2c96483f Mon Sep 17 00:00:00 2001 From: avrha Date: Thu, 9 Feb 2023 16:42:44 -0500 Subject: [PATCH 7/8] Change comments in connect.php. Add description details in README.md --- README.md | 16 ++++++++-------- connect.php | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8c546e3..fc0896f 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,20 @@ Build In | Contributors | Live version **PHP/SQL/HTML/CSS** | [@philip-hub](https://github.com/philip-hub) | Clone and run with your local SQL server # Description and Setup -A tweaked version of [sql-injectiono-hack-workshop](https://github.com/philip-hub/sql-injection-hack-workshop) to run on a Debian or Ubuntu machine hosting a LAMP stack application. +A modified version of [sql-injectiono-hack-workshop](https://github.com/philip-hub/sql-injection-hack-workshop) to run on a Debian or Ubuntu machine hosting a LAMP stack application. -This is a dummy bank website with poor security to teach people about the basics of SQL injection. This website requires a PHP server and a SQL server with a database as well as a table both named mhc_bank. The mhc_bank table has three TEXT columns labeled "username" , "password", and "amount". You can setup the website and install all of its dependences by running this repo's installation script. In a terminal, run ```sudo ./install.sh```. After the installation script is done running, modifiy ```connect.php``` in ```/var/www/html``` with your favorite text editor. Edit the following code.
+This is a dummy bank website with poor security to teach people about the basics of SQL injection. This website requires a PHP server and a SQL server with a database as well as a table both named mhc_bank. The mhc_bank table has three TEXT columns labeled "username" , "password", and "amount". You can setup the website and install all of its dependences by running this repo's installation script. In a terminal, run ```sudo ./install.sh```. After the installation script is done running, modifiy ```connect.php``` in ```/var/www/html``` with your favorite text editor under root privileges. Edit the following code.
``` -``` -

Verify the website is working by opening a web browser and going to http://localhost/. Once at the login page, try signing in to a user's account. Reference the article below and try some SQL injection commands. W3 Schools has a great article about SQL injection here

+``` +

Verify the website is working by opening a web browser and going to http://localhost/. Once at the login page, try signing in to a user's account. Reference the article below and try some SQL injection commands. W3 Schools has a great article about SQL injection here.

--- diff --git a/connect.php b/connect.php index d0333eb..32991f5 100644 --- a/connect.php +++ b/connect.php @@ -1,6 +1,6 @@ From bbdc50cea4072e82ec88d5a5afc8b3fc9ec81f24 Mon Sep 17 00:00:00 2001 From: avrha Date: Sat, 11 Feb 2023 21:44:13 -0500 Subject: [PATCH 8/8] Add input sanitization to prevent injection. --- index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.php b/index.php index df4072b..807d20c 100644 --- a/index.php +++ b/index.php @@ -10,6 +10,11 @@ // Make a SQL query $username=$_POST["username"]; $password = $_POST["password"]; + +// Sanitize input +// $username=filter_var($username, FILTER_SANITIZE_STRING); +// $password=filter_var($password, FILTER_SANITIZE_STRING); + $sql = 'SELECT * FROM mhc_bank WHERE username ="'.$username.'" AND password ="'.$password.'";'; // echo $sql; $result = mysqli_query($conn, $sql);