Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I created four labs #176

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ venv
*db.sqlite3
*/app.log
pygoat/app.log
pygoat/.DS_Store
pygoat/introduction/.DS_Store
test.html
http_server.py
.DS_Store
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ First, Clone the repository using GitHub website or git in Terminal
2. Change directory to the the Django Project directory `cd pygoat`<br>
3. Apply the migrations `python3 manage.py migrate`.<br>
4. Finally, run the development server `python3 manage.py runserver`.<br>
5. The project will be available at <http://127.0.0.1:8000>
5. The project will be available at <http://127.0.0.1:8000>

#### Method 2

Expand All @@ -55,7 +55,14 @@ First, Clone the repository using GitHub website or git in Terminal
2. Change directory to the the Django Project directory `cd pygoat`<br>
3. Apply the migrations `python3 manage.py migrate`.<br>
4. Finally, run the development server `python3 manage.py runserver`.<br>
5. The project will be available at <http://127.0.0.1:8000>
5. The project will be available at <http://127.0.0.1:8000>

#### Method 4
1. Install all app and python requirements using installer file - `bash installer.sh`
2. Change directory to the the Django Project directory `cd pygoat`<br>
3. Apply the migrations `python3 manage.py migrate`.<br>
4. Finally, run the development server `python3 manage.py runserver 0.0.0.0:8000`.<br>
5. The project will be available at <http://<server_IP>:8000>

### Docker Container
1. Install [Docker](https://www.docker.com)
Expand Down
12 changes: 12 additions & 0 deletions install_fedora.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
echo "INSTALL DEPENDENCIES"

yum -y install libpq-devel
yum -y install zlib-devel
yum -y install libjpeg-devel
yum -y install libffi-devel
yum -y install python3-devel

echo "ADDING FIREWALLD RULES FOR PORT 8000"
firewall-cmd --add-port=8000/tcp --permanent
firewall-cmd --reload
30 changes: 30 additions & 0 deletions install_redis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
echo "RUN SCRIPT AS ROOT"

echo "INSTALLING REDIS DEPENDENCIES"
yum -y install wget
yum -y install make
yum -y install gcc

echo "INSTALLING REDIS FROM SOURCE"

wget https://download.redis.io/releases/redis-5.0.8.tar.gz
tar -zxvf redis-5.0.8.tar.gz
cd redis-5.0.8
make MALLOC=libc install
mkdir /etc/redis
cp redis.conf /etc/redis/

echo "INSTALLED REDIS VERSION:"
redis-server -v

echo "You can start redis with:"
echo "redis-server /etc/redis/redis.conf"

echo "OPENING FIREWALL RULE FOR REDIS"

firewall-cmd --permanent --new-zone=redis
firewall-cmd --permanent --zone=redis --add-port=6379/tcp
firewall-cmd --permanent --zone=redis --add-source=127.0.0.1
firewall-cmd --reload

echo "All Done"
22 changes: 22 additions & 0 deletions pygoat/introduction/migrations/0022_zodiac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.0.4 on 2022-12-06 15:10

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('introduction', '0021_csrf_user_tbl'),
]

operations = [
migrations.CreateModel(
name='zodiac',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('symbol', models.CharField(max_length=200)),
('count', models.IntegerField(validators=[django.core.validators.MaxValueValidator(300)])),
],
),
]
22 changes: 22 additions & 0 deletions pygoat/introduction/migrations/0023_bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.0.4 on 2022-12-07 03:31

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('introduction', '0022_zodiac'),
]

operations = [
migrations.CreateModel(
name='Bank',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('user', models.CharField(max_length=200)),
('balance', models.IntegerField(validators=[django.core.validators.MaxValueValidator(300)])),
],
),
]
22 changes: 22 additions & 0 deletions pygoat/introduction/migrations/0024_totalwithdrawn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.0.4 on 2022-12-07 05:54

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('introduction', '0023_bank'),
]

operations = [
migrations.CreateModel(
name='TotalWithdrawn',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('user', models.CharField(max_length=200)),
('total', models.IntegerField(validators=[django.core.validators.MaxValueValidator(300)])),
],
),
]
17 changes: 17 additions & 0 deletions pygoat/introduction/migrations/0025_rename_totalwithdrawn_atm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.0.4 on 2022-12-07 06:23

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('introduction', '0024_totalwithdrawn'),
]

operations = [
migrations.RenameModel(
old_name='TotalWithdrawn',
new_name='ATM',
),
]
50 changes: 49 additions & 1 deletion pygoat/introduction/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.db import models
from django.core.validators import MaxValueValidator
from django.conf import settings
import time
# Create your models here.

class FAANG (models.Model):
Expand Down Expand Up @@ -93,4 +94,51 @@ class CSRF_user_tbl(models.Model):
is_loggedin = models.BooleanField(default=False)

def __str__(self):
return self.username
return self.username

class zodiac(models.Model):
id = models.AutoField(primary_key=True)
symbol=models.CharField(max_length=200)
count=models.IntegerField(validators=[MaxValueValidator(300)])

def __str__(self):
return self.symbol +": "+str(self.count)

def add(self):
self.count+=1

class Bank(models.Model):
id = models.AutoField(primary_key=True)
user=models.CharField(max_length=200)
balance=models.IntegerField(validators=[MaxValueValidator(300)])

def updateBalance(self, money):
time.sleep(1)
self.balance = self.balance-money

def getBalance(self):
return self.balance

def reset(self, num):
self.balance=num

def __str__(self):
return self.user + ":"+str(self.balance)

class ATM(models.Model):
id = models.AutoField(primary_key=True)
user=models.CharField(max_length=200)
total=models.IntegerField(validators=[MaxValueValidator(300)])

def reset(self):
self.total=0

def withdraw(self, num):
account=Bank.objects.all().filter(user=self.user)[0]
if account.balance>=num:
self.total=self.total+num
self.save()
return True
else:
return False

Binary file added pygoat/introduction/static/nika.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion pygoat/introduction/templates/Lab/A11/a11.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h4>What is Insecure Design</h4>
being developed, and thus the failure to determine what level of security
design is required.
</p>
<button class="coll btn btn-info">Lab Details</button>
<button class="coll btn btn-info">Lab 1</button>
<div class="lab">
<p class="bp">
This lab helps you to get an idea of how Insecure Design can result in major Security flaw.
Expand All @@ -35,6 +35,20 @@ <h4>What is Insecure Design</h4>
<div align="right"> <button class="btn btn-info" type="button" onclick="window.location.href='/insecure-design_lab'">Access
Lab</button></div>
</div>
<button class="coll btn btn-info">Lab 2</button>
<div class="lab">
<p class="bp">
This lab helps you to get an idea of how Insecure Design can result in major Security flaw.

In the next page, you will see Safe Bank, where a user can withdraw money from the bank if he has
sufficient balance.
<ul><code>Hint</code></ul>
<ul>What happens with many tabs sending withdrawal requests at the same time. Is it safe to bots sending requests?</ul>

<br>
<div align="right"> <button class="btn btn-info" type="button" onclick="window.location.href='/insecure-design_lab2'">Access
Lab</button></div>
</div>
<div>
<br>
<h4>Mitigation</h4>
Expand Down
46 changes: 46 additions & 0 deletions pygoat/introduction/templates/Lab/A11/a11_lab2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% extends "introduction/base.html" %}
{% load static %}
{% block content %}
{% block title %}
<title>Insecure Design Lab</title>
{% endblock %}
{% block header %}

{% endblock %}
<div style="display:flex; flex-direction: row-reverse; align-items:center; justify-content:space-evenly; align-content:center">
<div style="display:flex; flex-direction: column; align-items:center">
<div class="jumbotron">
<h3 style="text-align:center">Safe Bank</h4>
<h4 style="text-align:center">Your Money is not safe</h3>
<div class="login" style="text-align:center">
<h4 style="color:blue">BALANCE: {{balance}}</h4>
<h4 style="color:orangered">Total Withdrawn: {{Total}}</h4>
</div>
<div class="login"style="text-align:center">
<h4 style="text-align:center"></h4>
<div class="login" style="text-align:center">
<form method="post" action="/insecure-design_lab2">
{% csrf_token %}
<input id="input" type="number" name="howMuch" placeholder="0"><br>
<button id="withdraw" style="margin-top:20px" class="btn btn-info" type="submit"> Withdraw </button>
</form>
</div>
</div>
</div>
</div>
</div>

<div class="login"style="text-align:center">
<h4 style="text-align:center"></h4>
<div class="login" style="text-align:center">
<form method="post" action="/insecure-design_lab2">
{% csrf_token %}
<input id="input" type="submit" name="reset" placeholder="0" value="Reset Lab Balance (Use to reset lab)"><br>
</form>
</div>
</div>

<div align="right"> <button class="btn btn-info" type="button" onclick="window.location.href='/insecure-design'">Back to Lab
Details</button></div>

{% endblock %}
Loading