Skip to content

Commit

Permalink
Ready for running with docker
Browse files Browse the repository at this point in the history
solanav committed Dec 31, 2023
1 parent c30e298 commit 038f861
Showing 12 changed files with 66 additions and 29 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ PhishFlood is a python tool that uses playwright to automate the process of fill

## Demo

Example gif:
![](./output.gif)
Example page interaction:
![](images/output.gif)

Example output:
```json
@@ -111,10 +111,17 @@ PhishFlood will launch a Playwright browser instance in the background and start
To start the API and all required componets (RabbitMQ, PostgreSQL and the workers) you can run:

```bash
docker compose -f docker/docker-compose.yml up --build
docker compose -f docker/docker-compose.yml --compatibility up --build
```

The API will be running in `localhost:8000` and you can start exploring the different endpoints through the web UI.
The API will be running in `localhost:8000` and you can start exploring the different endpoints through the web UI:

![Alt text](images/api_root.png)

And here is a sample of one of the endpoints

![Alt text](images/action_list.png)


## Testing

1 change: 1 addition & 0 deletions api/settings.py
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "static"

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
5 changes: 3 additions & 2 deletions api/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.contrib import admin
from django.urls import include, path
from rest_framework import routers

from api import settings
from phishings import views
from django.conf.urls.static import static

router = routers.DefaultRouter()

@@ -23,6 +24,6 @@
path("", include(router.urls)),
path("admin/", admin.site.urls),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
]
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

urlpatterns += router.urls
20 changes: 20 additions & 0 deletions config/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
client_max_body_size 30m;

upstream phishflood {
server api:8000;
}

server {
listen 80;

location /static/ {
alias /home/nonroot/api/static/;
}

location / {
proxy_pass http://phishflood;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
4 changes: 4 additions & 0 deletions docker/Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx

RUN rm /etc/nginx/conf.d/default.conf
COPY ./config/nginx.conf /etc/nginx/conf.d
2 changes: 1 addition & 1 deletion docker/Dockerfile.worker
Original file line number Diff line number Diff line change
@@ -40,4 +40,4 @@ RUN poetry run playwright install
COPY --chown=nonroot:nonroot . /home/nonroot/$PROJECT_NAME

# Entrypoint
CMD poetry run python -m phishflood
CMD poetry run python -m phishflood worker
44 changes: 24 additions & 20 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
version: '3.8'

services:
# api:
# image: phishflood-api:latest
# build:
# context: ../
# dockerfile: docker/Dockerfile.api
# depends_on:
# - rabbitmq
# - psql
api:
image: phishflood-api:latest
build:
context: ../
dockerfile: docker/Dockerfile.api
depends_on:
- rabbitmq
- psql
ports:
- "127.0.0.1:8000:8000"

# worker:
# image: phishflood-worker:latest
# build:
# context: ../
# dockerfile: docker/Dockerfile.worker
# cap_add:
# - NET_ADMIN
# devices:
# - /dev/net/tun
# depends_on:
# - rabbitmq
# - psql
worker:
image: phishflood-worker:latest
build:
context: ../
dockerfile: docker/Dockerfile.worker
deploy:
replicas: 6
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
depends_on:
- rabbitmq
- psql

rabbitmq:
image: rabbitmq:3-management-alpine
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -13,4 +13,4 @@ echo "Creating admin user..."
echo "from django.contrib.auth.models import User; User.objects.filter(email='admin@phishflood.com').delete(); User.objects.create_superuser('admin', 'admin@phishflood.com', 'phishflood')" | poetry run python manage.py shell

echo "Runnning gunicorn..."
poetry run gunicorn phishing_analyzer.wsgi:application -w 8 --bind 0.0.0.0:8000
poetry run gunicorn api.wsgi:application -w 8 --bind 0.0.0.0:8000
Binary file added images/action_list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/api_root.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
2 changes: 1 addition & 1 deletion phishings/models.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ class Phishing(models.Model):
id = models.CharField(
max_length=255, primary_key=True, default=None, editable=False
)
url = models.URLField()
url = models.URLField(max_length=512)
created_at = models.DateTimeField(auto_now_add=True)

def save(self, *args, **kwargs):

0 comments on commit 038f861

Please sign in to comment.