An interactive educational project demonstrating the security differences between HTTP and HTTPS, including live attack simulations and payment interception.
- Node.js v14 or higher
- A terminal / VS Code integrated terminal
npm installopenssl req -x509 -newkey rsa:2048 \
-keyout certs/server.key \
-out certs/server.cert \
-days 365 -nodes \
-subj "/C=IN/ST=Maharashtra/L=Pune/O=Demo/CN=localhost"node server.js| URL | Mode |
|---|---|
| http://localhost:3000 | |
| https://localhost:3443 | 🔒 Secure HTTPS demo |
Note: For HTTPS, your browser will show a "certificate not trusted" warning — this is expected for a self-signed cert. Click "Advanced → Proceed to localhost".
http-https-demo/
├── server.js ← Main Node.js server (HTTP + HTTPS)
├── package.json
├── certs/
│ ├── server.key ← SSL private key
│ └── server.cert ← Self-signed SSL certificate
├── views/
│ ├── http.html ← Insecure HTTP demo page
│ └── https.html ← Secure HTTPS demo page
└── public/
├── css/style.css ← Shared stylesheet
└── js/
├── http.js ← HTTP page logic
└── https.js ← HTTPS page logic
HTTP (Insecure) — http://localhost:3000
- Submit a payment → watch it get intercepted in plaintext in the terminal AND on screen
- The server simulates a MitM attacker:
- Reads full card number, CVV, email from the packet
- Tampers with the payment amount
- Redirects the payment to the "hacker's" account
- Attack buttons simulate:
- Packet sniffing — credentials harvested from raw network traffic
- Session hijacking — cookie stolen, account taken over without password
- DNS spoofing — DNS cache poisoned to redirect users to a fake site
- SSL stripping — HTTPS downgraded to HTTP transparently
HTTPS (Secure) — https://localhost:3443
- TLS Handshake animation — step through all 5 phases of the SSL/TLS negotiation
- Submit a payment → see simulated AES-256-GCM ciphertext (what an attacker intercepts — unreadable)
- Same attacks attempted → each one blocked with explanation
- SSL certificate details displayed
- Active security headers listed (HSTS, CSP, X-Frame-Options, etc.)
| Method | Path | Description |
|---|---|---|
| GET | / |
Serves HTTP or HTTPS page based on connection |
| POST | /pay |
Payment endpoint — simulates attack (HTTP) or secure (HTTPS) |
| GET | /api/intercepted |
Returns log of intercepted HTTP packets |
| GET | /api/secure-log |
Returns log of secure HTTPS transactions |
| GET | /api/attack/:type |
Simulates sniff, session, dns, sslstrip attacks |
| GET | /api/cert-info |
Returns TLS/cipher details (HTTPS only) |
- Open the folder:
File → Open Folder → http-https-demo - Open the integrated terminal:
Ctrl + ``(backtick) - Run
npm installthennode server.js - Click the URLs in the terminal output (Ctrl+Click)
Install the nodemon package for auto-restart on file changes:
npm run dev