# Phishing training application

Application used for training users against phishing attacks using emails for communication. 
App also provides statistics about emails used in training.

## Starting the application with Vagrant

### Requirements

You need to have Virtualbox and Vagrant installed.

* Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) - required version 6.1.0+
* Install [Vagrant](https://www.vagrantup.com/downloads) - required version 2+

### Starting the application

To start application open the terminal with path to project directory and run following command:
```bash
$ vagrant up
```

Application is available on `http://localhost:3000`.

## Run application locally

If you want to run application without vagrant, firstly you must install 
mysql (server and client) and import dump file into database. Then install packages
for frontend and backend of application.

### MySQL install and config
Application is configured for 
following database settings:  

```DBNAME```  phishingdb  
```DBUSER```  phish  
```DBPASSWD```  phish123  

If you want to use different database settings, you must change Django setting file,
located in ```backend/trainingApi/settings.py```.

To install and configure database for application run following commands:
```bash
DBHOST=localhost
DBNAME=phishingdb
DBUSER=phish
DBPASSWD=phish123

debconf-set-selections <<< "mysql-server mysql-server/root_password password $DBPASSWD"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DBPASSWD"
sudo apt-get -y install mysql-server
sudo apt-get -y install libmysqlclient-dev 
mysql -uroot -p$DBPASSWD -e "CREATE DATABASE $DBNAME"
mysql -uroot -p$DBPASSWD -e "grant all privileges on $DBNAME.* to '$DBUSER'@'localhost' identified by '$DBPASSWD'"
mysql -uroot -p$DBPASSWD $DBNAME < dump/dump.sql
```

### Backend
For backend of application you must install python3, python3-pip and pipenv.

```bash
cd backend
sudo apt-get install -y python3
sudo apt-get install -y python3-pip
sudo pip3 install pipenv
pipenv install
pipenv run python manage.py makemigrations
pipenv run python manage.py migrate
```

### Frontend
Before running frontend of application you must install nodejs, modules 
and then run build. Enter following commands to terminal:
```bash
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt -y install nodejs
cd frontend
rm -rf package-lock.json
npm install
npm run build
sudo npm install -g serve
```

### Start application
After installation, you can run the application by typing following commands:

```bash
cd backend/
pipenv run python manage.py runserver
cd fronted/
serve -s build 
```

### Training configuration
If you want to enter administration section of training, you have to enter these credentials: 
 
login: admin  
password: admin

There is no option to register new user through frontend, if you want to add new user, 
visit ```http:localhost:8000/auth/register```.

In dump file are 13 emails (9 phishing and 4 legitimate), so be careful when changing training settings.
If there is not enough of emails in database, gamerun cannot be initialized.



**author:** Patrik Brosz  
**version:** 0.1.0  
**license:** MIT  
**repository:** [Github](https://gitlab.fi.muni.cz/xbrosz/phishing-game.git)