How afsh4ck/hacklabs works
Purpose and Entry Points
HackLabs is an intentionally vulnerable ethical-hacking training platform. The primary Flask application is app.py; local initialization runs through init_db.py. Container startup is defined by Dockerfile, entrypoint.sh, and docker-compose.yml; deploy.sh orchestrates LAN-facing deployment and optional Active Directory infrastructure.
Web Application and Lab Engine
app.py is the central control plane: it serves the lab routes, applies session-selected difficulty behavior, exposes intentionally insecure endpoints, validates flags, and manages account state. HTML rendering is organized around shared layout and individual lab views:
• templates/base.html
• templates/index.html
• templates/labs/
The application is deliberately not a secure service; vulnerable request handling is the product behavior and must remain isolated from public networks.
Accounts, Persistence, and Gamified Progress
SQLite persists both lab-facing seed data and registered-user progress. Schema/bootstrap boundaries are:
• database/schema.sql
• init_db.py
• hacklabs.db
Account pages under templates/account/ support registration, login, profile, and reset flows. Progress, XP, achievements, completion toggling, and certificate eligibility are user-account features, distinct from intentionally vulnerable lab users.
Lab Content and Evidence Delivery
Most web labs pair route logic in app.py with a dedicated instructional UI in templates/labs/, covering OWASP, API, authentication, AI, and exploitation scenarios. Static content provides client behavior and intentionally exposed/downloadable artifacts:
• static/js/main.js
• static/files/
• secret/
Digital-forensics labs are data-driven: templates present questions and evidence links, while artifact files are shipped in evidence/forensic/. Evidence generation utilities live in ad_hoc/forensics/.
Active Directory Lab Environment
AD labs are a separate, real Samba AD Domain Controller environment rather than Flask-only simulations. Its compose topology and container build are:
• docker-compose.active-directory.yml
• ad_hoc/active_directory/Dockerfile
• ad_hoc/active_directory/provision.sh
The AD container provisions domain identities, services, ACLs, flags, and attack paths; the web app’s AD templates provide target details and guided instructions. deploy.sh assigns separate network identity/IPs and updates local name resolution needed for Kerberos.
Host/Container Exploitation Scenarios
The primary container intentionally exposes services and host-like artifacts for labs such as SSH, FTP, SMB, LFI, upload, and privilege escalation. Build/runtime definitions are:
• Dockerfile
• docker-compose.yml
• etc/passwd
Container-escape training is deliberately separated into its own dangerous compose scenario:
• docker-compose.docker-escape.yml
• ad_hoc/docker_escape/victim/Dockerfile
• ad_hoc/docker_escape/dind/Dockerfile
Deployment Boundaries and External Tooling
Python/Flask is the main runtime, with SQLite embedded locally. Docker Compose provides isolated lab infrastructure; macvlan-style LAN deployment is handled by deploy.sh. No external cloud service is required. Learners interact using browser and Kali-compatible offensive/forensic tools; the AD environment additionally exposes DNS, Kerberos, LDAP/LDAPS, and SMB.
Main entry points: app.py Flask lab engine · deploy.sh LAN deployment · docker-compose.yml Primary lab container · docker-compose.active-directory.yml Active Directory topology
Components 23
Web Lab Platform
- Flask lab engine · Central routes, vulnerabilities, flags, sessions, and accounts.
app.py - Shared web UI
templates/base.html - Lab catalogue
templates/index.html - Lab instructional views · OWASP, API, authentication, AI, and exploitation lab interfaces.
- Account views · Registration, login, profile, and reset interfaces.
Data & Lab Content
- SQLite schema
database/schema.sql - Database bootstrap
init_db.py - Lab and progress store · Seed lab data and registered-user progress.
hacklabs.db - Client behavior
static/js/main.js - Exposed artifacts · Intentionally downloadable lab artifacts.
- Challenge secrets
- Forensic evidence
- Evidence generators
Isolated Infrastructure
Dangerous lab environments must remain off public networks.
- Primary lab container · Exposes intentionally vulnerable web and host-like services.
docker-compose.yml - Primary lab image
Dockerfile - Host-like accounts
etc/passwd - LAN deployment · Orchestrates LAN addressing and optional AD infrastructure.
deploy.sh - Active Directory topology · Separate Samba AD Domain Controller environment.
docker-compose.active-directory.yml - AD controller image
ad_hoc/active_directory/Dockerfile - AD provisioning · Creates domain identities, services, ACLs, flags, and attack paths.
ad_hoc/active_directory/provision.sh - Container escape scenario · Separately isolated dangerous Docker escape lab.
docker-compose.docker-escape.yml - Escape victim image
ad_hoc/docker_escape/victim/Dockerfile - DinD image
ad_hoc/docker_escape/dind/Dockerfile
Connections 23
- Flask lab engine → Shared web UI: renders
- Flask lab engine → Lab catalogue: renders
- Flask lab engine → Lab instructional views: serves labs through
- Flask lab engine → Account views: serves accounts through
- Flask lab engine → Lab and progress store: stores users and progress
- Flask lab engine → Client behavior: delivers
- Flask lab engine → Exposed artifacts: exposes
- Flask lab engine → Challenge secrets: uses for challenges
- Lab instructional views → Forensic evidence: links evidence
- Evidence generators → Forensic evidence: generates
- SQLite schema → Database bootstrap: applied by
- Database bootstrap → Lab and progress store: creates and seeds
- Primary lab image → Primary lab container: built by
- Host-like accounts → Primary lab image: included in
- Primary lab container → Flask lab engine: runs
- LAN deployment → Primary lab container: deploys
- AD controller image → Active Directory topology: built by
- AD provisioning → AD controller image: provisions
- LAN deployment → Active Directory topology: deploys with network identity
- Lab instructional views → Active Directory topology: guides learners to
- Escape victim image → Container escape scenario: built by
- DinD image → Container escape scenario: built by
- LAN deployment → Container escape scenario: kept separate from