Skip to content
einyePublic

About

A lightweight platform for running phishing‑simulation campaigns locally. Create and manage campaigns and targets, track metrics and view results through a simple admin dashboard.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

Repository files navigation

Phishsim

Overview

Phishsim is a lightweight phishing simulation platform built with Node.js and Express. It provides a simple API for creating campaigns, managing targets, tracking user interactions (opens, clicks, form submissions), and exporting campaign metrics. The service can be run locally for security‑training exercises, allowing teams to evaluate how effectively their users recognize and respond to phishing attempts.

Tech Stack & Structure

Layer Technology / Dependency Notes
Runtime Node ≥ 14 (JavaScript) Executed via node src/server.js
Web framework express (^5.2.1) Handles routing, JSON body parsing and static assets
Templating handlebars (^4.7.8) Server‑side rendering of .hbs views (e.g., education page)
Database better-sqlite3 (^11.10.0) Embedded SQLite database (data/db.sqlite)
Email nodemailer (^7.0.12) Used by src/services/mailer.js
Config dotenv (^17.2.3) Loads environment variables from .env
Containerisation (optional) Docker & docker‑compose docker-compose.yml and docker/Dockerfile are provided

Folder / File Overview

Phishsim/
├─ .env                     # Environment variables (see “Getting Started”)
├─ .gitignore / .dockerignore
├─ docker/
│   └─ Dockerfile           # Build image for the app
├─ docker-compose.yml       # Docker compose definition (service ports, db volume)
├─ data/
│   └─ db.sqlite            # SQLite file created at runtime
├─ src/
│   ├─ app.js               # Express app configuration, route mounting, view engine
│   ├─ server.js            # Entry point – loads env, runs migrations, starts HTTP server
│   ├─ db/
│   │   ├─ connection.js    # Creates SQLite connection, ensures DB folder exists
│   │   └─ migrations.js    # Creates tables & migrates legacy schema
│   ├─ repos/               # Data‑access layer (campaignRepo, eventRepo, …)
│   ├─ routes/              # API routes:
│   │   ├─ admin.js
│   │   ├─ campaignLifecycle.js   # Activate / complete campaigns
│   │   ├─ campaigns.js            # CRUD + stats endpoints
│   │   ├─ demo.js
│   │   ├─ export.js
│   │   ├─ targets.js
│   │   ├─ track.js
│   ├─ services/
│   │   ├─ hash.js
│   │   └─ mailer.js
│   └─ views/               # Handlebars templates (admin, education, …)
├─ package.json
└─ package-lock.json

Getting Started

Prerequisites

  • Node.js (LTS) and npm - install from https://nodejs.org/.
  • Git (optional, for cloning the repo).
  • SQLite support - bundled with better-sqlite3; no external server required.
  • (Optional) Docker Desktop if you prefer containerised execution.

Installation

# Clone the repo
git clone https://github.com/einye/Phishsim
cd Phishsim

Configuration

Copy the provided .env file or edit it to suit your environment. Required variables (present in the repo) are:

Variable Description Example
PORT HTTP port the app listens on 3000
NODE_ENV Runtime mode (development   production)
APP_BASE_URL Base URL used by generated links http://localhost:3000
DATABASE_FILE SQLite file location (relative to project root) ./data/db.sqlite
SMTP_HOST Host for outgoing mail (used by the mailer service) mailhog
SMTP_PORT Port for the SMTP server 1025
SMTP_SECURE true   false – TLS usage
ALLOWED_EMAIL_DOMAINS Comma‑separated list of domains accepted for target emails example.com, internal.test
HASH_ALGO Hash algorithm for token generation sha256

Running the Application

# Build and start all services (including the app and Mailhog)
docker compose up --build

After the containers are up you can access:

Tests

The repository includes a placeholder npm test script that currently only echoes an error. No automated tests are provided.

npm test   # → currently not implemented

Usage

The service exposes a JSON API under the /api path. Below are a few common operations (replace localhost:3000 with your configured host/port).

Health Check

GET http://localhost:3000/

Response: PhishLab Infrastructure is running.

Create a Campaign

POST http://localhost:3000/api/campaigns
Content-Type: application/json

{
  "name": "Q4 Phishing Test",
  "from_name": "Security Team",
  "from_email": "security@example.com",
  "template_name": "generic_phish"
}

Response (201): campaign object with generated id.

List All Campaigns

GET http://localhost:3000/api/campaigns

Activate / Complete a Campaign

POST http://localhost:3000/api/campaigns/<campaignId>/activate
POST http://localhost:3000/api/campaigns/<campaignId>/complete

Each returns { "status": "active" } or { "status": "completed" }.

Get Campaign Statistics

GET http://localhost:3000/api/campaigns/<campaignId>/stats

Returns a JSON payload with:

  • targets – total number of targets
  • metrics – counts of opens, clicks, form views, submissions, unique targets interacted
  • rates – derived open‑to‑submit and form‑to‑submit ratios

Education Page

Render a simple page (used after a demo) with optional query parameters:

GET http://localhost:3000/education?message=Thanks&submitted=1&email=user@example.com

The page uses the education.hbs Handlebars template.

Limitations & Known Issues

Issue Description
No authentication All API endpoints are publicly accessible; production usage requires adding auth middleware.
Placeholder test script npm test currently fails; no automated testing suite.
SMTP configuration Only basic host/port variables are defined; credentials or TLS settings are missing.
Static assets The /static folder is referenced but not included – serving CSS/JS will result in 404.
Missing documentation No Swagger/OpenAPI spec; developers must rely on reading source files.
Limited error handling Many routes return generic 400/404 without detailed validation.
Docker compose details docker-compose.yml exists but its services/volumes are not described here.
Token generation Hash algorithm is configurable, but the actual token creation logic in services/hash.js is not examined – verify it matches security expectations.
Database migrations are synchronous runMigrations runs synchronously on start; long‑running migrations could block server startup.
No UI for admin routes Admin Handlebars templates are present (admin-index.hbs, admin-campaign.hbs) but the corresponding route handlers are not inspected here.

About

A lightweight platform for running phishing‑simulation campaigns locally. Create and manage campaigns and targets, track metrics and view results through a simple admin dashboard.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages