LLM-Powered Automated Web Application Exploit Generator with Allow-List Safety Controls
This project implements an AI-powered security testing tool that automatically discovers and exploits web application vulnerabilities while maintaining strict safety controls through an allow-list mechanism. The system leverages Large Language Models (LLMs) to generate intelligent exploit payloads and provides comprehensive vulnerability reports.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββββ β
β β TargetForm β β StatusCard β β ReportViewer β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HTTP/REST API
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend (FastAPI) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Scan Pipeline β β
β β Phase 1: Allow-List Check β Phase 2: Crawling β β
β β Phase 3: Exploit Generation β Phase 4: Execution & Report β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ β
β β Allow-List β β Crawler Service β β Context β β
β β Checker β β (Playwright) β β Detector β β
β ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ β
β β
β ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ β
β β LLM Service β β Execution β β Reporting β β
β β (OpenAI GPT-4) β β Service β β Service β β
β ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Database (PostgreSQL) β
β AllowListEntry β ScanHistory β GeneratedReport β LLMInteractionβ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Backend:
- Python 3.9
- FastAPI (REST API framework)
- SQLAlchemy (ORM)
- PostgreSQL (Database)
- Playwright (Web automation)
- OpenAI API (LLM integration)
- Pydantic (Data validation)
Frontend:
- React 18.2
- JavaScript (ES6+)
- CSS3
- Fetch API
Infrastructure:
- Docker & Docker Compose
- Multi-container orchestration
Before you begin, ensure you have the following installed:
-
Docker Desktop (includes Docker Compose)
- Windows: Download from https://www.docker.com/products/docker-desktop
- Minimum version: Docker 20.10+, Docker Compose 2.0+
-
OpenAI API Key (for LLM functionality)
- Sign up at https://platform.openai.com/
- Generate an API key from your account dashboard
-
Git (to clone the repository)
- Windows: Download from https://git-scm.com/
git clone https://github.com/AMR-M-ALSHAMEERI/LLM-Safe-Exploit-Generator.git
cd LLM-Safe-Exploit-GeneratorBackend Configuration:
# Copy the example environment file
cp backend\.env.example backend\.env
# Edit backend\.env and add your OpenAI API key
# Use notepad or any text editor:
notepad backend\.envUpdate the following in backend\.env:
OPENAI_API_KEY=sk-your-actual-api-key-here
SECRET_KEY=your-random-secret-key-hereFrontend Configuration:
# Copy the example environment file
cp frontend\.env.example frontend\.env
# No changes needed unless you modify ports# Build all Docker containers (first time only - may take 5-10 minutes)
docker-compose build
# Start all services
docker-compose upWait for the services to start:
- Backend API:
http://localhost:8000 - Frontend UI:
http://localhost:3000 - Database:
localhost:5432
You should see logs indicating:
backend_1 | INFO: Uvicorn running on http://0.0.0.0:8000
frontend_1 | Compiled successfully!
db_1 | database system is ready to accept connections
- Open your browser and navigate to: http://localhost:3000
- You should see the "LLM-Safe-Exploit-Generator" interface
Before scanning any target, you MUST add it to the allow-list:
Option A: Using the API directly
# Add a test target to the allow-list
Invoke-RestMethod -Uri "http://localhost:8000/api/v1/admin/allow-list" `
-Method POST `
-ContentType "application/json" `
-Body '{"domain": "testphp.vulnweb.com", "description": "Test vulnerability site", "added_by": "admin"}'Option B: Using curl (if installed)
curl -X POST "http://localhost:8000/api/v1/admin/allow-list" `
-H "Content-Type: application/json" `
-d '{\"domain\": \"testphp.vulnweb.com\", \"description\": \"Test vulnerability site\", \"added_by\": \"admin\"}'Option C: Using a REST client
- Install Postman or similar tool
- POST to
http://localhost:8000/api/v1/admin/allow-list - Body:
{"domain": "testphp.vulnweb.com", "description": "Test site", "added_by": "admin"}
-
In the web UI at
http://localhost:3000, enter a target URL:http://testphp.vulnweb.com -
Click "Start Scan"
-
Monitor the progress (the UI will poll automatically)
-
View the comprehensive vulnerability report when complete
-
Add allow-list entry:
Invoke-RestMethod -Uri "http://localhost:8000/api/v1/admin/allow-list" ` -Method POST ` -ContentType "application/json" ` -Body '{"domain": "testphp.vulnweb.com", "description": "Test site", "added_by": "tester"}'
-
Start a scan via UI:
- Navigate to
http://localhost:3000 - Enter:
http://testphp.vulnweb.com - Click "Start Scan"
- Navigate to
-
Expected Results:
- Status changes:
pendingβin_progressβcompleted - Report shows discovered vulnerabilities with:
- Severity level (Critical/High/Medium/Low)
- Proof of Concept (PoC)
- Mitigation recommendations
- MITRE ATT&CK mapping
- Status changes:
-
Try to scan a non-allowed domain:
- Enter:
http://google.com - Click "Start Scan"
- Enter:
-
Expected Result:
- Error message: "Target not in allow-list"
- Scan status:
failed - No scan execution (safety mechanism works)
# Check if backend is healthy
Invoke-RestMethod -Uri "http://localhost:8000/health"
# Expected output:
# status: healthy
# database: connected
# timestamp: <current time># List all allowed domains
Invoke-RestMethod -Uri "http://localhost:8000/api/v1/admin/allow-list"If you prefer to run services outside Docker:
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
.\venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txt
# Install Playwright browsers
playwright install chromium
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# Run database migrations (ensure PostgreSQL is running)
# Create database manually or use:
# CREATE DATABASE exploit_generator;
# Start the backend server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000cd frontend
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Start development server
npm start# Install PostgreSQL (if not using Docker)
# Download from: https://www.postgresql.org/download/windows/
# Create database
psql -U postgres
CREATE DATABASE exploit_generator;
\q
# Update DATABASE_URL in backend/.env
# DATABASE_URL=postgresql://postgres:your_password@localhost:5432/exploit_generator# Stop all services
docker-compose down
# Stop and remove all data (including database)
docker-compose down -v
# View logs
docker-compose logs -f
# View logs for specific service
docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f db
# Rebuild after code changes
docker-compose up --build
# Run backend tests (when implemented)
docker-compose exec backend pytest
# Access PostgreSQL database
docker-compose exec db psql -U postgres -d exploit_generator
# Execute commands in backend container
docker-compose exec backend bash
# Execute commands in frontend container
docker-compose exec frontend shOnce the backend is running, access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Allow-List Control: Only pre-approved domains can be scanned
- Fail-Safe Design: Blocks execution if target is not in allow-list
- Audit Logging: All scans and LLM interactions are logged
- Sandboxed Execution: Playwright runs in isolated browser contexts
- Rate Limiting: Prevents resource exhaustion
- Input Validation: Pydantic schemas validate all inputs
LLM-Safe-Exploit-Generator/
βββ backend/
β Β βββ app/
β Β β Β βββ api/
β Β β Β β Β βββ endpoints/
β Β β Β β Β Β Β βββ admin.py Β Β Β Β Β # Allow-list CRUD
β Β β Β β Β Β Β βββ scan.py Β Β Β Β Β # Scan orchestration
β Β β Β βββ modules/
β Β β Β β Β βββ allow_list_checker.py # Safety control
β Β β Β β Β βββ crawler_service.py Β Β # Web crawling
β Β β Β β Β βββ context_detector.py Β # Vulnerability detection
β Β β Β β Β βββ llm_service.py Β Β Β Β # LLM integration
β Β β Β β Β βββ execution_service.py Β # Payload execution
β Β β Β β Β βββ reporting_service.py Β # Report generation
β Β β Β βββ database.py Β Β Β Β Β Β Β # DB connection
β Β β Β βββ models.py Β Β Β Β Β Β Β Β # SQLAlchemy models
β Β β Β βββ schemas.py Β Β Β Β Β Β Β Β # Pydantic schemas
β Β β Β Β Β βββ main.py Β Β Β Β Β Β Β Β Β # FastAPI app
β Β βββ Dockerfile
β Β βββ requirements.txt
β Β βββ .env.example
βββ frontend/
β Β βββ public/
β Β β Β βββ index.html
β Β βββ src/
β Β β Β βββ components/
β Β β Β β Β βββ TargetForm.js Β Β Β Β # URL input form
β Β β Β β Β βββ TargetForm.css
β Β β Β β Β βββ ReportViewer.js Β Β Β # Results display
β Β β Β β Β βββ ReportViewer.css
β Β β Β βββ services/
β Β β Β β Β βββ api.js Β Β Β Β Β Β Β Β # API client
β Β β Β βββ App.js Β Β Β Β Β Β Β Β Β Β # Main component
β Β β Β βββ App.css
β Β β Β βββ index.js Β Β Β Β Β Β Β Β Β # Entry point
β Β β Β βββ index.css
β Β βββ Dockerfile
β Β βββ package.json
β Β βββ .env.example
βββ docker-compose.yml
βββ .gitignore
βββ LICENSE
βββ README.md
To run the automated tests:
- Ensure Docker containers are running
- Execute the test script:
# For Linux/Mac
./scripts/test.sh
# For Windows
.\scripts\test.ps1- Outputs are saved in
tests/results/ - JSON files contain detailed test reports
- Ensure sufficient permissions are granted for test execution
- Review
tests/README.mdfor test structure and guidelines
For production deployment using Docker:
- Build the images:
docker-compose build --no-cache
- Start the containers:
docker-compose up -d
- Monitor logs:
docker-compose logs -f
For manual deployment without Docker:
- Set up Python virtual environment
- Install dependencies:
pip install -r backend/requirements.txt - Configure environment variables in
backend/.env - Run database migrations:
alembic upgrade head - Start the FastAPI server:
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
Solution:
# Remove all containers and volumes
docker-compose down -v
# Rebuild from scratch
docker-compose build --no-cache
# Start again
docker-compose upSolution:
# Check if PostgreSQL container is running
docker-compose ps
# View database logs
docker-compose logs db
# Restart database service
docker-compose restart dbSolution:
- Check
frontend/.envhas correct API URL:REACT_APP_API_BASE_URL=http://localhost:8000 - Ensure backend is running:
docker-compose logs backend - Check CORS settings in
backend/.env
Solution:
- Ensure you've created
backend/.envfrom.env.example - Add your OpenAI API key:
OPENAI_API_KEY=sk-... - Restart backend:
docker-compose restart backend
Solution: This is expected behavior! Add the target domain to the allow-list first:
Invoke-RestMethod -Uri "http://localhost:8000/api/v1/admin/allow-list" `
-Method POST `
-ContentType "application/json" `
-Body '{"domain": "your-target-domain.com", "description": "Test", "added_by": "admin"}'Solution:
# Access backend container
docker-compose exec backend bash
# Manually install browsers
playwright install chromium
# Exit and restart
exit
docker-compose restart backendThe system currently detects and generates exploits for:
-
SQL Injection (SQLi)
- Union-based
- Boolean-based blind
- Time-based blind
-
Cross-Site Scripting (XSS)
- Reflected XSS
- DOM-based XSS
- Stored XSS
-
Command Injection
- OS command injection
- Code injection
-
Path Traversal
- Directory traversal
- Local file inclusion (LFI)
-
Server-Side Request Forgery (SSRF)
- Internal network scanning
- Cloud metadata access
This tool is designed for EDUCATIONAL PURPOSES ONLY and AUTHORIZED SECURITY TESTING.
- β Use on systems you own or have explicit written permission to test
- β Use in controlled lab environments
- β Use for security research and learning
- β DO NOT use on systems without authorization
- β DO NOT use for malicious purposes
- β DO NOT bypass the allow-list safety mechanism
Unauthorized access to computer systems is illegal and punishable by law.
This project is licensed under the MIT License - see the LICENSE file for details.
AMR M. ALSHAMEERI
- GitHub: @AMR-M-ALSHAMEERI
- Final Year Project - 2025
- OpenAI for GPT-4 API
- FastAPI framework
- React.js library
- Playwright automation framework
- OWASP for vulnerability classifications
- MITRE ATT&CK framework
###π Support
For issues, questions, or contributions:
- Open an issue on GitHub
- Check existing documentation
- Review API documentation at
/docs
Happy (Ethical) Hacking! π‘οΈ LLM-Powered Automated Web Application Exploit Generator with Allow-List Safety Controls