Looks like it kinda works.
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
# Git
|
|
||||||
.git
|
|
||||||
.gitignore
|
|
||||||
|
|
||||||
# Python
|
|
||||||
__pycache__/
|
|
||||||
*.py[cod]
|
|
||||||
venv/
|
|
||||||
|
|
||||||
# IDE
|
|
||||||
.vscode/
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
# Uploads
|
|
||||||
uploads/*
|
|
||||||
|
|
||||||
# Docs
|
|
||||||
README.md
|
|
||||||
|
|
||||||
# Docker
|
|
||||||
Dockerfile
|
|
||||||
docker-compose.yml
|
|
||||||
.dockerignore
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
FROM python:3.11-slim
|
|
||||||
|
|
||||||
# Set environment variables
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
|
||||||
|
|
||||||
# Set work directory
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Install system dependencies
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
gcc \
|
|
||||||
libc-dev \
|
|
||||||
libffi-dev \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Install Python dependencies
|
|
||||||
|
|
||||||
COPY requirements.txt .
|
|
||||||
#COPY requirements-ml.txt .
|
|
||||||
|
|
||||||
RUN pip install --upgrade pip
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt --root-user-action=ignore
|
|
||||||
#RUN pip install --no-cache-dir -r requirements-ml.txt
|
|
||||||
|
|
||||||
# Copy application
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Create upload directory
|
|
||||||
RUN mkdir -p /tmp/stego_uploads
|
|
||||||
|
|
||||||
# Create non-root user for security
|
|
||||||
RUN useradd -m -u 1000 stego && chown -R stego:stego /app /tmp/stego_uploads
|
|
||||||
USER stego
|
|
||||||
|
|
||||||
# Expose port
|
|
||||||
EXPOSE 5000
|
|
||||||
|
|
||||||
# Health check
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
||||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5000/')" || exit 1
|
|
||||||
|
|
||||||
# Run with gunicorn in production
|
|
||||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "--threads", "4", "--timeout", "60", "app:app"]
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
# Stegasoo Web Service
|
|
||||||
|
|
||||||
A containerized Flask + Bootstrap web UI for hybrid Photo + Day-Phrase + PIN steganography.
|
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- 🔐 **AES-256-GCM** authenticated encryption
|
|
||||||
- 🧠 **Argon2id** memory-hard key derivation (256MB)
|
|
||||||
- 🎲 **Pseudo-random pixel selection** defeats steganalysis
|
|
||||||
- 📅 **Daily key rotation** with customizable phrases (3-12 words)
|
|
||||||
- 🔢 **Static PIN** for additional entropy (6-8 digits)
|
|
||||||
- 🖼️ **Reference photo** as "something you have"
|
|
||||||
- 🌐 **Web UI** with Bootstrap 5 dark theme
|
|
||||||
- 📖 **Memory aid stories** to help memorize phrases (template or AI-powered)
|
|
||||||
|
|
||||||
## Quick Start
|
|
||||||
|
|
||||||
### Docker (Recommended)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Build and run
|
|
||||||
docker-compose up -d
|
|
||||||
|
|
||||||
# Access at http://localhost:5000
|
|
||||||
```
|
|
||||||
|
|
||||||
### Manual Installation
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Create virtual environment
|
|
||||||
python -m venv venv
|
|
||||||
source venv/bin/activate # Linux/Mac
|
|
||||||
# or: venv\Scripts\activate # Windows
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
# Optional: Enable AI-powered story generation
|
|
||||||
pip install -r requirements-ml.txt
|
|
||||||
|
|
||||||
# Run development server
|
|
||||||
python app.py
|
|
||||||
|
|
||||||
# Or production with gunicorn
|
|
||||||
gunicorn --bind 0.0.0.0:5000 app:app
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### 1. Generate Credentials
|
|
||||||
|
|
||||||
Visit `/generate` to create:
|
|
||||||
- **7 phrases** (one per day of week, 3-12 words each)
|
|
||||||
- **1 PIN** (6-8 digits, same every day)
|
|
||||||
- **Memory aid stories** (optional, helps memorize phrases)
|
|
||||||
|
|
||||||
Memorize these! Don't save them.
|
|
||||||
|
|
||||||
### 2. Encode a Message
|
|
||||||
|
|
||||||
Visit `/encode` and provide:
|
|
||||||
- **Reference photo** - A photo both parties have (NOT transmitted)
|
|
||||||
- **Carrier image** - The image to hide your message in
|
|
||||||
- **Message** - Your secret text
|
|
||||||
- **Day phrase** - Today's phrase
|
|
||||||
- **PIN** - Your static PIN
|
|
||||||
|
|
||||||
Download the stego image and share it through any channel.
|
|
||||||
|
|
||||||
### 3. Decode a Message
|
|
||||||
|
|
||||||
Visit `/decode` and provide:
|
|
||||||
- **Reference photo** - Same photo used for encoding
|
|
||||||
- **Stego image** - The image containing the hidden message
|
|
||||||
- **Day phrase** - The phrase for the day it was encoded
|
|
||||||
- **PIN** - Your static PIN
|
|
||||||
|
|
||||||
## Security Model
|
|
||||||
|
|
||||||
| Component | Entropy | Purpose |
|
|
||||||
|-----------|---------|---------|
|
|
||||||
| Reference Photo | ~80-256 bits | Something you have |
|
|
||||||
| Day Phrase | ~33-132 bits | Something you know (rotates daily) |
|
|
||||||
| PIN | ~20-27 bits | Something you know (static) |
|
|
||||||
| **Combined** | **133-415+ bits** | **Beyond brute force** |
|
|
||||||
|
|
||||||
### Attack Resistance
|
|
||||||
|
|
||||||
| Attack | Result |
|
|
||||||
|--------|--------|
|
|
||||||
| Brute force | 2^133+ combinations = impossible |
|
|
||||||
| Rainbow tables | Random salt per message |
|
|
||||||
| Steganalysis | Random pixel selection defeats detection |
|
|
||||||
| GPU cracking | Argon2 requires 256MB RAM per attempt |
|
|
||||||
|
|
||||||
## Memory Aid Stories
|
|
||||||
|
|
||||||
The generate page can create stories to help you memorize your phrases:
|
|
||||||
|
|
||||||
**Template-based** (default):
|
|
||||||
> Monday morning began when I discovered a **APPLE** near the **FOREST**. I had to **THUNDER** quickly, then grab the **CRYSTAL** before reaching the **BRAVE**.
|
|
||||||
|
|
||||||
**AI-powered** (with `requirements-ml.txt`):
|
|
||||||
- Uses DistilGPT-2 (~350MB model)
|
|
||||||
- Generates more coherent, natural stories
|
|
||||||
- Words highlighted in RED CAPS
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
Environment variables:
|
|
||||||
|
|
||||||
| Variable | Default | Description |
|
|
||||||
|----------|---------|-------------|
|
|
||||||
| `FLASK_ENV` | production | Flask environment |
|
|
||||||
| `SECRET_KEY` | random | Session secret (auto-generated) |
|
|
||||||
|
|
||||||
## Production Deployment
|
|
||||||
|
|
||||||
For production, consider:
|
|
||||||
|
|
||||||
1. **HTTPS** - Use nginx reverse proxy with SSL
|
|
||||||
2. **Rate limiting** - Prevent abuse
|
|
||||||
3. **Logging** - Monitor for security events
|
|
||||||
4. **Memory** - Allocate at least 512MB (Argon2 needs 256MB)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT License - Use responsibly.
|
|
||||||
|
|
||||||
## ⚠️ Disclaimer
|
|
||||||
|
|
||||||
This tool is for educational and legitimate privacy purposes only. Users are responsible for complying with applicable laws in their jurisdiction.
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
# Stegasoo Web Service
|
|
||||||
|
|
||||||
A containerized Flask + Bootstrap web UI for hybrid Photo + Day-Phrase + PIN steganography.
|
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- 🔐 **AES-256-GCM** authenticated encryption
|
|
||||||
- 🧠 **Argon2id** memory-hard key derivation (256MB)
|
|
||||||
- 🎲 **Pseudo-random pixel selection** defeats steganalysis
|
|
||||||
- 📅 **Daily key rotation** with 3-word phrases
|
|
||||||
- 🔢 **Static PIN** for additional entropy
|
|
||||||
- 🖼️ **Reference photo** as "something you have"
|
|
||||||
- 🌐 **Web UI** with Bootstrap 5 dark theme
|
|
||||||
|
|
||||||
## Quick Start
|
|
||||||
|
|
||||||
### Docker (Recommended)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Build and run
|
|
||||||
docker-compose up -d
|
|
||||||
|
|
||||||
# Access at http://localhost:5000
|
|
||||||
```
|
|
||||||
|
|
||||||
### Manual Installation
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Create virtual environment
|
|
||||||
python -m venv venv
|
|
||||||
source venv/bin/activate # Linux/Mac
|
|
||||||
# or: venv\Scripts\activate # Windows
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
# Run development server
|
|
||||||
python app.py
|
|
||||||
|
|
||||||
# Or production with gunicorn
|
|
||||||
gunicorn --bind 0.0.0.0:5000 app:app
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### 1. Generate Credentials
|
|
||||||
|
|
||||||
Visit `/generate` to create:
|
|
||||||
- **7 three-word phrases** (one per day of week)
|
|
||||||
- **1 six-digit PIN** (same every day)
|
|
||||||
|
|
||||||
Memorize these! Don't save them.
|
|
||||||
|
|
||||||
### 2. Encode a Message
|
|
||||||
|
|
||||||
Visit `/encode` and provide:
|
|
||||||
- **Reference photo** - A photo both parties have (NOT transmitted)
|
|
||||||
- **Carrier image** - The image to hide your message in
|
|
||||||
- **Message** - Your secret text
|
|
||||||
- **Day phrase** - Today's 3-word phrase
|
|
||||||
- **PIN** - Your static 6-digit PIN
|
|
||||||
|
|
||||||
Download the stego image and share it through any channel.
|
|
||||||
|
|
||||||
### 3. Decode a Message
|
|
||||||
|
|
||||||
Visit `/decode` and provide:
|
|
||||||
- **Reference photo** - Same photo used for encoding
|
|
||||||
- **Stego image** - The image containing the hidden message
|
|
||||||
- **Day phrase** - The phrase for the day it was encoded
|
|
||||||
- **PIN** - Your static PIN
|
|
||||||
|
|
||||||
## Security Model
|
|
||||||
|
|
||||||
| Component | Entropy | Purpose |
|
|
||||||
|-----------|---------|---------|
|
|
||||||
| Reference Photo | ~80-256 bits | Something you have |
|
|
||||||
| 3-Word Phrase | ~33 bits | Something you know (rotates daily) |
|
|
||||||
| 6-Digit PIN | ~20 bits | Something you know (static) |
|
|
||||||
| **Combined** | **133+ bits** | **Beyond brute force** |
|
|
||||||
|
|
||||||
### Attack Resistance
|
|
||||||
|
|
||||||
| Attack | Result |
|
|
||||||
|--------|--------|
|
|
||||||
| Brute force | 2^133 combinations = impossible |
|
|
||||||
| Rainbow tables | Random salt per message |
|
|
||||||
| Steganalysis | Random pixel selection defeats detection |
|
|
||||||
| GPU cracking | Argon2 requires 256MB RAM per attempt |
|
|
||||||
|
|
||||||
## API Endpoints
|
|
||||||
|
|
||||||
| Endpoint | Method | Description |
|
|
||||||
|----------|--------|-------------|
|
|
||||||
| `/` | GET | Home page |
|
|
||||||
| `/generate` | GET/POST | Generate phrase card + PIN |
|
|
||||||
| `/encode` | GET/POST | Encode message in image |
|
|
||||||
| `/decode` | GET/POST | Decode message from image |
|
|
||||||
| `/about` | GET | Security information |
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
Environment variables:
|
|
||||||
|
|
||||||
| Variable | Default | Description |
|
|
||||||
|----------|---------|-------------|
|
|
||||||
| `FLASK_ENV` | production | Flask environment |
|
|
||||||
| `SECRET_KEY` | random | Session secret (auto-generated) |
|
|
||||||
|
|
||||||
## Production Deployment
|
|
||||||
|
|
||||||
For production, consider:
|
|
||||||
|
|
||||||
1. **HTTPS** - Use nginx reverse proxy with SSL
|
|
||||||
2. **Rate limiting** - Prevent abuse
|
|
||||||
3. **Logging** - Monitor for security events
|
|
||||||
4. **Memory** - Allocate at least 512MB (Argon2 needs 256MB)
|
|
||||||
|
|
||||||
Example nginx config:
|
|
||||||
|
|
||||||
```nginx
|
|
||||||
server {
|
|
||||||
listen 443 ssl;
|
|
||||||
server_name stegocrypt.example.com;
|
|
||||||
|
|
||||||
ssl_certificate /path/to/cert.pem;
|
|
||||||
ssl_certificate_key /path/to/key.pem;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://stegocrypt:5000;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
client_max_body_size 50M;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT License - Use responsibly.
|
|
||||||
|
|
||||||
## ⚠️ Disclaimer
|
|
||||||
|
|
||||||
This tool is for educational and legitimate privacy purposes only. Users are responsible for complying with applicable laws in their jurisdiction.
|
|
||||||
@@ -1,900 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
Stegasoo: Steganography portal for security-minded messaging.
|
|
||||||
|
|
||||||
Aaron D. Lee (w/ vibes)
|
|
||||||
2025-12-27
|
|
||||||
|
|
||||||
Built as a learning experience with a few LLMs to see if I can make something decent.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
import io
|
|
||||||
import re
|
|
||||||
import secrets
|
|
||||||
import hashlib
|
|
||||||
import struct
|
|
||||||
import time
|
|
||||||
from datetime import datetime
|
|
||||||
from flask import Flask, render_template, request, send_file, jsonify, flash, redirect, url_for
|
|
||||||
from werkzeug.utils import secure_filename
|
|
||||||
from PIL import Image
|
|
||||||
from secureDeleter import SecureDeleter
|
|
||||||
|
|
||||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|
||||||
from cryptography.hazmat.backends import default_backend
|
|
||||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
||||||
from cryptography.hazmat.primitives import serialization
|
|
||||||
from cryptography.hazmat.primitives.serialization import load_pem_private_key
|
|
||||||
|
|
||||||
try:
|
|
||||||
from argon2.low_level import hash_secret_raw, Type
|
|
||||||
HAS_ARGON2 = True
|
|
||||||
except ImportError:
|
|
||||||
HAS_ARGON2 = False
|
|
||||||
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
|
||||||
from cryptography.hazmat.primitives import hashes
|
|
||||||
|
|
||||||
HAS_ML = False # Story generator disabled
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# FLASK APP CONFIGURATION
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
app.secret_key = secrets.token_hex(32)
|
|
||||||
app.config['MAX_CONTENT_LENGTH'] = 5 * 1024 * 1024 # 5MB max upload per file
|
|
||||||
app.config['UPLOAD_FOLDER'] = '/tmp/stego_uploads'
|
|
||||||
|
|
||||||
# Limits
|
|
||||||
MAX_IMAGE_PIXELS = 4000000 # 4 megapixels max (e.g., 2000x2000)
|
|
||||||
MAX_MESSAGE_SIZE = 50000 # 50KB message max
|
|
||||||
MIN_PIN_LENGTH = 6
|
|
||||||
MAX_PIN_LENGTH = 9
|
|
||||||
MIN_RSA_BITS = 2048
|
|
||||||
VALID_RSA_SIZES = [2048, 3072, 4096]
|
|
||||||
|
|
||||||
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
|
||||||
|
|
||||||
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'bmp', 'gif'}
|
|
||||||
|
|
||||||
# Temporary file storage for sharing (file_id -> {data, timestamp, filename})
|
|
||||||
TEMP_FILES = {}
|
|
||||||
TEMP_FILE_EXPIRY = 300 # 5 minutes
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# CRYPTO CONFIGURATION
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
MAGIC_HEADER = b'\x89ST3'
|
|
||||||
VERSION = 3
|
|
||||||
SALT_SIZE = 32
|
|
||||||
IV_SIZE = 12
|
|
||||||
TAG_SIZE = 16
|
|
||||||
ARGON2_TIME_COST = 4
|
|
||||||
ARGON2_MEMORY_COST = 256 * 1024
|
|
||||||
ARGON2_PARALLELISM = 4
|
|
||||||
|
|
||||||
DAY_NAMES = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
|
||||||
|
|
||||||
# BIP-39 wordlist (loaded from file)
|
|
||||||
BIP39_FILE = os.path.join(os.path.dirname(__file__), 'bip39-words.txt')
|
|
||||||
with open(BIP39_FILE, 'r') as f:
|
|
||||||
BIP39_WORDS = [line.strip() for line in f if line.strip()]
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# SECURE CLEANUP
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
def secure_cleanup_uploads():
|
|
||||||
"""Securely delete any stray files in uploads directory."""
|
|
||||||
upload_dir = app.config['UPLOAD_FOLDER']
|
|
||||||
if os.path.exists(upload_dir):
|
|
||||||
for filename in os.listdir(upload_dir):
|
|
||||||
filepath = os.path.join(upload_dir, filename)
|
|
||||||
if os.path.isfile(filepath) and not filename.startswith('.'):
|
|
||||||
try:
|
|
||||||
deleter = SecureDeleter(filepath)
|
|
||||||
deleter.execute()
|
|
||||||
except Exception as e:
|
|
||||||
os.remove(filepath)
|
|
||||||
|
|
||||||
|
|
||||||
def cleanup_temp_files():
|
|
||||||
"""Remove expired temporary files."""
|
|
||||||
now = time.time()
|
|
||||||
expired = [fid for fid, info in TEMP_FILES.items() if now - info['timestamp'] > TEMP_FILE_EXPIRY]
|
|
||||||
for fid in expired:
|
|
||||||
TEMP_FILES.pop(fid, None)
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# VALIDATION FUNCTIONS
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
def allowed_file(filename):
|
|
||||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
|
||||||
|
|
||||||
|
|
||||||
def validate_pin(pin):
|
|
||||||
"""Validate PIN format: 6-9 digits, no leading zeros."""
|
|
||||||
if not pin:
|
|
||||||
return True, "" # Empty PIN is valid (if RSA key provided)
|
|
||||||
if not pin.isdigit():
|
|
||||||
return False, "PIN must contain only digits"
|
|
||||||
if len(pin) < MIN_PIN_LENGTH or len(pin) > MAX_PIN_LENGTH:
|
|
||||||
return False, f"PIN must be {MIN_PIN_LENGTH}-{MAX_PIN_LENGTH} digits"
|
|
||||||
if pin[0] == '0':
|
|
||||||
return False, "PIN cannot start with zero"
|
|
||||||
return True, ""
|
|
||||||
|
|
||||||
|
|
||||||
def validate_message(message):
|
|
||||||
"""Validate message size."""
|
|
||||||
if not message:
|
|
||||||
return False, "Message is required"
|
|
||||||
if len(message) > MAX_MESSAGE_SIZE:
|
|
||||||
return False, f"Message too long. Max {MAX_MESSAGE_SIZE // 1000}KB allowed"
|
|
||||||
return True, ""
|
|
||||||
|
|
||||||
|
|
||||||
def validate_image(image_data, name="Image"):
|
|
||||||
"""Validate image data and dimensions."""
|
|
||||||
try:
|
|
||||||
img = Image.open(io.BytesIO(image_data))
|
|
||||||
width, height = img.size
|
|
||||||
num_pixels = width * height
|
|
||||||
|
|
||||||
if num_pixels > MAX_IMAGE_PIXELS:
|
|
||||||
max_dim = int(MAX_IMAGE_PIXELS ** 0.5)
|
|
||||||
return False, f"{name} too large ({width}x{height} = {num_pixels:,} pixels). Max ~{MAX_IMAGE_PIXELS:,} pixels ({max_dim}x{max_dim})"
|
|
||||||
return True, ""
|
|
||||||
except Exception as e:
|
|
||||||
return False, f"Could not read {name}: {str(e)}"
|
|
||||||
|
|
||||||
|
|
||||||
def validate_rsa_key(key_data, password=None):
|
|
||||||
"""
|
|
||||||
Validate RSA private key.
|
|
||||||
Returns (is_valid, error_message, key_size_bits)
|
|
||||||
"""
|
|
||||||
if not key_data:
|
|
||||||
return True, "", 0 # Empty key is valid (if PIN provided)
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Try to load the key
|
|
||||||
if password:
|
|
||||||
private_key = load_pem_private_key(key_data, password=password.encode(), backend=default_backend())
|
|
||||||
else:
|
|
||||||
# Try without password first
|
|
||||||
try:
|
|
||||||
private_key = load_pem_private_key(key_data, password=None, backend=default_backend())
|
|
||||||
except TypeError:
|
|
||||||
# Key is encrypted but no password provided
|
|
||||||
return False, "RSA key is password-protected. Please enter the password.", 0
|
|
||||||
|
|
||||||
# Check key size
|
|
||||||
key_size = private_key.key_size
|
|
||||||
if key_size < MIN_RSA_BITS:
|
|
||||||
return False, f"RSA key must be at least {MIN_RSA_BITS} bits (got {key_size})", 0
|
|
||||||
|
|
||||||
return True, "", key_size
|
|
||||||
|
|
||||||
except ValueError as e:
|
|
||||||
if "password" in str(e).lower() or "encrypted" in str(e).lower():
|
|
||||||
return False, "Incorrect password for RSA key", 0
|
|
||||||
return False, f"Invalid RSA key format: {str(e)}", 0
|
|
||||||
except Exception as e:
|
|
||||||
return False, f"Could not load RSA key: {str(e)}", 0
|
|
||||||
|
|
||||||
|
|
||||||
def validate_security_factors(pin, rsa_key_data):
|
|
||||||
"""Ensure at least one security factor is provided."""
|
|
||||||
has_pin = bool(pin and pin.strip())
|
|
||||||
has_key = bool(rsa_key_data and len(rsa_key_data) > 0)
|
|
||||||
|
|
||||||
if not has_pin and not has_key:
|
|
||||||
return False, "You must provide at least a PIN or RSA Key"
|
|
||||||
return True, ""
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# RSA KEY GENERATION
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
def generate_rsa_key(bits=2048):
|
|
||||||
"""Generate RSA private key."""
|
|
||||||
if bits not in VALID_RSA_SIZES:
|
|
||||||
bits = 2048
|
|
||||||
|
|
||||||
private_key = rsa.generate_private_key(
|
|
||||||
public_exponent=65537,
|
|
||||||
key_size=bits,
|
|
||||||
backend=default_backend()
|
|
||||||
)
|
|
||||||
return private_key
|
|
||||||
|
|
||||||
|
|
||||||
def export_rsa_key_pem(private_key, password=None):
|
|
||||||
"""Export RSA key to PEM format, optionally encrypted."""
|
|
||||||
if password:
|
|
||||||
encryption = serialization.BestAvailableEncryption(password.encode())
|
|
||||||
else:
|
|
||||||
encryption = serialization.NoEncryption()
|
|
||||||
|
|
||||||
pem = private_key.private_bytes(
|
|
||||||
encoding=serialization.Encoding.PEM,
|
|
||||||
format=serialization.PrivateFormat.PKCS8,
|
|
||||||
encryption_algorithm=encryption
|
|
||||||
)
|
|
||||||
return pem
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# HELPER FUNCTIONS
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
def generate_pin(length=6):
|
|
||||||
"""Generate a random PIN of specified length (6-9 digits)."""
|
|
||||||
length = max(MIN_PIN_LENGTH, min(MAX_PIN_LENGTH, length))
|
|
||||||
first_digit = str(secrets.randbelow(9) + 1) # 1-9
|
|
||||||
rest = ''.join(str(secrets.randbelow(10)) for _ in range(length - 1))
|
|
||||||
return first_digit + rest
|
|
||||||
|
|
||||||
|
|
||||||
def generate_day_phrases(words_per_phrase=3):
|
|
||||||
phrases = {}
|
|
||||||
for day in DAY_NAMES:
|
|
||||||
words = [secrets.choice(BIP39_WORDS) for _ in range(words_per_phrase)]
|
|
||||||
phrases[day] = ' '.join(words)
|
|
||||||
return phrases
|
|
||||||
|
|
||||||
|
|
||||||
def hash_photo(image_data):
|
|
||||||
"""Compute deterministic hash of photo content."""
|
|
||||||
img = Image.open(io.BytesIO(image_data))
|
|
||||||
img = img.convert('RGB')
|
|
||||||
pixels = img.tobytes()
|
|
||||||
h = hashlib.sha256(pixels).digest()
|
|
||||||
h = hashlib.sha256(h + pixels[:1024]).digest()
|
|
||||||
return h
|
|
||||||
|
|
||||||
|
|
||||||
def derive_hybrid_key(photo_data, day_phrase, date_str, salt, pin="", rsa_key_data=None):
|
|
||||||
"""Derive encryption key from photo + phrase + PIN + RSA key + date + salt."""
|
|
||||||
photo_hash = hash_photo(photo_data)
|
|
||||||
|
|
||||||
key_material = (
|
|
||||||
photo_hash +
|
|
||||||
day_phrase.lower().encode() +
|
|
||||||
pin.encode() +
|
|
||||||
date_str.encode() +
|
|
||||||
salt
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add RSA key hash if provided
|
|
||||||
if rsa_key_data:
|
|
||||||
key_material += hashlib.sha256(rsa_key_data).digest()
|
|
||||||
|
|
||||||
if HAS_ARGON2:
|
|
||||||
key = hash_secret_raw(
|
|
||||||
secret=key_material,
|
|
||||||
salt=salt[:32],
|
|
||||||
time_cost=ARGON2_TIME_COST,
|
|
||||||
memory_cost=ARGON2_MEMORY_COST,
|
|
||||||
parallelism=ARGON2_PARALLELISM,
|
|
||||||
hash_len=32,
|
|
||||||
type=Type.ID
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
kdf = PBKDF2HMAC(
|
|
||||||
algorithm=hashes.SHA512(),
|
|
||||||
length=32,
|
|
||||||
salt=salt,
|
|
||||||
iterations=600000,
|
|
||||||
backend=default_backend()
|
|
||||||
)
|
|
||||||
key = kdf.derive(key_material)
|
|
||||||
|
|
||||||
return key
|
|
||||||
|
|
||||||
|
|
||||||
def derive_pixel_key(photo_data, day_phrase, date_str, pin="", rsa_key_data=None):
|
|
||||||
"""Derive key for pixel selection."""
|
|
||||||
photo_hash = hash_photo(photo_data)
|
|
||||||
material = photo_hash + day_phrase.lower().encode() + pin.encode() + date_str.encode()
|
|
||||||
|
|
||||||
if rsa_key_data:
|
|
||||||
material += hashlib.sha256(rsa_key_data).digest()
|
|
||||||
|
|
||||||
return hashlib.sha256(material + b"pixel_selection").digest()
|
|
||||||
|
|
||||||
|
|
||||||
def encrypt_message(message, photo_data, day_phrase, date_str, pin="", rsa_key_data=None):
|
|
||||||
"""Encrypt message using hybrid key derivation."""
|
|
||||||
salt = secrets.token_bytes(SALT_SIZE)
|
|
||||||
key = derive_hybrid_key(photo_data, day_phrase, date_str, salt, pin, rsa_key_data)
|
|
||||||
iv = secrets.token_bytes(IV_SIZE)
|
|
||||||
|
|
||||||
if isinstance(message, str):
|
|
||||||
message = message.encode()
|
|
||||||
|
|
||||||
padding_len = secrets.randbelow(256) + 64
|
|
||||||
padded_len = ((len(message) + padding_len + 255) // 256) * 256
|
|
||||||
padding_needed = padded_len - len(message)
|
|
||||||
padding = secrets.token_bytes(padding_needed - 4) + struct.pack('>I', len(message))
|
|
||||||
padded_message = message + padding
|
|
||||||
|
|
||||||
cipher = Cipher(algorithms.AES(key), modes.GCM(iv), backend=default_backend())
|
|
||||||
encryptor = cipher.encryptor()
|
|
||||||
encryptor.authenticate_additional_data(MAGIC_HEADER + bytes([VERSION]))
|
|
||||||
ciphertext = encryptor.update(padded_message) + encryptor.finalize()
|
|
||||||
|
|
||||||
date_bytes = date_str.encode()
|
|
||||||
|
|
||||||
return (
|
|
||||||
MAGIC_HEADER +
|
|
||||||
bytes([VERSION]) +
|
|
||||||
bytes([len(date_bytes)]) +
|
|
||||||
date_bytes +
|
|
||||||
salt +
|
|
||||||
iv +
|
|
||||||
encryptor.tag +
|
|
||||||
ciphertext
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def generate_pixel_indices(key, num_pixels, num_needed):
|
|
||||||
"""Generate pseudo-random pixel indices."""
|
|
||||||
if num_needed >= num_pixels // 2:
|
|
||||||
nonce = b'\x00' * 16
|
|
||||||
cipher = Cipher(algorithms.ChaCha20(key, nonce), mode=None, backend=default_backend())
|
|
||||||
encryptor = cipher.encryptor()
|
|
||||||
|
|
||||||
indices = list(range(num_pixels))
|
|
||||||
random_bytes = encryptor.update(b'\x00' * (num_pixels * 4))
|
|
||||||
|
|
||||||
for i in range(num_pixels - 1, 0, -1):
|
|
||||||
j_bytes = random_bytes[(num_pixels - 1 - i) * 4:(num_pixels - i) * 4]
|
|
||||||
j = int.from_bytes(j_bytes, 'big') % (i + 1)
|
|
||||||
indices[i], indices[j] = indices[j], indices[i]
|
|
||||||
|
|
||||||
return indices[:num_needed]
|
|
||||||
|
|
||||||
selected = []
|
|
||||||
used = set()
|
|
||||||
|
|
||||||
nonce = b'\x00' * 16
|
|
||||||
cipher = Cipher(algorithms.ChaCha20(key, nonce), mode=None, backend=default_backend())
|
|
||||||
encryptor = cipher.encryptor()
|
|
||||||
|
|
||||||
bytes_needed = (num_needed * 2) * 4
|
|
||||||
random_bytes = encryptor.update(b'\x00' * bytes_needed)
|
|
||||||
|
|
||||||
byte_offset = 0
|
|
||||||
while len(selected) < num_needed and byte_offset < len(random_bytes) - 4:
|
|
||||||
idx = int.from_bytes(random_bytes[byte_offset:byte_offset + 4], 'big') % num_pixels
|
|
||||||
byte_offset += 4
|
|
||||||
|
|
||||||
if idx not in used:
|
|
||||||
used.add(idx)
|
|
||||||
selected.append(idx)
|
|
||||||
|
|
||||||
while len(selected) < num_needed:
|
|
||||||
extra_bytes = encryptor.update(b'\x00' * 4)
|
|
||||||
idx = int.from_bytes(extra_bytes, 'big') % num_pixels
|
|
||||||
if idx not in used:
|
|
||||||
used.add(idx)
|
|
||||||
selected.append(idx)
|
|
||||||
|
|
||||||
return selected
|
|
||||||
|
|
||||||
|
|
||||||
def embed_in_image(carrier_data, encrypted_data, pixel_key, bits_per_channel=1):
|
|
||||||
"""Embed encrypted data in carrier image. Returns PNG bytes."""
|
|
||||||
img = Image.open(io.BytesIO(carrier_data))
|
|
||||||
if img.mode != 'RGB':
|
|
||||||
img = img.convert('RGB')
|
|
||||||
|
|
||||||
pixels = list(img.getdata())
|
|
||||||
num_pixels = len(pixels)
|
|
||||||
|
|
||||||
bits_per_pixel = 3 * bits_per_channel
|
|
||||||
max_bytes = (num_pixels * bits_per_pixel) // 8
|
|
||||||
|
|
||||||
data_with_len = struct.pack('>I', len(encrypted_data)) + encrypted_data
|
|
||||||
|
|
||||||
if len(data_with_len) > max_bytes:
|
|
||||||
raise ValueError(f"Carrier too small. Need {len(data_with_len)} bytes, have {max_bytes}")
|
|
||||||
|
|
||||||
binary_data = ''.join(format(b, '08b') for b in data_with_len)
|
|
||||||
pixels_needed = (len(binary_data) + bits_per_pixel - 1) // bits_per_pixel
|
|
||||||
|
|
||||||
selected_indices = generate_pixel_indices(pixel_key, num_pixels, pixels_needed)
|
|
||||||
|
|
||||||
new_pixels = list(pixels)
|
|
||||||
clear_mask = 0xFF ^ ((1 << bits_per_channel) - 1)
|
|
||||||
|
|
||||||
bit_idx = 0
|
|
||||||
for pixel_idx in selected_indices:
|
|
||||||
if bit_idx >= len(binary_data):
|
|
||||||
break
|
|
||||||
|
|
||||||
r, g, b = new_pixels[pixel_idx]
|
|
||||||
|
|
||||||
for channel_idx, channel_val in enumerate([r, g, b]):
|
|
||||||
if bit_idx >= len(binary_data):
|
|
||||||
break
|
|
||||||
bits = binary_data[bit_idx:bit_idx + bits_per_channel].ljust(bits_per_channel, '0')
|
|
||||||
new_val = (channel_val & clear_mask) | int(bits, 2)
|
|
||||||
|
|
||||||
if channel_idx == 0:
|
|
||||||
r = new_val
|
|
||||||
elif channel_idx == 1:
|
|
||||||
g = new_val
|
|
||||||
else:
|
|
||||||
b = new_val
|
|
||||||
|
|
||||||
bit_idx += bits_per_channel
|
|
||||||
|
|
||||||
new_pixels[pixel_idx] = (r, g, b)
|
|
||||||
|
|
||||||
stego_img = Image.new('RGB', img.size)
|
|
||||||
stego_img.putdata(new_pixels)
|
|
||||||
|
|
||||||
output = io.BytesIO()
|
|
||||||
stego_img.save(output, 'PNG')
|
|
||||||
output.seek(0)
|
|
||||||
|
|
||||||
return output.getvalue(), {
|
|
||||||
'pixels_modified': len(selected_indices),
|
|
||||||
'total_pixels': num_pixels,
|
|
||||||
'capacity_used': len(data_with_len) / max_bytes
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def extract_from_image(image_data, pixel_key, bits_per_channel=1):
|
|
||||||
"""Extract hidden data from image."""
|
|
||||||
img = Image.open(io.BytesIO(image_data))
|
|
||||||
if img.mode != 'RGB':
|
|
||||||
img = img.convert('RGB')
|
|
||||||
|
|
||||||
pixels = list(img.getdata())
|
|
||||||
num_pixels = len(pixels)
|
|
||||||
bits_per_pixel = 3 * bits_per_channel
|
|
||||||
|
|
||||||
initial_pixels = (32 + bits_per_pixel - 1) // bits_per_pixel + 10
|
|
||||||
initial_indices = generate_pixel_indices(pixel_key, num_pixels, initial_pixels)
|
|
||||||
|
|
||||||
binary_data = ''
|
|
||||||
for pixel_idx in initial_indices:
|
|
||||||
r, g, b = pixels[pixel_idx]
|
|
||||||
for channel in [r, g, b]:
|
|
||||||
for bit_pos in range(bits_per_channel - 1, -1, -1):
|
|
||||||
binary_data += str((channel >> bit_pos) & 1)
|
|
||||||
|
|
||||||
try:
|
|
||||||
length_bits = binary_data[:32]
|
|
||||||
data_length = struct.unpack('>I', int(length_bits, 2).to_bytes(4, 'big'))[0]
|
|
||||||
except:
|
|
||||||
return None
|
|
||||||
|
|
||||||
max_possible = (num_pixels * bits_per_pixel) // 8 - 4
|
|
||||||
if data_length > max_possible or data_length < 10:
|
|
||||||
return None
|
|
||||||
|
|
||||||
total_bits = (4 + data_length) * 8
|
|
||||||
pixels_needed = (total_bits + bits_per_pixel - 1) // bits_per_pixel
|
|
||||||
|
|
||||||
selected_indices = generate_pixel_indices(pixel_key, num_pixels, pixels_needed)
|
|
||||||
|
|
||||||
binary_data = ''
|
|
||||||
for pixel_idx in selected_indices:
|
|
||||||
r, g, b = pixels[pixel_idx]
|
|
||||||
for channel in [r, g, b]:
|
|
||||||
for bit_pos in range(bits_per_channel - 1, -1, -1):
|
|
||||||
binary_data += str((channel >> bit_pos) & 1)
|
|
||||||
|
|
||||||
data_bits = binary_data[32:32 + (data_length * 8)]
|
|
||||||
|
|
||||||
data_bytes = bytearray()
|
|
||||||
for i in range(0, len(data_bits), 8):
|
|
||||||
byte_bits = data_bits[i:i+8]
|
|
||||||
if len(byte_bits) == 8:
|
|
||||||
data_bytes.append(int(byte_bits, 2))
|
|
||||||
|
|
||||||
return bytes(data_bytes)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_header(encrypted_data):
|
|
||||||
"""Parse v3 header."""
|
|
||||||
if len(encrypted_data) < 10 or encrypted_data[:4] != MAGIC_HEADER:
|
|
||||||
return None
|
|
||||||
|
|
||||||
date_len = encrypted_data[5]
|
|
||||||
date_str = encrypted_data[6:6+date_len].decode()
|
|
||||||
|
|
||||||
offset = 6 + date_len
|
|
||||||
salt = encrypted_data[offset:offset+SALT_SIZE]
|
|
||||||
offset += SALT_SIZE
|
|
||||||
iv = encrypted_data[offset:offset+IV_SIZE]
|
|
||||||
offset += IV_SIZE
|
|
||||||
tag = encrypted_data[offset:offset+TAG_SIZE]
|
|
||||||
offset += TAG_SIZE
|
|
||||||
ciphertext = encrypted_data[offset:]
|
|
||||||
|
|
||||||
return {'date': date_str, 'salt': salt, 'iv': iv, 'tag': tag, 'ciphertext': ciphertext}
|
|
||||||
|
|
||||||
|
|
||||||
def decrypt_message(encrypted_data, photo_data, day_phrase, pin="", rsa_key_data=None):
|
|
||||||
"""Decrypt message."""
|
|
||||||
header = parse_header(encrypted_data)
|
|
||||||
if not header:
|
|
||||||
return None
|
|
||||||
|
|
||||||
key = derive_hybrid_key(photo_data, day_phrase, header['date'], header['salt'], pin, rsa_key_data)
|
|
||||||
|
|
||||||
cipher = Cipher(
|
|
||||||
algorithms.AES(key),
|
|
||||||
modes.GCM(header['iv'], header['tag']),
|
|
||||||
backend=default_backend()
|
|
||||||
)
|
|
||||||
decryptor = cipher.decryptor()
|
|
||||||
decryptor.authenticate_additional_data(MAGIC_HEADER + bytes([VERSION]))
|
|
||||||
|
|
||||||
try:
|
|
||||||
padded_plaintext = decryptor.update(header['ciphertext']) + decryptor.finalize()
|
|
||||||
original_length = struct.unpack('>I', padded_plaintext[-4:])[0]
|
|
||||||
return padded_plaintext[:original_length].decode('utf-8')
|
|
||||||
except:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# FLASK ROUTES
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
def index():
|
|
||||||
return render_template('index.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/generate', methods=['GET', 'POST'])
|
|
||||||
def generate():
|
|
||||||
if request.method == 'POST':
|
|
||||||
words_per_phrase = int(request.form.get('words_per_phrase', 3))
|
|
||||||
|
|
||||||
# Security factor options
|
|
||||||
use_pin = request.form.get('use_pin') == 'on'
|
|
||||||
use_rsa = request.form.get('use_rsa') == 'on'
|
|
||||||
|
|
||||||
# Validate at least one factor selected
|
|
||||||
if not use_pin and not use_rsa:
|
|
||||||
flash('You must select at least one security factor (PIN or RSA Key)', 'error')
|
|
||||||
return render_template('generate.html', generated=False, has_ml=HAS_ML)
|
|
||||||
|
|
||||||
pin_length = int(request.form.get('pin_length', 6))
|
|
||||||
rsa_bits = int(request.form.get('rsa_bits', 2048))
|
|
||||||
|
|
||||||
# Clamp values to valid ranges
|
|
||||||
words_per_phrase = max(3, min(12, words_per_phrase))
|
|
||||||
pin_length = max(MIN_PIN_LENGTH, min(MAX_PIN_LENGTH, pin_length))
|
|
||||||
if rsa_bits not in VALID_RSA_SIZES:
|
|
||||||
rsa_bits = 2048
|
|
||||||
|
|
||||||
phrases = generate_day_phrases(words_per_phrase)
|
|
||||||
|
|
||||||
# Generate PIN if selected
|
|
||||||
pin = generate_pin(pin_length) if use_pin else None
|
|
||||||
|
|
||||||
# Generate RSA key if selected
|
|
||||||
rsa_key_pem = None
|
|
||||||
if use_rsa:
|
|
||||||
private_key = generate_rsa_key(rsa_bits)
|
|
||||||
rsa_key_pem = export_rsa_key_pem(private_key, password=None).decode('utf-8')
|
|
||||||
|
|
||||||
# Calculate entropy
|
|
||||||
phrase_entropy = words_per_phrase * 11
|
|
||||||
pin_entropy = int(pin_length * 3.32) if use_pin else 0
|
|
||||||
# RSA key adds significant entropy (conservatively estimate effective security)
|
|
||||||
rsa_entropy = min(rsa_bits // 16, 128) if use_rsa else 0 # ~128 bits effective for 2048-bit
|
|
||||||
total_entropy = phrase_entropy + pin_entropy + rsa_entropy
|
|
||||||
|
|
||||||
return render_template('generate.html',
|
|
||||||
phrases=phrases,
|
|
||||||
pin=pin,
|
|
||||||
days=DAY_NAMES,
|
|
||||||
generated=True,
|
|
||||||
words_per_phrase=words_per_phrase,
|
|
||||||
pin_length=pin_length if use_pin else None,
|
|
||||||
use_pin=use_pin,
|
|
||||||
use_rsa=use_rsa,
|
|
||||||
rsa_bits=rsa_bits,
|
|
||||||
rsa_key_pem=rsa_key_pem,
|
|
||||||
phrase_entropy=phrase_entropy,
|
|
||||||
pin_entropy=pin_entropy,
|
|
||||||
rsa_entropy=rsa_entropy,
|
|
||||||
total_entropy=total_entropy,
|
|
||||||
has_ml=HAS_ML)
|
|
||||||
|
|
||||||
return render_template('generate.html', generated=False, has_ml=HAS_ML)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/generate/download-key', methods=['POST'])
|
|
||||||
def download_key():
|
|
||||||
"""Download RSA key as password-protected PEM file."""
|
|
||||||
key_pem = request.form.get('key_pem', '')
|
|
||||||
password = request.form.get('key_password', '')
|
|
||||||
|
|
||||||
if not key_pem:
|
|
||||||
flash('No key to download', 'error')
|
|
||||||
return redirect(url_for('generate'))
|
|
||||||
|
|
||||||
if not password or len(password) < 8:
|
|
||||||
flash('Password must be at least 8 characters', 'error')
|
|
||||||
return redirect(url_for('generate'))
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Load the unencrypted key
|
|
||||||
private_key = load_pem_private_key(key_pem.encode(), password=None, backend=default_backend())
|
|
||||||
|
|
||||||
# Re-export with password protection
|
|
||||||
encrypted_pem = export_rsa_key_pem(private_key, password=password)
|
|
||||||
|
|
||||||
# Generate filename
|
|
||||||
key_id = secrets.token_hex(4)
|
|
||||||
filename = f'stegasoo_key_{private_key.key_size}_{key_id}.pem'
|
|
||||||
|
|
||||||
return send_file(
|
|
||||||
io.BytesIO(encrypted_pem),
|
|
||||||
mimetype='application/x-pem-file',
|
|
||||||
as_attachment=True,
|
|
||||||
download_name=filename
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
flash(f'Error creating key file: {str(e)}', 'error')
|
|
||||||
return redirect(url_for('generate'))
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/encode', methods=['GET', 'POST'])
|
|
||||||
def encode():
|
|
||||||
day_of_week = datetime.now().strftime("%A")
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
try:
|
|
||||||
# Get files
|
|
||||||
ref_photo = request.files.get('reference_photo')
|
|
||||||
carrier = request.files.get('carrier')
|
|
||||||
rsa_key_file = request.files.get('rsa_key')
|
|
||||||
|
|
||||||
if not ref_photo or not carrier:
|
|
||||||
flash('Both reference photo and carrier image are required', 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
if not allowed_file(ref_photo.filename) or not allowed_file(carrier.filename):
|
|
||||||
flash('Invalid file type. Use PNG, JPG, or BMP', 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
# Get form data
|
|
||||||
message = request.form.get('message', '')
|
|
||||||
day_phrase = request.form.get('day_phrase', '')
|
|
||||||
pin = request.form.get('pin', '').strip()
|
|
||||||
rsa_password = request.form.get('rsa_password', '')
|
|
||||||
|
|
||||||
# Validate message
|
|
||||||
valid, error = validate_message(message)
|
|
||||||
if not valid:
|
|
||||||
flash(error, 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
if not day_phrase:
|
|
||||||
flash('Day phrase is required', 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
# Read files
|
|
||||||
ref_data = ref_photo.read()
|
|
||||||
carrier_data = carrier.read()
|
|
||||||
rsa_key_data = rsa_key_file.read() if rsa_key_file and rsa_key_file.filename else None
|
|
||||||
|
|
||||||
# Validate security factors
|
|
||||||
valid, error = validate_security_factors(pin, rsa_key_data)
|
|
||||||
if not valid:
|
|
||||||
flash(error, 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
# Validate PIN if provided
|
|
||||||
if pin:
|
|
||||||
valid, error = validate_pin(pin)
|
|
||||||
if not valid:
|
|
||||||
flash(error, 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
# Validate RSA key if provided
|
|
||||||
if rsa_key_data:
|
|
||||||
valid, error, key_size = validate_rsa_key(rsa_key_data, rsa_password if rsa_password else None)
|
|
||||||
if not valid:
|
|
||||||
flash(error, 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
# Validate carrier image
|
|
||||||
valid, error = validate_image(carrier_data, "Carrier image")
|
|
||||||
if not valid:
|
|
||||||
flash(error, 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
# Get date - use client's local date if provided
|
|
||||||
client_date = request.form.get('client_date', '').strip()
|
|
||||||
if client_date and len(client_date) == 10 and client_date[4] == '-' and client_date[7] == '-':
|
|
||||||
date_str = client_date
|
|
||||||
else:
|
|
||||||
date_str = datetime.now().strftime('%Y-%m-%d')
|
|
||||||
|
|
||||||
# Encrypt
|
|
||||||
encrypted = encrypt_message(message, ref_data, day_phrase, date_str, pin, rsa_key_data)
|
|
||||||
|
|
||||||
# Get pixel key
|
|
||||||
pixel_key = derive_pixel_key(ref_data, day_phrase, date_str, pin, rsa_key_data)
|
|
||||||
|
|
||||||
# Embed
|
|
||||||
stego_data, stats = embed_in_image(carrier_data, encrypted, pixel_key)
|
|
||||||
|
|
||||||
# Generate filename and file ID
|
|
||||||
filename = f'{secrets.token_hex(4)}_{date_str.replace("-", "")}.png'
|
|
||||||
file_id = secrets.token_urlsafe(16)
|
|
||||||
|
|
||||||
# Store temporarily for download/share
|
|
||||||
cleanup_temp_files()
|
|
||||||
TEMP_FILES[file_id] = {
|
|
||||||
'data': stego_data,
|
|
||||||
'filename': filename,
|
|
||||||
'timestamp': time.time()
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect(url_for('encode_result', file_id=file_id))
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
flash(f'Error: {str(e)}', 'error')
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
return render_template('encode.html', day_of_week=day_of_week)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/encode/result/<file_id>')
|
|
||||||
def encode_result(file_id):
|
|
||||||
if file_id not in TEMP_FILES:
|
|
||||||
flash('File expired or not found. Please encode again.', 'error')
|
|
||||||
return redirect(url_for('encode'))
|
|
||||||
|
|
||||||
file_info = TEMP_FILES[file_id]
|
|
||||||
return render_template('encode_result.html',
|
|
||||||
file_id=file_id,
|
|
||||||
filename=file_info['filename'])
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/encode/download/<file_id>')
|
|
||||||
def encode_download(file_id):
|
|
||||||
if file_id not in TEMP_FILES:
|
|
||||||
flash('File expired or not found.', 'error')
|
|
||||||
return redirect(url_for('encode'))
|
|
||||||
|
|
||||||
file_info = TEMP_FILES[file_id]
|
|
||||||
|
|
||||||
return send_file(
|
|
||||||
io.BytesIO(file_info['data']),
|
|
||||||
mimetype='image/png',
|
|
||||||
as_attachment=True,
|
|
||||||
download_name=file_info['filename']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/encode/file/<file_id>')
|
|
||||||
def encode_file(file_id):
|
|
||||||
"""Serve file for Web Share API (inline, not attachment)."""
|
|
||||||
if file_id not in TEMP_FILES:
|
|
||||||
return "Not found", 404
|
|
||||||
|
|
||||||
file_info = TEMP_FILES[file_id]
|
|
||||||
|
|
||||||
return send_file(
|
|
||||||
io.BytesIO(file_info['data']),
|
|
||||||
mimetype='image/png',
|
|
||||||
as_attachment=False,
|
|
||||||
download_name=file_info['filename']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/encode/cleanup/<file_id>', methods=['POST'])
|
|
||||||
def encode_cleanup(file_id):
|
|
||||||
"""Manually cleanup a file after sharing."""
|
|
||||||
TEMP_FILES.pop(file_id, None)
|
|
||||||
return jsonify({'status': 'ok'})
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/decode', methods=['GET', 'POST'])
|
|
||||||
def decode():
|
|
||||||
if request.method == 'POST':
|
|
||||||
try:
|
|
||||||
# Get files
|
|
||||||
ref_photo = request.files.get('reference_photo')
|
|
||||||
stego_image = request.files.get('stego_image')
|
|
||||||
rsa_key_file = request.files.get('rsa_key')
|
|
||||||
|
|
||||||
if not ref_photo or not stego_image:
|
|
||||||
flash('Both reference photo and stego image are required', 'error')
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
# Get form data
|
|
||||||
day_phrase = request.form.get('day_phrase', '')
|
|
||||||
pin = request.form.get('pin', '').strip()
|
|
||||||
rsa_password = request.form.get('rsa_password', '')
|
|
||||||
|
|
||||||
if not day_phrase:
|
|
||||||
flash('Day phrase is required', 'error')
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
# Read files
|
|
||||||
ref_data = ref_photo.read()
|
|
||||||
stego_data = stego_image.read()
|
|
||||||
rsa_key_data = rsa_key_file.read() if rsa_key_file and rsa_key_file.filename else None
|
|
||||||
|
|
||||||
# Validate security factors
|
|
||||||
valid, error = validate_security_factors(pin, rsa_key_data)
|
|
||||||
if not valid:
|
|
||||||
flash(error, 'error')
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
# Validate PIN if provided
|
|
||||||
if pin:
|
|
||||||
valid, error = validate_pin(pin)
|
|
||||||
if not valid:
|
|
||||||
flash(error, 'error')
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
# Validate RSA key if provided
|
|
||||||
if rsa_key_data:
|
|
||||||
valid, error, key_size = validate_rsa_key(rsa_key_data, rsa_password if rsa_password else None)
|
|
||||||
if not valid:
|
|
||||||
flash(error, 'error')
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
# Try to extract and decrypt
|
|
||||||
date_str = datetime.now().strftime('%Y-%m-%d')
|
|
||||||
pixel_key = derive_pixel_key(ref_data, day_phrase, date_str, pin, rsa_key_data)
|
|
||||||
|
|
||||||
encrypted = extract_from_image(stego_data, pixel_key)
|
|
||||||
|
|
||||||
if encrypted:
|
|
||||||
header = parse_header(encrypted)
|
|
||||||
if header and header['date'] != date_str:
|
|
||||||
pixel_key = derive_pixel_key(ref_data, day_phrase, header['date'], pin, rsa_key_data)
|
|
||||||
encrypted = extract_from_image(stego_data, pixel_key)
|
|
||||||
|
|
||||||
if not encrypted:
|
|
||||||
flash('Could not extract data. Check your inputs.', 'error')
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
message = decrypt_message(encrypted, ref_data, day_phrase, pin, rsa_key_data)
|
|
||||||
|
|
||||||
if message:
|
|
||||||
return render_template('decode.html', decoded_message=message)
|
|
||||||
else:
|
|
||||||
flash('Decryption failed. Wrong phrase, PIN, RSA key, or reference photo.', 'error')
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
flash(f'Error: {str(e)}', 'error')
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
return render_template('decode.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/about')
|
|
||||||
def about():
|
|
||||||
return render_template('about.html', has_argon2=HAS_ARGON2)
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# MAIN
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run(host='0.0.0.0', port=5000, debug=False)
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
|||||||
# ML dependencies for AI-powered story generation
|
|
||||||
# Install with: pip install -r requirements-ml.txt
|
|
||||||
#
|
|
||||||
# Note: These add ~1-2GB disk space for model downloads
|
|
||||||
# The app works without these (falls back to template-based stories)
|
|
||||||
|
|
||||||
transformers>=4.35.0
|
|
||||||
torch>=2.0.0
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# Core dependencies
|
|
||||||
flask>=3.0.0
|
|
||||||
gunicorn>=21.0.0
|
|
||||||
pillow>=10.0.0
|
|
||||||
cryptography>=41.0.0
|
|
||||||
|
|
||||||
# Memory-hard key derivation (highly recommended)
|
|
||||||
argon2-cffi>=23.0.0
|
|
||||||
|
|
||||||
# Optional: ML story generation (adds ~1GB disk space)
|
|
||||||
# Uncomment for AI-powered memory aid stories
|
|
||||||
# transformers>=4.35.0
|
|
||||||
# torch>=2.0.0
|
|
||||||
|
|
||||||
# Optional: For production deployment
|
|
||||||
# gevent>=23.0.0
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
import os
|
|
||||||
import shutil
|
|
||||||
import random
|
|
||||||
|
|
||||||
class SecureDeleter:
|
|
||||||
def __init__(self, path):
|
|
||||||
self.path = path
|
|
||||||
|
|
||||||
def overwrite_file(self, file_path, passes=7):
|
|
||||||
"""Overwrites the file with multiple patterns and random data."""
|
|
||||||
patterns = [b'\x00', b'\xFF', random.randbytes(1)]
|
|
||||||
print(patterns)
|
|
||||||
length = os.path.getsize(file_path)
|
|
||||||
for _ in range(passes):
|
|
||||||
with open(file_path, "r+b") as file:
|
|
||||||
for pattern in patterns:
|
|
||||||
file.seek(0)
|
|
||||||
for _ in range(length):
|
|
||||||
file.write(pattern)
|
|
||||||
# Final pass with random data for each byte
|
|
||||||
file.seek(0)
|
|
||||||
file.write(random.randbytes(length))
|
|
||||||
|
|
||||||
def delete_file(self, file_path):
|
|
||||||
"""Securely deletes a file."""
|
|
||||||
if os.path.isfile(file_path):
|
|
||||||
self.overwrite_file(file_path)
|
|
||||||
os.remove(file_path)
|
|
||||||
|
|
||||||
def delete_folder(self, folder_path):
|
|
||||||
"""Securely deletes a folder and its contents."""
|
|
||||||
if os.path.isdir(folder_path):
|
|
||||||
for root, dirs, files in os.walk(folder_path, topdown=False):
|
|
||||||
for name in files:
|
|
||||||
file_path = os.path.join(root, name)
|
|
||||||
self.delete_file(file_path)
|
|
||||||
for name in dirs:
|
|
||||||
os.rmdir(os.path.join(root, name))
|
|
||||||
shutil.rmtree(folder_path)\
|
|
||||||
|
|
||||||
def wipe_free_space(self, drive, size=1024*1024*10): # 10MB default file size
|
|
||||||
"""Writes temporary files with random data to overwrite free disk space."""
|
|
||||||
temp_files = []
|
|
||||||
try:
|
|
||||||
while True:
|
|
||||||
temp_file = os.path.join(drive, f"temp_{random.randint(0, 999999)}.dat")
|
|
||||||
with open(temp_file, "wb") as file:
|
|
||||||
file.write(random.randbytes(size))
|
|
||||||
temp_files.append(temp_file)
|
|
||||||
except OSError: # Typically disk full
|
|
||||||
for temp_file in temp_files:
|
|
||||||
os.remove(temp_file)
|
|
||||||
|
|
||||||
def execute(self):
|
|
||||||
"""Determines whether the path is a file or folder and deletes it securely."""
|
|
||||||
if os.path.isfile(self.path):
|
|
||||||
self.delete_file(self.path)
|
|
||||||
elif os.path.isdir(self.path):
|
|
||||||
self.delete_folder(self.path)
|
|
||||||
else:
|
|
||||||
print("Path does not exist.")
|
|
||||||
|
|
||||||
# Usage example:
|
|
||||||
#deleter = SecureDeleter("/path/to/your/file_or_folder")
|
|
||||||
#deleter.execute()
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
||||||
<stop offset="0%" style="stop-color:#667eea"/>
|
|
||||||
<stop offset="100%" style="stop-color:#764ba2"/>
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
|
|
||||||
<!-- Shield -->
|
|
||||||
<path d="M32 4 L56 14 L56 32 C56 48 44 58 32 62 C20 58 8 48 8 32 L8 14 Z"
|
|
||||||
fill="url(#grad)"/>
|
|
||||||
|
|
||||||
<!-- Photo frame -->
|
|
||||||
<rect x="16" y="18" width="32" height="24" rx="2" fill="#1a1a2e" stroke="#fff" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Mountain -->
|
|
||||||
<polygon points="16,42 26,30 34,36 48,22 48,42" fill="#667eea" opacity="0.5"/>
|
|
||||||
|
|
||||||
<!-- Lock -->
|
|
||||||
<rect x="24" y="30" width="16" height="12" rx="2" fill="#fff"/>
|
|
||||||
<path d="M27 30 L27 25 C27 20 37 20 37 25 L37 30" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round"/>
|
|
||||||
<circle cx="32" cy="35" r="2.5" fill="url(#grad)"/>
|
|
||||||
<rect x="31" y="35" width="2" height="4" fill="url(#grad)"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 964 B |
@@ -1,99 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
|
|
||||||
<defs>
|
|
||||||
<!-- Gradient for the shield/frame -->
|
|
||||||
<linearGradient id="shieldGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
||||||
<stop offset="0%" style="stop-color:#667eea"/>
|
|
||||||
<stop offset="100%" style="stop-color:#764ba2"/>
|
|
||||||
</linearGradient>
|
|
||||||
|
|
||||||
<!-- Gradient for the photo -->
|
|
||||||
<linearGradient id="photoGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
||||||
<stop offset="0%" style="stop-color:#1a1a2e"/>
|
|
||||||
<stop offset="100%" style="stop-color:#16213e"/>
|
|
||||||
</linearGradient>
|
|
||||||
|
|
||||||
<!-- Glow effect -->
|
|
||||||
<filter id="glow" x="-20%" y="-20%" width="140%" height="140%">
|
|
||||||
<feGaussianBlur stdDeviation="3" result="coloredBlur"/>
|
|
||||||
<feMerge>
|
|
||||||
<feMergeNode in="coloredBlur"/>
|
|
||||||
<feMergeNode in="SourceGraphic"/>
|
|
||||||
</feMerge>
|
|
||||||
</filter>
|
|
||||||
|
|
||||||
<!-- Drop shadow -->
|
|
||||||
<filter id="shadow" x="-10%" y="-10%" width="120%" height="120%">
|
|
||||||
<feDropShadow dx="2" dy="4" stdDeviation="4" flood-color="#000" flood-opacity="0.3"/>
|
|
||||||
</filter>
|
|
||||||
</defs>
|
|
||||||
|
|
||||||
<!-- Background circle (optional, for icon use) -->
|
|
||||||
<circle cx="100" cy="100" r="95" fill="none" stroke="url(#shieldGrad)" stroke-width="2" opacity="0.3"/>
|
|
||||||
|
|
||||||
<!-- Shield shape (security) that also looks like a photo frame -->
|
|
||||||
<path d="M100 20
|
|
||||||
L170 45
|
|
||||||
L170 100
|
|
||||||
C170 145 140 175 100 185
|
|
||||||
C60 175 30 145 30 100
|
|
||||||
L30 45 Z"
|
|
||||||
fill="url(#shieldGrad)"
|
|
||||||
filter="url(#shadow)"
|
|
||||||
opacity="0.95"/>
|
|
||||||
|
|
||||||
<!-- Inner photo frame area -->
|
|
||||||
<rect x="50" y="55" width="100" height="75" rx="4" ry="4"
|
|
||||||
fill="url(#photoGrad)"
|
|
||||||
stroke="#fff"
|
|
||||||
stroke-width="2"
|
|
||||||
opacity="0.9"/>
|
|
||||||
|
|
||||||
<!-- Stylized mountain/landscape (photo content hint) -->
|
|
||||||
<polygon points="50,130 75,95 95,115 130,75 150,130"
|
|
||||||
fill="#667eea"
|
|
||||||
opacity="0.6"/>
|
|
||||||
|
|
||||||
<!-- Sun in photo -->
|
|
||||||
<circle cx="125" cy="75" r="12" fill="#ffd700" opacity="0.8"/>
|
|
||||||
|
|
||||||
<!-- Lock symbol overlay (centered on photo) -->
|
|
||||||
<g transform="translate(100, 105)" filter="url(#glow)">
|
|
||||||
<!-- Lock body -->
|
|
||||||
<rect x="-18" y="-5" width="36" height="28" rx="4" ry="4"
|
|
||||||
fill="#fff" opacity="0.95"/>
|
|
||||||
<!-- Lock shackle -->
|
|
||||||
<path d="M-10 -5 L-10 -18
|
|
||||||
C-10 -30 10 -30 10 -18
|
|
||||||
L10 -5"
|
|
||||||
fill="none"
|
|
||||||
stroke="#fff"
|
|
||||||
stroke-width="6"
|
|
||||||
stroke-linecap="round"
|
|
||||||
opacity="0.95"/>
|
|
||||||
<!-- Keyhole -->
|
|
||||||
<circle cx="0" cy="8" r="5" fill="url(#shieldGrad)"/>
|
|
||||||
<rect x="-2.5" y="8" width="5" height="10" rx="1" fill="url(#shieldGrad)"/>
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- Binary/pixel dots (steganography hint) - scattered around -->
|
|
||||||
<g opacity="0.4" fill="#fff">
|
|
||||||
<circle cx="40" cy="85" r="2"/>
|
|
||||||
<circle cx="45" cy="140" r="1.5"/>
|
|
||||||
<circle cx="160" cy="80" r="2"/>
|
|
||||||
<circle cx="155" cy="135" r="1.5"/>
|
|
||||||
<circle cx="38" cy="110" r="1"/>
|
|
||||||
<circle cx="162" cy="110" r="1"/>
|
|
||||||
<circle cx="65" cy="150" r="1.5"/>
|
|
||||||
<circle cx="135" cy="150" r="1.5"/>
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- "Hidden" pixels effect on edges -->
|
|
||||||
<g opacity="0.3">
|
|
||||||
<rect x="52" y="57" width="3" height="3" fill="#667eea"/>
|
|
||||||
<rect x="58" y="57" width="3" height="3" fill="#764ba2"/>
|
|
||||||
<rect x="145" y="57" width="3" height="3" fill="#667eea"/>
|
|
||||||
<rect x="139" y="57" width="3" height="3" fill="#764ba2"/>
|
|
||||||
<rect x="52" y="124" width="3" height="3" fill="#764ba2"/>
|
|
||||||
<rect x="145" y="124" width="3" height="3" fill="#764ba2"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 3.5 KiB |
@@ -1,257 +0,0 @@
|
|||||||
/* ============================================================================
|
|
||||||
Stegasoo - Main Stylesheet
|
|
||||||
============================================================================ */
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
CSS Variables
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
:root {
|
|
||||||
--gradient-start: #667eea;
|
|
||||||
--gradient-end: #764ba2;
|
|
||||||
--bg-dark-1: #1a1a2e;
|
|
||||||
--bg-dark-2: #16213e;
|
|
||||||
--bg-dark-3: #0f3460;
|
|
||||||
--text-muted: rgba(255, 255, 255, 0.5);
|
|
||||||
--border-light: rgba(255, 255, 255, 0.1);
|
|
||||||
--overlay-dark: rgba(0, 0, 0, 0.3);
|
|
||||||
--overlay-light: rgba(255, 255, 255, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Base Styles
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
body {
|
|
||||||
min-height: 100vh;
|
|
||||||
background: linear-gradient(135deg, var(--bg-dark-1) 0%, var(--bg-dark-2) 50%, var(--bg-dark-3) 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Navigation
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.navbar {
|
|
||||||
background: var(--overlay-dark) !important;
|
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Cards
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.card {
|
|
||||||
background: var(--overlay-light);
|
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header {
|
|
||||||
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.feature-card {
|
|
||||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.feature-card:hover {
|
|
||||||
transform: translateY(-5px);
|
|
||||||
box-shadow: 0 10px 40px rgba(102, 126, 234, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Buttons
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.btn-primary {
|
|
||||||
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
background: linear-gradient(135deg, var(--gradient-end), var(--gradient-start));
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Forms
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.form-control,
|
|
||||||
.form-select {
|
|
||||||
background: var(--overlay-light);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-control:focus,
|
|
||||||
.form-select:focus {
|
|
||||||
background: rgba(255, 255, 255, 0.1);
|
|
||||||
border-color: var(--gradient-start);
|
|
||||||
box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.25);
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-control::placeholder {
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fix dropdown options for dark theme */
|
|
||||||
.form-select option {
|
|
||||||
background: var(--bg-dark-1);
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Hero & Icons
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.hero-icon {
|
|
||||||
font-size: 4rem;
|
|
||||||
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
|
|
||||||
-webkit-background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
|
||||||
background-clip: text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Phrase Display
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.phrase-display {
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
font-size: 1rem;
|
|
||||||
background: var(--overlay-dark);
|
|
||||||
padding: 0.5rem 0.75rem;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
border-left: 4px solid var(--gradient-start);
|
|
||||||
display: inline-block;
|
|
||||||
line-height: 1.6;
|
|
||||||
word-spacing: 0.3rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
PIN Display
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.pin-display {
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
font-size: 3rem;
|
|
||||||
font-weight: bold;
|
|
||||||
letter-spacing: 0.75rem;
|
|
||||||
background: linear-gradient(135deg, #fef08a, #fcd34d, #fb923c);
|
|
||||||
-webkit-background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
|
||||||
background-clip: text;
|
|
||||||
display: inline-block;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pin-container {
|
|
||||||
background: var(--overlay-dark);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
border-radius: 0.75rem;
|
|
||||||
padding: 1.5rem 2rem;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Story Cards (Memory Aid)
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.story-word {
|
|
||||||
color: #ff6b6b;
|
|
||||||
font-weight: bold;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
|
|
||||||
.story-card {
|
|
||||||
background: rgba(0, 0, 0, 0.2);
|
|
||||||
border-left: 3px solid var(--gradient-start);
|
|
||||||
padding: 1rem;
|
|
||||||
margin-bottom: 0.75rem;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.story-card .day-label {
|
|
||||||
font-weight: bold;
|
|
||||||
color: var(--gradient-start);
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Alert / Message Display
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.alert-message {
|
|
||||||
background: var(--overlay-dark);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
padding: 1.5rem;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Drop Zone (Drag & Drop File Upload)
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.drop-zone {
|
|
||||||
position: relative;
|
|
||||||
border: 2px dashed rgba(255, 255, 255, 0.2);
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
padding: 1.5rem;
|
|
||||||
text-align: center;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drop-zone.drag-over {
|
|
||||||
border-color: var(--gradient-start);
|
|
||||||
background: rgba(102, 126, 234, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.drop-zone input[type="file"] {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
opacity: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drop-zone-label {
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drop-zone-preview {
|
|
||||||
max-height: 120px;
|
|
||||||
border-radius: 0.375rem;
|
|
||||||
margin-top: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Footer
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
footer {
|
|
||||||
background: rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Custom Alert Variants
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.alert-success-bright {
|
|
||||||
background: rgba(34, 197, 94, 0.2);
|
|
||||||
border-color: #22c55e;
|
|
||||||
color: #4ade80;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
Utility Classes
|
|
||||||
---------------------------------------------------------------------------- */
|
|
||||||
.bg-dark-subtle {
|
|
||||||
background: rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-box {
|
|
||||||
background: rgba(0, 0, 0, 0.2);
|
|
||||||
padding: 1rem;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.result-icon {
|
|
||||||
font-size: 4rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-icon {
|
|
||||||
vertical-align: text-bottom;
|
|
||||||
}
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block title %}About - Stegasoo{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-lg-10">
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-info-circle me-2"></i>About Stegasoo</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p>
|
|
||||||
Stegasoo is a hybrid steganography system that hides encrypted messages inside
|
|
||||||
ordinary images. It combines multiple security layers to create a system that is
|
|
||||||
both highly secure and practical to use.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h6 class="mt-4 mb-3">System Status</h6>
|
|
||||||
<div class="row g-3">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<div class="d-flex align-items-center p-3 rounded status-box">
|
|
||||||
{% if has_argon2 %}
|
|
||||||
<i class="bi bi-check-circle-fill text-success fs-4 me-3"></i>
|
|
||||||
<div>
|
|
||||||
<strong>Argon2id Available</strong>
|
|
||||||
<div class="small text-muted">Memory-hard key derivation (256MB)</div>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<i class="bi bi-exclamation-triangle-fill text-warning fs-4 me-3"></i>
|
|
||||||
<div>
|
|
||||||
<strong>Using PBKDF2 Fallback</strong>
|
|
||||||
<div class="small text-muted">Install argon2-cffi for better security</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<div class="d-flex align-items-center p-3 rounded status-box">
|
|
||||||
<i class="bi bi-shield-fill-check text-success fs-4 me-3"></i>
|
|
||||||
<div>
|
|
||||||
<strong>AES-256-GCM</strong>
|
|
||||||
<div class="small text-muted">Authenticated encryption enabled</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-shield-lock me-2"></i>Security Model</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-dark">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Component</th>
|
|
||||||
<th>Entropy</th>
|
|
||||||
<th>Purpose</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td><i class="bi bi-image text-info me-2"></i>Reference Photo</td>
|
|
||||||
<td>~80-256 bits</td>
|
|
||||||
<td>Something you have (plausible deniability)</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><i class="bi bi-chat-quote text-info me-2"></i>3-Word Phrase</td>
|
|
||||||
<td>~33 bits</td>
|
|
||||||
<td>Something you know (changes daily)</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><i class="bi bi-123 text-info me-2"></i>6-Digit PIN</td>
|
|
||||||
<td>~20 bits</td>
|
|
||||||
<td>Something you know (static)</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><i class="bi bi-calendar text-info me-2"></i>Date</td>
|
|
||||||
<td>N/A</td>
|
|
||||||
<td>Automatic key rotation</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="table-active">
|
|
||||||
<td><strong>Combined</strong></td>
|
|
||||||
<td><strong>133+ bits</strong></td>
|
|
||||||
<td><strong>Beyond brute force</strong></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-cpu me-2"></i>Attack Resistance</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="row g-4">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h6 class="text-danger"><i class="bi bi-x-circle me-2"></i>What Attackers Can't Do</h6>
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-shield-x text-muted me-2"></i>
|
|
||||||
Brute force the passphrase (2<sup>133</sup> combinations)
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-shield-x text-muted me-2"></i>
|
|
||||||
Use rainbow tables (random salt per message)
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-shield-x text-muted me-2"></i>
|
|
||||||
Detect hidden data (random pixel selection)
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-shield-x text-muted me-2"></i>
|
|
||||||
Use GPU farms (Argon2 requires 256MB RAM per attempt)
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h6 class="text-warning"><i class="bi bi-exclamation-triangle me-2"></i>Real Threats</h6>
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-person-x text-muted me-2"></i>
|
|
||||||
Social engineering (someone tricks you)
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-door-open text-muted me-2"></i>
|
|
||||||
Physical access to your devices
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-bug text-muted me-2"></i>
|
|
||||||
Malware/keyloggers on your system
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-camera-video text-muted me-2"></i>
|
|
||||||
Shoulder surfing while you type
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-book me-2"></i>Best Practices</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h6 class="text-success"><i class="bi bi-check-lg me-2"></i>Do</h6>
|
|
||||||
<ul>
|
|
||||||
<li>Memorize your phrases and PIN, never write them down</li>
|
|
||||||
<li>Use a reference photo that both parties already have</li>
|
|
||||||
<li>Use different carrier images for each message</li>
|
|
||||||
<li>Share stego images through normal channels (looks innocent)</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h6 class="text-danger"><i class="bi bi-x-lg me-2"></i>Don't</h6>
|
|
||||||
<ul>
|
|
||||||
<li>Don't transmit the reference photo</li>
|
|
||||||
<li>Don't reuse the same carrier image</li>
|
|
||||||
<li>Don't store phrases or PIN digitally</li>
|
|
||||||
<li>Don't resize or recompress stego images</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" data-bs-theme="dark">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>{% block title %}Stegasoo{% endblock %}</title>
|
|
||||||
<link rel="icon" type="image/svg+xml" href="{{ url_for('static', filename='favicon.svg') }}">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" rel="stylesheet">
|
|
||||||
<link href="{{ url_for('static', filename='style.css') }}" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
|
||||||
<div class="container">
|
|
||||||
<a class="navbar-brand d-flex align-items-center" href="/">
|
|
||||||
<img src="{{ url_for('static', filename='logo.svg') }}" alt="Stegasoo" height="36" class="me-2">
|
|
||||||
<span class="fw-bold">Stegasoo</span>
|
|
||||||
</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav ms-auto">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="/"><i class="bi bi-house me-1"></i> Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="/encode"><i class="bi bi-lock me-1"></i> Encode</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="/decode"><i class="bi bi-unlock me-1"></i> Decode</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="/generate"><i class="bi bi-key me-1"></i> Generate</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="/about"><i class="bi bi-info-circle me-1"></i> About</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="container py-5">
|
|
||||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
||||||
{% if messages %}
|
|
||||||
{% for category, message in messages %}
|
|
||||||
<div class="alert alert-{{ 'danger' if category == 'error' else 'success' }} alert-dismissible fade show" role="alert">
|
|
||||||
<i class="bi bi-{{ 'exclamation-triangle' if category == 'error' else 'check-circle' }} me-2"></i>
|
|
||||||
{{ message }}
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endwith %}
|
|
||||||
|
|
||||||
{% block content %}{% endblock %}
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<footer class="py-4 mt-5">
|
|
||||||
<div class="container text-center text-muted">
|
|
||||||
<small>
|
|
||||||
<img src="{{ url_for('static', filename='favicon.svg') }}" alt="" height="16" class="me-1" style="vertical-align: text-bottom;">
|
|
||||||
Stegasoo v1.1 — Hybrid Photo + Day-Phrase + PIN Steganography
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
{% block scripts %}{% endblock %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,259 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block title %}Decode Message - Stegasoo{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-unlock-fill me-2"></i>Decode Secret Message</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
{% if decoded_message %}
|
|
||||||
<div class="alert alert-success">
|
|
||||||
<h6><i class="bi bi-check-circle me-2"></i>Message Decrypted Successfully!</h6>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-4">
|
|
||||||
<label class="form-label text-muted">Decoded Message:</label>
|
|
||||||
<div class="alert-message">{{ decoded_message }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="/decode" class="btn btn-outline-light w-100">
|
|
||||||
<i class="bi bi-arrow-repeat me-2"></i>Decode Another Message
|
|
||||||
</a>
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
|
|
||||||
<form method="POST" enctype="multipart/form-data" id="decodeForm">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-image me-1"></i> Reference Photo
|
|
||||||
</label>
|
|
||||||
<div class="drop-zone">
|
|
||||||
<input type="file" name="reference_photo" accept="image/*" required>
|
|
||||||
<div class="drop-zone-label">
|
|
||||||
<i class="bi bi-cloud-arrow-up fs-3 d-block mb-2 text-muted"></i>
|
|
||||||
<span class="text-muted">Drop image or click to browse</span>
|
|
||||||
</div>
|
|
||||||
<img class="drop-zone-preview d-none">
|
|
||||||
</div>
|
|
||||||
<div class="form-text">
|
|
||||||
The same reference photo used for encoding
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-file-earmark-image me-1"></i> Stego Image
|
|
||||||
</label>
|
|
||||||
<div class="drop-zone" id="stegoDropZone">
|
|
||||||
<input type="file" name="stego_image" accept="image/*" required>
|
|
||||||
<div class="drop-zone-label">
|
|
||||||
<i class="bi bi-cloud-arrow-up fs-3 d-block mb-2 text-muted"></i>
|
|
||||||
<span class="text-muted">Drop image or click to browse</span>
|
|
||||||
</div>
|
|
||||||
<img class="drop-zone-preview d-none">
|
|
||||||
</div>
|
|
||||||
<div class="form-text">
|
|
||||||
The image containing the hidden message
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label" id="dayPhraseLabel">
|
|
||||||
<i class="bi bi-chat-quote me-1"></i> Day Phrase
|
|
||||||
</label>
|
|
||||||
<input type="text" name="day_phrase" class="form-control"
|
|
||||||
placeholder="e.g., correct horse battery" required>
|
|
||||||
<div class="form-text">
|
|
||||||
The phrase for the day the message was encoded
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr class="my-4">
|
|
||||||
|
|
||||||
<h6 class="text-muted mb-3">
|
|
||||||
SECURITY FACTORS
|
|
||||||
<span class="text-warning small">(provide same factors used during encoding)</span>
|
|
||||||
</h6>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-123 me-1"></i> PIN
|
|
||||||
</label>
|
|
||||||
<input type="password" name="pin" class="form-control" id="pinInput"
|
|
||||||
placeholder="6-9 digits" maxlength="9">
|
|
||||||
<div class="form-text">
|
|
||||||
If PIN was used during encoding
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-file-earmark-lock me-1"></i> RSA Key
|
|
||||||
</label>
|
|
||||||
<input type="file" name="rsa_key" class="form-control" id="rsaKeyInput"
|
|
||||||
accept=".pem,.key">
|
|
||||||
<div class="form-text">
|
|
||||||
If RSA key was used during encoding
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- RSA Key Password (shown when key selected) -->
|
|
||||||
<div class="mb-3 d-none" id="rsaPasswordGroup">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-key me-1"></i> RSA Key Password
|
|
||||||
</label>
|
|
||||||
<input type="password" name="rsa_password" class="form-control"
|
|
||||||
placeholder="Password for the .pem file (if encrypted)">
|
|
||||||
<div class="form-text">
|
|
||||||
Leave blank if your key file is not password-protected
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary btn-lg w-100" id="decodeBtn">
|
|
||||||
<i class="bi bi-unlock me-2"></i>Decode Message
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card mt-4">
|
|
||||||
<div class="card-body">
|
|
||||||
<h6 class="text-muted mb-3"><i class="bi bi-question-circle me-2"></i>Troubleshooting</h6>
|
|
||||||
<ul class="list-unstyled text-muted small mb-0">
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-dot"></i>
|
|
||||||
Make sure you're using the <strong>exact same reference photo</strong> file
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-dot"></i>
|
|
||||||
Use the phrase for the <strong>day the message was encoded</strong>, not today
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-dot"></i>
|
|
||||||
Provide the <strong>same security factors</strong> (PIN and/or RSA key) used during encoding
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-dot"></i>
|
|
||||||
Ensure the stego image hasn't been <strong>resized or recompressed</strong>
|
|
||||||
</li>
|
|
||||||
<li class="mb-0">
|
|
||||||
<i class="bi bi-dot"></i>
|
|
||||||
If using an RSA key, make sure the <strong>password is correct</strong>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block scripts %}
|
|
||||||
<script>
|
|
||||||
// Form submit loading state
|
|
||||||
document.getElementById('decodeForm')?.addEventListener('submit', function() {
|
|
||||||
const btn = document.getElementById('decodeBtn');
|
|
||||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Decoding...';
|
|
||||||
btn.disabled = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Show RSA password field when key is selected
|
|
||||||
const rsaKeyInput = document.getElementById('rsaKeyInput');
|
|
||||||
const rsaPasswordGroup = document.getElementById('rsaPasswordGroup');
|
|
||||||
|
|
||||||
rsaKeyInput?.addEventListener('change', function() {
|
|
||||||
rsaPasswordGroup.classList.toggle('d-none', !this.files.length);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Day names for date detection
|
|
||||||
const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
||||||
|
|
||||||
// Detect day from filename
|
|
||||||
function detectDayFromFilename(filename) {
|
|
||||||
const dateMatch = filename.match(/_(\d{4})[-]?(\d{2})[-]?(\d{2})/);
|
|
||||||
|
|
||||||
if (dateMatch) {
|
|
||||||
const [, year, month, day] = dateMatch;
|
|
||||||
const date = new Date(year, month - 1, day);
|
|
||||||
return dayNames[date.getDay()];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update day phrase label
|
|
||||||
function updateDayLabel(dayName) {
|
|
||||||
const label = document.getElementById('dayPhraseLabel');
|
|
||||||
if (label && dayName) {
|
|
||||||
label.innerHTML = `<i class="bi bi-chat-quote me-1"></i> ${dayName}'s Phrase`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drag & drop with preview
|
|
||||||
document.querySelectorAll('.drop-zone').forEach(zone => {
|
|
||||||
const input = zone.querySelector('input[type="file"]');
|
|
||||||
const label = zone.querySelector('.drop-zone-label');
|
|
||||||
const preview = zone.querySelector('.drop-zone-preview');
|
|
||||||
const isStegoZone = zone.id === 'stegoDropZone';
|
|
||||||
|
|
||||||
['dragenter', 'dragover'].forEach(evt => {
|
|
||||||
zone.addEventListener(evt, e => {
|
|
||||||
e.preventDefault();
|
|
||||||
zone.classList.add('drag-over');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
['dragleave', 'drop'].forEach(evt => {
|
|
||||||
zone.addEventListener(evt, e => {
|
|
||||||
e.preventDefault();
|
|
||||||
zone.classList.remove('drag-over');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
zone.addEventListener('drop', e => {
|
|
||||||
if (e.dataTransfer.files.length) {
|
|
||||||
input.files = e.dataTransfer.files;
|
|
||||||
const file = e.dataTransfer.files[0];
|
|
||||||
showPreview(file);
|
|
||||||
|
|
||||||
if (isStegoZone) {
|
|
||||||
const dayName = detectDayFromFilename(file.name);
|
|
||||||
updateDayLabel(dayName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
input.addEventListener('change', function() {
|
|
||||||
if (this.files && this.files[0]) {
|
|
||||||
const file = this.files[0];
|
|
||||||
showPreview(file);
|
|
||||||
|
|
||||||
if (isStegoZone) {
|
|
||||||
const dayName = detectDayFromFilename(file.name);
|
|
||||||
updateDayLabel(dayName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function showPreview(file) {
|
|
||||||
if (!file.type.startsWith('image/')) return;
|
|
||||||
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = e => {
|
|
||||||
preview.src = e.target.result;
|
|
||||||
preview.classList.remove('d-none');
|
|
||||||
label.innerHTML = '<i class="bi bi-check-circle text-success me-1"></i>' + file.name;
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,259 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block title %}Encode Message - Stegasoo{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-lock-fill me-2"></i>Encode Secret Message</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<form method="POST" enctype="multipart/form-data" id="encodeForm">
|
|
||||||
<input type="hidden" name="client_date" id="clientDate" value="">
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-image me-1"></i> Reference Photo
|
|
||||||
</label>
|
|
||||||
<div class="drop-zone" id="refDropZone">
|
|
||||||
<input type="file" name="reference_photo" accept="image/*" required>
|
|
||||||
<div class="drop-zone-label">
|
|
||||||
<i class="bi bi-cloud-arrow-up fs-3 d-block mb-2 text-muted"></i>
|
|
||||||
<span class="text-muted">Drop image or click to browse</span>
|
|
||||||
</div>
|
|
||||||
<img class="drop-zone-preview d-none" id="refPreview">
|
|
||||||
</div>
|
|
||||||
<div class="form-text">
|
|
||||||
The secret photo both parties have (NOT transmitted)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-file-image me-1"></i> Carrier Image
|
|
||||||
</label>
|
|
||||||
<div class="drop-zone" id="carrierDropZone">
|
|
||||||
<input type="file" name="carrier" accept="image/*" required>
|
|
||||||
<div class="drop-zone-label">
|
|
||||||
<i class="bi bi-cloud-arrow-up fs-3 d-block mb-2 text-muted"></i>
|
|
||||||
<span class="text-muted">Drop image or click to browse</span>
|
|
||||||
</div>
|
|
||||||
<img class="drop-zone-preview d-none" id="carrierPreview">
|
|
||||||
</div>
|
|
||||||
<div class="form-text">
|
|
||||||
The image to hide your message in (e.g., a meme)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-chat-left-text me-1"></i> Secret Message
|
|
||||||
</label>
|
|
||||||
<textarea name="message" class="form-control" rows="4" id="messageInput"
|
|
||||||
placeholder="Enter your secret message here..." required></textarea>
|
|
||||||
<div class="d-flex justify-content-between form-text">
|
|
||||||
<span>
|
|
||||||
<span id="charCount">0</span> / 50,000 characters
|
|
||||||
<span id="charWarning" class="text-warning d-none ms-2">
|
|
||||||
<i class="bi bi-exclamation-triangle"></i> Getting long!
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<span id="charPercent" class="text-muted">0%</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label" id="dayPhraseLabel">
|
|
||||||
<i class="bi bi-chat-quote me-1"></i> {{ day_of_week }}'s Phrase
|
|
||||||
</label>
|
|
||||||
<input type="text" name="day_phrase" class="form-control"
|
|
||||||
placeholder="e.g., correct horse battery" required>
|
|
||||||
<div class="form-text">
|
|
||||||
Your phrase for <strong>today</strong> (based on your local timezone)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr class="my-4">
|
|
||||||
|
|
||||||
<h6 class="text-muted mb-3">
|
|
||||||
SECURITY FACTORS
|
|
||||||
<span class="text-warning small">(provide at least one: PIN or RSA Key)</span>
|
|
||||||
</h6>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-123 me-1"></i> PIN
|
|
||||||
</label>
|
|
||||||
<input type="password" name="pin" class="form-control" id="pinInput"
|
|
||||||
placeholder="6-9 digits" maxlength="9">
|
|
||||||
<div class="form-text">
|
|
||||||
Your static 6-9 digit PIN (if configured)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-file-earmark-lock me-1"></i> RSA Key
|
|
||||||
</label>
|
|
||||||
<input type="file" name="rsa_key" class="form-control" id="rsaKeyInput"
|
|
||||||
accept=".pem,.key">
|
|
||||||
<div class="form-text">
|
|
||||||
Your shared .pem key file (if configured)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- RSA Key Password (shown when key selected) -->
|
|
||||||
<div class="mb-3 d-none" id="rsaPasswordGroup">
|
|
||||||
<label class="form-label">
|
|
||||||
<i class="bi bi-key me-1"></i> RSA Key Password
|
|
||||||
</label>
|
|
||||||
<input type="password" name="rsa_password" class="form-control"
|
|
||||||
placeholder="Password for the .pem file (if encrypted)">
|
|
||||||
<div class="form-text">
|
|
||||||
Leave blank if your key file is not password-protected
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary btn-lg w-100" id="encodeBtn">
|
|
||||||
<i class="bi bi-lock me-2"></i>Encode Message
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<hr class="my-4">
|
|
||||||
|
|
||||||
<div class="row text-center text-muted small">
|
|
||||||
<div class="col-4">
|
|
||||||
<i class="bi bi-shield-check fs-4 d-block mb-1 text-success"></i>
|
|
||||||
AES-256-GCM Encryption
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
<i class="bi bi-shuffle fs-4 d-block mb-1 text-info"></i>
|
|
||||||
Random Pixel Embedding
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
<i class="bi bi-eye-slash fs-4 d-block mb-1 text-warning"></i>
|
|
||||||
Undetectable by Analysis
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="alert alert-secondary mt-4 small">
|
|
||||||
<i class="bi bi-info-circle me-1"></i>
|
|
||||||
<strong>Limits:</strong>
|
|
||||||
Carrier image max ~4 megapixels (2000×2000).
|
|
||||||
Files max 5MB each.
|
|
||||||
Message max 50KB.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block scripts %}
|
|
||||||
<script>
|
|
||||||
// Detect client's local date and day
|
|
||||||
const now = new Date();
|
|
||||||
const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
||||||
const localDay = dayNames[now.getDay()];
|
|
||||||
const localDate = now.getFullYear() + '-' +
|
|
||||||
String(now.getMonth() + 1).padStart(2, '0') + '-' +
|
|
||||||
String(now.getDate()).padStart(2, '0');
|
|
||||||
|
|
||||||
// Update day label to client's local day
|
|
||||||
const dayLabel = document.getElementById('dayPhraseLabel');
|
|
||||||
if (dayLabel) {
|
|
||||||
dayLabel.innerHTML = `<i class="bi bi-chat-quote me-1"></i> ${localDay}'s Phrase`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set hidden field with client's local date for server
|
|
||||||
const dateInput = document.getElementById('clientDate');
|
|
||||||
if (dateInput) {
|
|
||||||
dateInput.value = localDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show RSA password field when key is selected
|
|
||||||
const rsaKeyInput = document.getElementById('rsaKeyInput');
|
|
||||||
const rsaPasswordGroup = document.getElementById('rsaPasswordGroup');
|
|
||||||
|
|
||||||
rsaKeyInput.addEventListener('change', function() {
|
|
||||||
rsaPasswordGroup.classList.toggle('d-none', !this.files.length);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Form submit loading state
|
|
||||||
document.getElementById('encodeForm').addEventListener('submit', function(e) {
|
|
||||||
const btn = document.getElementById('encodeBtn');
|
|
||||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Encoding...';
|
|
||||||
btn.disabled = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Character counter
|
|
||||||
const messageInput = document.getElementById('messageInput');
|
|
||||||
const charCount = document.getElementById('charCount');
|
|
||||||
const charWarning = document.getElementById('charWarning');
|
|
||||||
const charPercent = document.getElementById('charPercent');
|
|
||||||
const maxChars = 50000;
|
|
||||||
|
|
||||||
messageInput.addEventListener('input', function() {
|
|
||||||
const len = this.value.length;
|
|
||||||
charCount.textContent = len.toLocaleString();
|
|
||||||
|
|
||||||
const pct = Math.round((len / maxChars) * 100);
|
|
||||||
charPercent.textContent = pct + '%';
|
|
||||||
|
|
||||||
charWarning.classList.toggle('d-none', len < maxChars * 0.8);
|
|
||||||
charCount.classList.toggle('text-danger', len > maxChars * 0.95);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Drag & drop with preview
|
|
||||||
document.querySelectorAll('.drop-zone').forEach(zone => {
|
|
||||||
const input = zone.querySelector('input[type="file"]');
|
|
||||||
const label = zone.querySelector('.drop-zone-label');
|
|
||||||
const preview = zone.querySelector('.drop-zone-preview');
|
|
||||||
|
|
||||||
['dragenter', 'dragover'].forEach(evt => {
|
|
||||||
zone.addEventListener(evt, e => {
|
|
||||||
e.preventDefault();
|
|
||||||
zone.classList.add('drag-over');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
['dragleave', 'drop'].forEach(evt => {
|
|
||||||
zone.addEventListener(evt, e => {
|
|
||||||
e.preventDefault();
|
|
||||||
zone.classList.remove('drag-over');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
zone.addEventListener('drop', e => {
|
|
||||||
if (e.dataTransfer.files.length) {
|
|
||||||
input.files = e.dataTransfer.files;
|
|
||||||
showPreview(e.dataTransfer.files[0]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
input.addEventListener('change', function() {
|
|
||||||
if (this.files && this.files[0]) {
|
|
||||||
showPreview(this.files[0]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function showPreview(file) {
|
|
||||||
if (!file.type.startsWith('image/')) return;
|
|
||||||
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = e => {
|
|
||||||
preview.src = e.target.result;
|
|
||||||
preview.classList.remove('d-none');
|
|
||||||
label.innerHTML = '<i class="bi bi-check-circle text-success me-1"></i>' + file.name;
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block title %}Message Encoded - Stegasoo{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-check-circle-fill me-2"></i>Message Encoded Successfully!</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body text-center">
|
|
||||||
<div class="mb-4">
|
|
||||||
<i class="bi bi-file-earmark-image text-success result-icon"></i>
|
|
||||||
<h5 class="mt-3">{{ filename }}</h5>
|
|
||||||
<p class="text-muted">Your secret message is hidden in this image</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-grid gap-3 mb-4">
|
|
||||||
<a href="{{ url_for('encode_download', file_id=file_id) }}"
|
|
||||||
class="btn btn-primary btn-lg" id="downloadBtn">
|
|
||||||
<i class="bi bi-download me-2"></i>Download Image
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-outline-light btn-lg" id="shareBtn">
|
|
||||||
<i class="bi bi-share me-2"></i>Share Image
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Fallback share options (shown if Web Share API unavailable) -->
|
|
||||||
<div id="shareFallback" class="d-none">
|
|
||||||
<p class="text-muted mb-3">Share via:</p>
|
|
||||||
<div class="d-flex justify-content-center gap-2 flex-wrap">
|
|
||||||
<a href="#" id="shareEmail" class="btn btn-outline-secondary">
|
|
||||||
<i class="bi bi-envelope me-1"></i>Email
|
|
||||||
</a>
|
|
||||||
<a href="#" id="shareTelegram" class="btn btn-outline-secondary">
|
|
||||||
<i class="bi bi-telegram me-1"></i>Telegram
|
|
||||||
</a>
|
|
||||||
<a href="#" id="shareWhatsapp" class="btn btn-outline-secondary">
|
|
||||||
<i class="bi bi-whatsapp me-1"></i>WhatsApp
|
|
||||||
</a>
|
|
||||||
<button type="button" id="copyLink" class="btn btn-outline-secondary">
|
|
||||||
<i class="bi bi-link-45deg me-1"></i>Copy Link
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr class="my-4">
|
|
||||||
|
|
||||||
<div class="alert alert-warning small text-start">
|
|
||||||
<i class="bi bi-clock me-1"></i>
|
|
||||||
<strong>File expires in 5 minutes.</strong>
|
|
||||||
Download or share now. The file will be securely deleted after expiry.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="{{ url_for('encode') }}" class="btn btn-outline-light">
|
|
||||||
<i class="bi bi-plus-circle me-2"></i>Encode Another Message
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block scripts %}
|
|
||||||
<script>
|
|
||||||
const fileId = "{{ file_id }}";
|
|
||||||
const filename = "{{ filename }}";
|
|
||||||
const fileUrl = "{{ url_for('encode_file', file_id=file_id, _external=True) }}";
|
|
||||||
const downloadUrl = "{{ url_for('encode_download', file_id=file_id, _external=True) }}";
|
|
||||||
|
|
||||||
const shareBtn = document.getElementById('shareBtn');
|
|
||||||
const shareFallback = document.getElementById('shareFallback');
|
|
||||||
|
|
||||||
// Check if Web Share API with files is supported
|
|
||||||
async function canShareFiles() {
|
|
||||||
if (!navigator.canShare) return false;
|
|
||||||
|
|
||||||
// Create a test file to check
|
|
||||||
const testFile = new File(['test'], 'test.png', { type: 'image/png' });
|
|
||||||
return navigator.canShare({ files: [testFile] });
|
|
||||||
}
|
|
||||||
|
|
||||||
shareBtn.addEventListener('click', async function() {
|
|
||||||
const canShare = await canShareFiles();
|
|
||||||
|
|
||||||
if (canShare) {
|
|
||||||
try {
|
|
||||||
// Fetch the image as a blob
|
|
||||||
const response = await fetch(fileUrl);
|
|
||||||
const blob = await response.blob();
|
|
||||||
const file = new File([blob], filename, { type: 'image/png' });
|
|
||||||
|
|
||||||
await navigator.share({
|
|
||||||
files: [file],
|
|
||||||
title: 'Shared Image',
|
|
||||||
});
|
|
||||||
|
|
||||||
// Cleanup after successful share
|
|
||||||
fetch("{{ url_for('encode_cleanup', file_id=file_id) }}", { method: 'POST' });
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
if (err.name !== 'AbortError') {
|
|
||||||
console.error('Share failed:', err);
|
|
||||||
shareFallback.classList.remove('d-none');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Show fallback options
|
|
||||||
shareFallback.classList.remove('d-none');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fallback share links
|
|
||||||
document.getElementById('shareEmail').href =
|
|
||||||
`mailto:?subject=Shared Image&body=Check out this image: ${downloadUrl}`;
|
|
||||||
|
|
||||||
document.getElementById('shareTelegram').href =
|
|
||||||
`https://t.me/share/url?url=${encodeURIComponent(downloadUrl)}`;
|
|
||||||
|
|
||||||
document.getElementById('shareWhatsapp').href =
|
|
||||||
`https://wa.me/?text=${encodeURIComponent('Check this out: ' + downloadUrl)}`;
|
|
||||||
|
|
||||||
document.getElementById('copyLink').addEventListener('click', function() {
|
|
||||||
navigator.clipboard.writeText(downloadUrl).then(() => {
|
|
||||||
this.innerHTML = '<i class="bi bi-check me-1"></i>Copied!';
|
|
||||||
setTimeout(() => {
|
|
||||||
this.innerHTML = '<i class="bi bi-link-45deg me-1"></i>Copy Link';
|
|
||||||
}, 2000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Cleanup after download
|
|
||||||
document.getElementById('downloadBtn').addEventListener('click', function() {
|
|
||||||
// Give time for download to start, then cleanup
|
|
||||||
setTimeout(() => {
|
|
||||||
fetch("{{ url_for('encode_cleanup', file_id=file_id) }}", { method: 'POST' });
|
|
||||||
}, 3000);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,345 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block title %}Generate Credentials - Stegasoo{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-key-fill me-2"></i>Generate Credentials</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
{% if not generated %}
|
|
||||||
<p class="text-muted mb-4">
|
|
||||||
Generate your weekly phrase card and security factors. You must choose at least one: PIN or RSA Key.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<form method="POST" id="generateForm">
|
|
||||||
<div class="mb-4">
|
|
||||||
<label class="form-label">Words per phrase</label>
|
|
||||||
<select name="words_per_phrase" class="form-select" id="wordsSelect">
|
|
||||||
<option value="3" selected>3 words (~33 bits)</option>
|
|
||||||
<option value="4">4 words (~44 bits)</option>
|
|
||||||
<option value="5">5 words (~55 bits)</option>
|
|
||||||
<option value="6">6 words (~66 bits)</option>
|
|
||||||
<option value="7">7 words (~77 bits)</option>
|
|
||||||
<option value="8">8 words (~88 bits)</option>
|
|
||||||
<option value="9">9 words (~99 bits)</option>
|
|
||||||
<option value="10">10 words (~110 bits)</option>
|
|
||||||
<option value="11">11 words (~121 bits)</option>
|
|
||||||
<option value="12">12 words (~132 bits)</option>
|
|
||||||
</select>
|
|
||||||
<div class="form-text">More words = more security, harder to memorize</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr class="my-4">
|
|
||||||
|
|
||||||
<h6 class="text-muted mb-3">SECURITY FACTORS <span class="text-warning">(select at least one)</span></h6>
|
|
||||||
|
|
||||||
<!-- PIN Option -->
|
|
||||||
<div class="card mb-3" style="background: rgba(0,0,0,0.2);">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="form-check mb-3">
|
|
||||||
<input class="form-check-input" type="checkbox" name="use_pin" id="usePin" checked>
|
|
||||||
<label class="form-check-label fw-bold" for="usePin">
|
|
||||||
<i class="bi bi-123 me-1"></i> PIN
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div id="pinOptions">
|
|
||||||
<label class="form-label">PIN length</label>
|
|
||||||
<select name="pin_length" class="form-select" id="pinSelect">
|
|
||||||
<option value="6" selected>6 digits (~20 bits)</option>
|
|
||||||
<option value="7">7 digits (~23 bits)</option>
|
|
||||||
<option value="8">8 digits (~27 bits)</option>
|
|
||||||
<option value="9">9 digits (~30 bits)</option>
|
|
||||||
</select>
|
|
||||||
<div class="form-text">Memorizable, same PIN used every day</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- RSA Key Option -->
|
|
||||||
<div class="card mb-3" style="background: rgba(0,0,0,0.2);">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="form-check mb-3">
|
|
||||||
<input class="form-check-input" type="checkbox" name="use_rsa" id="useRsa">
|
|
||||||
<label class="form-check-label fw-bold" for="useRsa">
|
|
||||||
<i class="bi bi-file-earmark-lock me-1"></i> RSA Key
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div id="rsaOptions" class="d-none">
|
|
||||||
<label class="form-label">Key size</label>
|
|
||||||
<select name="rsa_bits" class="form-select" id="rsaSelect">
|
|
||||||
<option value="2048" selected>2048-bit (~128 bits effective)</option>
|
|
||||||
<option value="3072">3072-bit (~128 bits effective)</option>
|
|
||||||
<option value="4096">4096-bit (~128 bits effective)</option>
|
|
||||||
</select>
|
|
||||||
<div class="form-text">File-based key, both parties need the same .pem file</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="alert alert-info mb-4">
|
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
|
||||||
<span><i class="bi bi-calculator me-2"></i>Estimated entropy:</span>
|
|
||||||
<strong id="entropyDisplay">~53 bits</strong>
|
|
||||||
</div>
|
|
||||||
<div class="progress mt-2" style="height: 8px;">
|
|
||||||
<div class="progress-bar bg-success" id="entropyBar" style="width: 40%"></div>
|
|
||||||
</div>
|
|
||||||
<small class="text-muted mt-1 d-block">
|
|
||||||
<span id="entropyDesc">Good for most use cases</span>
|
|
||||||
• Reference photo adds ~80-256 bits more
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="alert alert-warning d-none" id="noFactorWarning">
|
|
||||||
<i class="bi bi-exclamation-triangle me-2"></i>
|
|
||||||
You must select at least one security factor (PIN or RSA Key)
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary btn-lg w-100" id="generateBtn">
|
|
||||||
<i class="bi bi-shuffle me-2"></i>Generate Credentials
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
|
|
||||||
<!-- Generated Results -->
|
|
||||||
<div class="alert alert-success-bright alert-dismissible fade show">
|
|
||||||
<i class="bi bi-check-circle me-2"></i>
|
|
||||||
<strong>Credentials Generated!</strong>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="alert alert-warning alert-dismissible fade show">
|
|
||||||
<i class="bi bi-exclamation-triangle me-2"></i>
|
|
||||||
<strong>Memorize phrases, save key securely, then close!</strong> - Do not screenshot
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if pin %}
|
|
||||||
<hr class="my-4">
|
|
||||||
<div class="text-center mb-4">
|
|
||||||
<h6 class="text-muted mb-2">YOUR STATIC PIN</h6>
|
|
||||||
<div class="pin-container">
|
|
||||||
<div class="pin-display">{{ pin }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="mt-2">
|
|
||||||
<small class="text-muted">Use this {{ pin_length }}-digit PIN every day</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if rsa_key_pem %}
|
|
||||||
<hr class="my-4">
|
|
||||||
<div class="mb-4">
|
|
||||||
<h6 class="text-muted mb-3">
|
|
||||||
<i class="bi bi-file-earmark-lock me-2"></i>YOUR RSA KEY ({{ rsa_bits }}-bit)
|
|
||||||
</h6>
|
|
||||||
|
|
||||||
<div class="alert alert-danger small">
|
|
||||||
<i class="bi bi-shield-exclamation me-1"></i>
|
|
||||||
<strong>Save this key securely!</strong> Share it with your recipient through a secure channel. You cannot recover it later.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Key Display -->
|
|
||||||
<div class="mb-3">
|
|
||||||
<textarea class="form-control font-monospace" id="rsaKeyText" rows="6" readonly style="font-size: 0.75rem;">{{ rsa_key_pem }}</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Copy to Clipboard -->
|
|
||||||
<button type="button" class="btn btn-outline-light me-2" id="copyKeyBtn">
|
|
||||||
<i class="bi bi-clipboard me-1"></i> Copy to Clipboard
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- Download with Password -->
|
|
||||||
<button type="button" class="btn btn-outline-light" data-bs-toggle="collapse" data-bs-target="#downloadKeyForm">
|
|
||||||
<i class="bi bi-download me-1"></i> Download as .pem
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div class="collapse mt-3" id="downloadKeyForm">
|
|
||||||
<div class="card" style="background: rgba(0,0,0,0.2);">
|
|
||||||
<div class="card-body">
|
|
||||||
<form method="POST" action="{{ url_for('download_key') }}">
|
|
||||||
<input type="hidden" name="key_pem" value="{{ rsa_key_pem }}">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Password to protect key file</label>
|
|
||||||
<input type="password" name="key_password" class="form-control"
|
|
||||||
placeholder="Minimum 8 characters" minlength="8" required>
|
|
||||||
<div class="form-text">You'll need this password when using the key</div>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary">
|
|
||||||
<i class="bi bi-file-earmark-lock me-1"></i> Download Protected Key
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<hr class="my-4">
|
|
||||||
|
|
||||||
<h6 class="text-muted mb-3">DAILY PHRASES ({{ words_per_phrase }} words each)</h6>
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-dark table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 140px;">Day</th>
|
|
||||||
<th>Phrase</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for day in days %}
|
|
||||||
<tr>
|
|
||||||
<td class="text-nowrap">
|
|
||||||
<i class="bi bi-calendar3 me-2"></i>{{ day }}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="phrase-display">{{ phrases[day] }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="alert alert-success mt-4">
|
|
||||||
<h6><i class="bi bi-shield-check me-2"></i>Security Summary</h6>
|
|
||||||
<div class="row text-center mt-3">
|
|
||||||
<div class="col-3">
|
|
||||||
<div class="fs-4 fw-bold">{{ phrase_entropy }}</div>
|
|
||||||
<small class="text-muted">bits/phrase</small>
|
|
||||||
</div>
|
|
||||||
{% if pin %}
|
|
||||||
<div class="col-3">
|
|
||||||
<div class="fs-4 fw-bold">{{ pin_entropy }}</div>
|
|
||||||
<small class="text-muted">bits/PIN</small>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if rsa_key_pem %}
|
|
||||||
<div class="col-3">
|
|
||||||
<div class="fs-4 fw-bold">{{ rsa_entropy }}</div>
|
|
||||||
<small class="text-muted">bits/RSA</small>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="col-3">
|
|
||||||
<div class="fs-4 fw-bold text-success">{{ total_entropy }}</div>
|
|
||||||
<small class="text-muted">bits total</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<small class="d-block mt-2 text-center text-muted">
|
|
||||||
+ reference photo (~80-256 bits) = <strong>{{ total_entropy + 80 }}+ bits combined</strong>
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="/generate" class="btn btn-outline-light btn-lg w-100 mt-3">
|
|
||||||
<i class="bi bi-arrow-repeat me-2"></i>Generate New Credentials
|
|
||||||
</a>
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block scripts %}
|
|
||||||
<script>
|
|
||||||
{% if not generated %}
|
|
||||||
const usePinCheckbox = document.getElementById('usePin');
|
|
||||||
const useRsaCheckbox = document.getElementById('useRsa');
|
|
||||||
const pinOptions = document.getElementById('pinOptions');
|
|
||||||
const rsaOptions = document.getElementById('rsaOptions');
|
|
||||||
const noFactorWarning = document.getElementById('noFactorWarning');
|
|
||||||
const generateBtn = document.getElementById('generateBtn');
|
|
||||||
|
|
||||||
// Toggle option visibility
|
|
||||||
usePinCheckbox.addEventListener('change', function() {
|
|
||||||
pinOptions.classList.toggle('d-none', !this.checked);
|
|
||||||
validateFactors();
|
|
||||||
updateEntropy();
|
|
||||||
});
|
|
||||||
|
|
||||||
useRsaCheckbox.addEventListener('change', function() {
|
|
||||||
rsaOptions.classList.toggle('d-none', !this.checked);
|
|
||||||
validateFactors();
|
|
||||||
updateEntropy();
|
|
||||||
});
|
|
||||||
|
|
||||||
function validateFactors() {
|
|
||||||
const hasPin = usePinCheckbox.checked;
|
|
||||||
const hasRsa = useRsaCheckbox.checked;
|
|
||||||
const valid = hasPin || hasRsa;
|
|
||||||
|
|
||||||
noFactorWarning.classList.toggle('d-none', valid);
|
|
||||||
generateBtn.disabled = !valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateEntropy() {
|
|
||||||
const words = parseInt(document.getElementById('wordsSelect').value);
|
|
||||||
const usePin = usePinCheckbox.checked;
|
|
||||||
const useRsa = useRsaCheckbox.checked;
|
|
||||||
const pinLen = parseInt(document.getElementById('pinSelect').value);
|
|
||||||
|
|
||||||
const phraseEntropy = words * 11;
|
|
||||||
const pinEntropy = usePin ? Math.floor(pinLen * 3.32) : 0;
|
|
||||||
const rsaEntropy = useRsa ? 128 : 0;
|
|
||||||
const total = phraseEntropy + pinEntropy + rsaEntropy;
|
|
||||||
|
|
||||||
document.getElementById('entropyDisplay').textContent = '~' + total + ' bits';
|
|
||||||
|
|
||||||
// Update progress bar
|
|
||||||
const pct = Math.min(100, Math.max(10, (total - 30) * 0.5));
|
|
||||||
document.getElementById('entropyBar').style.width = pct + '%';
|
|
||||||
|
|
||||||
// Update description
|
|
||||||
let desc;
|
|
||||||
if (total < 50) desc = 'Basic security';
|
|
||||||
else if (total < 80) desc = 'Good for most use cases';
|
|
||||||
else if (total < 120) desc = 'Strong security';
|
|
||||||
else if (total < 180) desc = 'Very strong security';
|
|
||||||
else desc = 'Maximum security';
|
|
||||||
|
|
||||||
document.getElementById('entropyDesc').textContent = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('wordsSelect').addEventListener('change', updateEntropy);
|
|
||||||
document.getElementById('pinSelect').addEventListener('change', updateEntropy);
|
|
||||||
document.getElementById('rsaSelect').addEventListener('change', updateEntropy);
|
|
||||||
|
|
||||||
// Form submit
|
|
||||||
document.getElementById('generateForm').addEventListener('submit', function(e) {
|
|
||||||
if (!usePinCheckbox.checked && !useRsaCheckbox.checked) {
|
|
||||||
e.preventDefault();
|
|
||||||
noFactorWarning.classList.remove('d-none');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
generateBtn.disabled = true;
|
|
||||||
generateBtn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Generating...';
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initial state
|
|
||||||
validateFactors();
|
|
||||||
updateEntropy();
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
|
|
||||||
// Copy RSA key to clipboard
|
|
||||||
document.getElementById('copyKeyBtn')?.addEventListener('click', function() {
|
|
||||||
const keyText = document.getElementById('rsaKeyText');
|
|
||||||
navigator.clipboard.writeText(keyText.value).then(() => {
|
|
||||||
this.innerHTML = '<i class="bi bi-check me-1"></i> Copied!';
|
|
||||||
setTimeout(() => {
|
|
||||||
this.innerHTML = '<i class="bi bi-clipboard me-1"></i> Copy to Clipboard';
|
|
||||||
}, 2000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block title %}Stegasoo - Secure Steganography{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="text-center mb-5">
|
|
||||||
<img src="{{ url_for('static', filename='logo.svg') }}" alt="Stegasoo" height="120" class="mb-3">
|
|
||||||
<h1 class="display-4 fw-bold">Stegasoo</h1>
|
|
||||||
<p class="lead text-muted">Create hidden encrypted messages in images and photos using advanced steganography.</p>
|
|
||||||
</div>
|
|
||||||
<div class="row g-4 mb-5">
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card h-100 feature-card">
|
|
||||||
<div class="card-header text-center py-3">
|
|
||||||
<i class="bi bi-lock-fill fs-1"></i>
|
|
||||||
</div>
|
|
||||||
<div class="card-body text-center">
|
|
||||||
<h5 class="card-title">Encode Message</h5>
|
|
||||||
<p class="card-text text-muted">
|
|
||||||
Hide your secret message inside an innocent-looking image using your daily phrase + PIN.
|
|
||||||
</p>
|
|
||||||
<a href="/encode" class="btn btn-primary">
|
|
||||||
<i class="bi bi-upload me-1"></i> Encode
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card h-100 feature-card">
|
|
||||||
<div class="card-header text-center py-3">
|
|
||||||
<i class="bi bi-unlock-fill fs-1"></i>
|
|
||||||
</div>
|
|
||||||
<div class="card-body text-center">
|
|
||||||
<h5 class="card-title">Decode Message</h5>
|
|
||||||
<p class="card-text text-muted">
|
|
||||||
Extract and decrypt hidden messages from Stegasoo-encoded images using your credentials.
|
|
||||||
</p>
|
|
||||||
<a href="/decode" class="btn btn-primary">
|
|
||||||
<i class="bi bi-download me-1"></i> Decode
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card h-100 feature-card">
|
|
||||||
<div class="card-header text-center py-3">
|
|
||||||
<i class="bi bi-key-fill fs-1"></i>
|
|
||||||
</div>
|
|
||||||
<div class="card-body text-center">
|
|
||||||
<h5 class="card-title">Generate Keys</h5>
|
|
||||||
<p class="card-text text-muted">
|
|
||||||
Create your weekly phrase card and PIN. Memorize 21 words + 6 digits for maximum security.
|
|
||||||
</p>
|
|
||||||
<a href="/generate" class="btn btn-primary">
|
|
||||||
<i class="bi bi-plus-circle me-1"></i> Generate
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="mb-0"><i class="bi bi-diagram-3 me-2"></i>How It Works</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h6 class="text-primary"><i class="bi bi-1-circle me-2"></i>Key Components</h6>
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-image text-info me-2"></i>
|
|
||||||
<strong>Reference Photo</strong> — Any photo you and recipient both have
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-chat-quote text-info me-2"></i>
|
|
||||||
<strong>Day Phrase</strong> — 3 words, different each day of the week
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-123 text-info me-2"></i>
|
|
||||||
<strong>Static PIN</strong> — 6 digits, same every day
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h6 class="text-primary"><i class="bi bi-2-circle me-2"></i>Security Features</h6>
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-shield-check text-success me-2"></i>
|
|
||||||
Argon2id memory-hard key derivation (256MB)
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-shuffle text-success me-2"></i>
|
|
||||||
Pseudo-random pixel selection (defeats steganalysis)
|
|
||||||
</li>
|
|
||||||
<li class="mb-2">
|
|
||||||
<i class="bi bi-lock text-success me-2"></i>
|
|
||||||
AES-256-GCM authenticated encryption
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,244 +0,0 @@
|
|||||||
"""
|
|
||||||
Story Generator for Passphrase Memorization
|
|
||||||
Uses lightweight ML (DistilGPT-2) for coherent stories, with template fallback.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import random
|
|
||||||
import re
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
# Try to import ML libraries
|
|
||||||
try:
|
|
||||||
from transformers import pipeline, set_seed
|
|
||||||
import torch
|
|
||||||
HAS_ML = True
|
|
||||||
except ImportError:
|
|
||||||
HAS_ML = False
|
|
||||||
|
|
||||||
# Global generator (lazy loaded)
|
|
||||||
_generator = None
|
|
||||||
_model_loaded = False
|
|
||||||
|
|
||||||
|
|
||||||
def get_generator():
|
|
||||||
"""Lazy load the text generation model."""
|
|
||||||
global _generator, _model_loaded
|
|
||||||
|
|
||||||
if not HAS_ML:
|
|
||||||
return None
|
|
||||||
|
|
||||||
if not _model_loaded:
|
|
||||||
try:
|
|
||||||
# Use distilgpt2 - small (~350MB) and fast
|
|
||||||
device = 0 if torch.cuda.is_available() else -1
|
|
||||||
_generator = pipeline(
|
|
||||||
'text-generation',
|
|
||||||
model='distilgpt2',
|
|
||||||
device=device,
|
|
||||||
torch_dtype=torch.float32
|
|
||||||
)
|
|
||||||
_model_loaded = True
|
|
||||||
print("ML story generator loaded successfully")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Could not load ML model: {e}. Using templates.")
|
|
||||||
_generator = None
|
|
||||||
_model_loaded = True # Don't retry
|
|
||||||
|
|
||||||
return _generator
|
|
||||||
|
|
||||||
|
|
||||||
def generate_story_ml(day: str, words: list[str], max_attempts: int = 3) -> Optional[str]:
|
|
||||||
"""
|
|
||||||
Generate a story using ML that incorporates all passphrase words.
|
|
||||||
|
|
||||||
Returns None if ML is unavailable or generation fails.
|
|
||||||
"""
|
|
||||||
generator = get_generator()
|
|
||||||
if generator is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Create a compelling prompt
|
|
||||||
words_str = ', '.join(words[:-1]) + f', and {words[-1]}' if len(words) > 1 else words[0]
|
|
||||||
|
|
||||||
prompts = [
|
|
||||||
f"{day}, something memorable happened including: {words_str}.",
|
|
||||||
]
|
|
||||||
|
|
||||||
prompt = random.choice(prompts)
|
|
||||||
|
|
||||||
try:
|
|
||||||
set_seed(random.randint(0, 10000))
|
|
||||||
|
|
||||||
# Generate text
|
|
||||||
result = generator(
|
|
||||||
prompt,
|
|
||||||
max_new_tokens=80,
|
|
||||||
num_return_sequences=1,
|
|
||||||
temperature=0.8,
|
|
||||||
top_p=0.9,
|
|
||||||
do_sample=True,
|
|
||||||
pad_token_id=50256, # eos token for gpt2
|
|
||||||
)
|
|
||||||
|
|
||||||
story = result[0]['generated_text']
|
|
||||||
|
|
||||||
# Clean up - get just a few sentences
|
|
||||||
story = story.strip()
|
|
||||||
|
|
||||||
# Try to end at a sentence boundary
|
|
||||||
for end_char in ['. ', '! ', '? ']:
|
|
||||||
last_end = story.rfind(end_char)
|
|
||||||
if last_end > len(prompt) + 20:
|
|
||||||
story = story[:last_end + 1]
|
|
||||||
break
|
|
||||||
|
|
||||||
# Verify most words are present (ML doesn't always include all)
|
|
||||||
story_lower = story.lower()
|
|
||||||
words_found = sum(1 for w in words if w.lower() in story_lower)
|
|
||||||
|
|
||||||
if words_found < len(words) * 0.5: # At least 50% of words
|
|
||||||
# Append missing words naturally
|
|
||||||
missing = [w for w in words if w.lower() not in story_lower]
|
|
||||||
if missing:
|
|
||||||
story += f" Don't forget: {', '.join(missing)}."
|
|
||||||
|
|
||||||
return story
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"ML generation error: {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# TEMPLATE FALLBACK (always available)
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
STORY_TEMPLATES = {
|
|
||||||
'Monday': [
|
|
||||||
"Monday morning began when I discovered a {0} near the {1}. I had to {2} quickly, then grab the {3} before reaching the {4}.",
|
|
||||||
"The week started with a {0} appearing at the {1}. My plan was to {2}, secure the {3}, and head toward the {4}.",
|
|
||||||
"On Monday, the {0} and the {1} crossed paths. We decided to {2}, bring the {3}, and meet at the {4}.",
|
|
||||||
],
|
|
||||||
'Tuesday': [
|
|
||||||
"Tuesday brought a {0} to the {1}. Everyone wanted to {2}, especially with the {3} near the {4}.",
|
|
||||||
"The {0} arrived Tuesday carrying a {1}. Together we would {2}, protect the {3}, and explore the {4}.",
|
|
||||||
"On Tuesday, my {0} transformed into a {1}. I needed to {2}, find the {3}, and unlock the {4}.",
|
|
||||||
],
|
|
||||||
'Wednesday': [
|
|
||||||
"By Wednesday, the {0} had found a {1}. The mission: {2}, retrieve the {3}, and guard the {4}.",
|
|
||||||
"Midweek magic: a {0} emerged from the {1}. We had to {2}, grab the {3}, and escape to the {4}.",
|
|
||||||
"Wednesday's {0} was hiding near the {1}. To {2} successfully, we needed the {3} and the {4}.",
|
|
||||||
],
|
|
||||||
'Thursday': [
|
|
||||||
"Thursday's {0} came with a {1}. Our plan: {2}, then move the {3} inside the {4}.",
|
|
||||||
"On Thursday, the {0} met the {1} unexpectedly. They decided to {2}, share the {3}, and visit the {4}.",
|
|
||||||
"The {0} adventure on Thursday led us to a {1}. We chose to {2}, carry the {3}, and discover the {4}.",
|
|
||||||
],
|
|
||||||
'Friday': [
|
|
||||||
"Friday arrived with a {0} and a {1}. Time to {2}, celebrate with the {3}, and toast the {4}!",
|
|
||||||
"TGIF! The {0} party featured a {1}. We would {2}, enjoy the {3}, and dance around the {4}.",
|
|
||||||
"Friday's surprise was a {0} inside a {1}. Everyone wanted to {2}, taste the {3}, and admire the {4}.",
|
|
||||||
],
|
|
||||||
'Saturday': [
|
|
||||||
"Saturday morning, the {0} journeyed to the {1}. Goals: {2}, collect the {3}, and protect the {4}.",
|
|
||||||
"Weekend mode: a {0} relaxing near a {1}. I chose to {2}, photograph the {3}, and sketch the {4}.",
|
|
||||||
"On Saturday, the legendary {0} appeared at the {1}. Heroes must {2}, wield the {3}, and defeat the {4}.",
|
|
||||||
],
|
|
||||||
'Sunday': [
|
|
||||||
"Sunday peace was broken by a {0} and a {1}. We needed to {2}, fix the {3}, and restore the {4}.",
|
|
||||||
"A quiet Sunday with my {0} near the {1}. Plans: {2} later, maybe find the {3}, or visit the {4}.",
|
|
||||||
"Sunday sunset revealed a {0} beside a {1}. Time to {2}, remember the {3}, and dream of the {4}.",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Extensions for 6+ word phrases
|
|
||||||
EXTENSIONS = [
|
|
||||||
[" Suddenly, a {5} appeared!"],
|
|
||||||
[" The {6} changed everything."],
|
|
||||||
[" Behind it was a {7}."],
|
|
||||||
[" Plus a mysterious {8}."],
|
|
||||||
[" The {9} completed the quest."],
|
|
||||||
[" A {10} watched from afar."],
|
|
||||||
[" And finally, the legendary {11}."],
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def generate_story_template(day: str, words: list[str]) -> str:
|
|
||||||
"""Generate story using templates (fallback method)."""
|
|
||||||
templates = STORY_TEMPLATES.get(day, STORY_TEMPLATES['Monday'])
|
|
||||||
template = random.choice(templates)
|
|
||||||
|
|
||||||
# Add extensions for longer phrases
|
|
||||||
for i, ext_list in enumerate(EXTENSIONS):
|
|
||||||
word_idx = i + 5
|
|
||||||
if len(words) > word_idx:
|
|
||||||
template += random.choice(ext_list)
|
|
||||||
|
|
||||||
# Pad words list to ensure we have enough for any template
|
|
||||||
padded_words = words + [''] * (12 - len(words))
|
|
||||||
|
|
||||||
return template.format(*padded_words)
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# MAIN API
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
def generate_story(day: str, words: list[str], use_ml: bool = True) -> dict:
|
|
||||||
"""
|
|
||||||
Generate a memorable story incorporating the passphrase words.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
day: Day of the week (e.g., 'Monday')
|
|
||||||
words: List of passphrase words
|
|
||||||
use_ml: Whether to try ML generation first
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict with 'story' (plain text) and 'story_html' (with highlighted words)
|
|
||||||
"""
|
|
||||||
story = None
|
|
||||||
used_ml = False
|
|
||||||
|
|
||||||
# Try ML first if requested
|
|
||||||
if use_ml and HAS_ML:
|
|
||||||
story = generate_story_ml(day, words)
|
|
||||||
if story:
|
|
||||||
used_ml = True
|
|
||||||
|
|
||||||
# Fall back to templates
|
|
||||||
if story is None:
|
|
||||||
story = generate_story_template(day, words)
|
|
||||||
|
|
||||||
# Generate HTML version with highlighted words (RED and CAPS)
|
|
||||||
html_story = story
|
|
||||||
for word in words:
|
|
||||||
# Case-insensitive replacement with highlighted version
|
|
||||||
pattern = re.compile(re.escape(word), re.IGNORECASE)
|
|
||||||
html_story = pattern.sub(
|
|
||||||
f'<span class="story-word">{word.upper()}</span>',
|
|
||||||
html_story
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
|
||||||
'story': story,
|
|
||||||
'story_html': html_story,
|
|
||||||
'used_ml': used_ml
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def generate_all_stories(phrases: dict[str, str], use_ml: bool = True) -> dict[str, dict]:
|
|
||||||
"""
|
|
||||||
Generate stories for all days.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
phrases: Dict mapping day names to phrase strings
|
|
||||||
use_ml: Whether to use ML generation
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Dict mapping day names to story dicts
|
|
||||||
"""
|
|
||||||
stories = {}
|
|
||||||
for day, phrase in phrases.items():
|
|
||||||
words = phrase.split()
|
|
||||||
stories[day] = generate_story(day, words, use_ml=use_ml)
|
|
||||||
return stories
|
|
||||||
Reference in New Issue
Block a user