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.
| 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) |
| 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 |
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
- 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.
# Clone the repo
git clone https://github.com/einye/Phishsim
cd PhishsimCopy 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 |
# Build and start all services (including the app and Mailhog)
docker compose up --buildAfter the containers are up you can access:
- The Phishsim admin dashboard at http://localhost:3000/admin
- Mailhog UI at http://localhost:8025/
The repository includes a placeholder npm test script that currently only echoes an error. No automated tests are provided.
npm test # → currently not implementedThe service exposes a JSON API under the /api path. Below are a few common operations (replace localhost:3000 with your configured host/port).
GET http://localhost:3000/Response: PhishLab Infrastructure is running.
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.
GET http://localhost:3000/api/campaignsPOST http://localhost:3000/api/campaigns/<campaignId>/activate
POST http://localhost:3000/api/campaigns/<campaignId>/completeEach returns { "status": "active" } or { "status": "completed" }.
GET http://localhost:3000/api/campaigns/<campaignId>/statsReturns a JSON payload with:
targets– total number of targetsmetrics– counts of opens, clicks, form views, submissions, unique targets interactedrates– derived open‑to‑submit and form‑to‑submit ratios
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.
| 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. |