Skip to content

Commit f9033a8

Browse files
committed
chore(init): repository
0 parents  commit f9033a8

50 files changed

Lines changed: 1157 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
OPENAI_API_KEY=""
2+
OPENAI_MODEL_NAME="gpt-4-turbo"
3+
GEMINI_API_KEY=""
4+
GEMINI_MODEL_NAME="gemini-1.5-pro"
5+
OPENROUTER_API_KEY=""
6+
OPENROUTER_MODEL_NAME="anthropic/claude-3-opus"
7+
8+
# add your own custom providers
9+
# DGRID_API_KEY=
10+
# or any other key names.

.gitignore

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
env/
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
wheels/
20+
share/python-wheels/
21+
*.egg-info/
22+
.installed.cfg
23+
*.egg
24+
MANIFEST
25+
26+
# Environment Variables
27+
.env
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# Virtual environments
34+
venv/
35+
.venv/
36+
env/
37+
.env/
38+
ENV/
39+
env.bak/
40+
venv.bak/
41+
42+
# SQLite Databases (Local Memory)
43+
*.db
44+
*.sqlite
45+
*.sqlite3
46+
pentest_memory.db
47+
48+
# IDEs & OS Files
49+
.vscode/
50+
.idea/
51+
*.swp
52+
*.swo
53+
.DS_Store
54+
Thumbs.db
55+
56+
# Logs and Output Reports
57+
*.log
58+
reports/
59+
logs/
60+
61+
pentest_report.pdf

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Contributing to AI Agentic Pentesting Framework
2+
3+
We welcome contributions to this project!
4+
5+
## Development Setup
6+
7+
1. Fork and clone the repository.
8+
2. Install the required dependencies: `pip install -r requirements.txt`
9+
3. We use `make` to manage tasks. See the `Makefile` for available commands.
10+
11+
## Adding a New Tool
12+
13+
1. Create a new module in `watchtower/tools/`.
14+
2. Implement a Python wrapper for the tool that returns the raw output and structured data.
15+
3. Expose the tool to the `Worker` node in `watchtower/agents/worker.py`.
16+
17+
## Adding a New Specialized Agent
18+
19+
1. Create a new module in `watchtower/agents/`.
20+
2. Define the agent's prompts and expected output (using Pydantic/JSON).
21+
3. Connect the agent into the LangGraph state machine in `watchtower/core/agent_manager.py`.
22+
23+
Please ensure that you do not remove any guardrails preventing out-of-scope testing.

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM python:3.11-slim
2+
3+
# Install system dependencies and security tools
4+
RUN apt-get update && apt-get install -y \
5+
nmap \
6+
masscan \
7+
curl \
8+
wget \
9+
git \
10+
make \
11+
dnsutils \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Install Nuclei (example of installing a Go-based tool from binaries)
15+
# Note: In a complete production image, you would add more tools (httpx, subfinder, etc.)
16+
RUN wget https://github.com/projectdiscovery/nuclei/releases/download/v3.0.0/nuclei_3.0.0_linux_amd64.zip \
17+
&& apt-get update && apt-get install -y unzip \
18+
&& unzip nuclei_3.0.0_linux_amd64.zip \
19+
&& mv nuclei /usr/local/bin/ \
20+
&& rm nuclei_3.0.0_linux_amd64.zip
21+
22+
WORKDIR /app
23+
24+
COPY requirements.txt .
25+
26+
RUN pip install --no-cache-dir -r requirements.txt
27+
28+
COPY . .
29+
30+
# Run the framework
31+
CMD ["python", "-m", "watchtower.main"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 fzn0x
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.PHONY: install test run docker-build docker-up docker-down
2+
3+
install:
4+
pip install -r requirements.txt
5+
6+
test:
7+
python -m unittest discover -s tests
8+
9+
run:
10+
@if [ -z "$(TARGET)" ]; then \
11+
echo "Usage: make run TARGET=https://example.com"; \
12+
exit 1; \
13+
fi
14+
python -m watchtower.main -t $(TARGET)
15+
16+
docker-build:
17+
docker-compose build
18+
19+
docker-up:
20+
docker-compose up
21+
22+
docker-down:
23+
docker-compose down

README.md

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
![Watchtower](assets/imgs/watchtower.png)
2+
3+
# 🏰 Watchtower (AI-Powered Penetration Testing Framework)
4+
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
6+
[![Python 3.11+](https://img.shields.io/badge/Python-3.11%2B-brightgreen.svg?style=flat-square&logo=python)](https://www.python.org/downloads/)
7+
[![Architecture](https://img.shields.io/badge/Architecture-LangGraph-orange.svg?style=flat-square)](https://langchain-ai.github.io/langgraph/)
8+
[![LLMs](https://img.shields.io/badge/LLMs-Claude%20%7C%20Gemini%20%7C%20GPT-purple.svg?style=flat-square)]()
9+
10+
**Watchtower** is a simple AI-powered penetration testing automation CLI tool that leverages LLMs and LangGraph to orchestrate agentic workflows that you can use to test your websites locally. Generate useful pentest reports for your websites.
11+
12+
Penetration testing is red team activity and should be done with permission.
13+
14+
<p align="center">
15+
<br>
16+
<a href="#✨-core-features">Features</a> •
17+
<a href="#2-💻-installation">Installation</a> •
18+
<a href="#🚀-quick-start">Quick Start</a> •
19+
<a href="#❓-faq--troubleshooting">FAQ</a> •
20+
<a href="#📄-license">License</a>
21+
</p>
22+
23+
## ⚠️ Legal Disclaimer
24+
25+
**Watchtower is designed exclusively for authorized security testing and educational purposes.**
26+
27+
- **Legal Use:** Authorized penetration testing, security research, educational environments.
28+
- **Illegal Use:** Unauthorized access, malicious activities, any form of cyber attack.
29+
30+
You are fully responsible for ensuring you have explicit written permission before testing any system. Unauthorized access to computer systems is illegal under laws including the Computer Fraud and Abuse Act (CFAA), GDPR, and equivalent international legislation.
31+
32+
By using Watchtower, you agree to use it only on systems you own or have explicit authorization to test.
33+
34+
## ✨ Core Features
35+
36+
- **Multi-Agent Architecture**:
37+
- `Planner`: Analyzes the target and current findings to strategize the next sequence of actions.
38+
- `Worker`: Dynamically executes tools requested by the Planner.
39+
- `Analyst`: Parses tool stdout/stderr, filters false positives, and converts raw findings into structured schema data.
40+
- **Dynamic Tool Arsenal**: Integrated with 23 security tools using Python subprocess wrappers. The interactive CLI auto-checks your PATH and lets you exclude tools dynamically.
41+
- *Network*: `nmap`, `masscan`
42+
- *Web Recon*: `httpx`, `whatweb`, `wafw00f`
43+
- *Subdomain*: `subfinder`, `amass`, `dnsrecon`
44+
- *Vulnerability*: `nuclei`, `nikto`, `sqlmap`, `wpscan`, `retire.js`
45+
- *SSL/TLS*: `testssl.sh`, `sslyze`
46+
- *Content/Params*: `gobuster`, `ffuf`, `arjun`, `kiterunner`
47+
- *Security Analysis*: `xsstrike`, `gitleaks`, `cmseek`, `dalfox`
48+
- **State Management**: Uses `SQLite` locally to store a historical record of observations and findings.
49+
- **LLM Agnostic**: Seamlessly swap between OpenAI, Google Gemini, and OpenRouter APIs via `.env` files.
50+
51+
---
52+
53+
## 🚀 Quick Start
54+
55+
### 1. 📋 Requirements & Prerequisites
56+
57+
**Prerequisites:**
58+
- **OS**: Linux or macOS recommended (Windows supported via WSL2 for some networking tools).
59+
- **Python**: 3.11+ installed.
60+
- **API Keys**: An active API key for OpenRouter, OpenAI, or Gemini.
61+
62+
**Tool Requirements:**
63+
To utilize the AI's full capabilities, you must have the actual CLI binaries installed and accessible in your system `PATH` (e.g., `nmap`, `nuclei`, `httpx`). The framework will automatically detect which tools are missing and skip them in the UI.
64+
65+
### 2. 💻 Installation
66+
67+
```bash
68+
git clone https://github.com/fzn0x/watchtower.git
69+
cd watchtower
70+
71+
python -m venv venv
72+
source venv/bin/activate # On Windows: venv\Scripts\activate
73+
pip install -r requirements.txt
74+
```
75+
76+
### 3. ⚙️ Configuration
77+
78+
```bash
79+
cp .env.example .env
80+
```
81+
Populate `.env` with your API keys. You only need to fulfill **one** of the API setups:
82+
- `OPENAI_API_KEY=""`
83+
- `GEMINI_API_KEY=""`
84+
- `OPENROUTER_API_KEY=""`
85+
86+
*(Optional)* Explicitly define which model strings the framework should use. Defaults are already configured:
87+
- `OPENAI_MODEL_NAME="gpt-4-turbo"`
88+
- `GEMINI_MODEL_NAME="gemini-1.5-pro"`
89+
- `OPENROUTER_MODEL_NAME="anthropic/claude-3-opus"`
90+
91+
### 4. ▶️ Running the Framework
92+
93+
You **must** specify a target URL or IP using the `-t` or `--target` flag.
94+
95+
```bash
96+
python -m watchtower.main -t https://www.example.com
97+
```
98+
99+
Upon execution, Watchtower will display an interactive CLI checkbox prompt. It automatically highlights which of the 23 tools are successfully installed on your machine. You can use `<Space>` to enable/disable specific tools allowing you to narrowly focus the LLM's payload, or hit `<Enter>` to confirm the selection.
100+
101+
**Headless Mode:**
102+
If you want to bypass the interactive menu or are integrating Watchtower into an automated CI/CD pipeline, use the `--skip-ask-tools` flag to auto-run with everything available on your PATH:
103+
```bash
104+
python -m watchtower.main -t https://www.example.com --skip-ask-tools
105+
```
106+
107+
## 📊 Generating Reports
108+
109+
Watchtower automatically stores all executed commands, terminal outputs, and confirmed vulnerabilities in a local SQLite memory file (`pentest_memory.db`).
110+
111+
You can extract all findings into a cleanly formatted PDF document without re-running the pentest:
112+
```bash
113+
python -m watchtower.main --report "pentest_report.pdf"
114+
```
115+
116+
### 5. 🔌 Custom Providers
117+
118+
Watchtower dynamically supports almost any LLM provider on the market via LangChain and LiteLLM integrations. You can override the default models from the CLI using the `--provider`, `--model`, and `--apikey` flags.
119+
120+
```bash
121+
python -m watchtower.main -t https://www.example.com --provider=https://api.dgrid.ai --model=anthropic/claude-opus-4.5 --apikey "API_KEY"
122+
```
123+
124+
Example response (using httpx tool):
125+
126+
```bash
127+
INFO: ==> Node Executed: [WORKER]
128+
INFO: HTTP Request: POST https://api.dgrid.ai/api/v1/chat/completions "HTTP/1.1 200 OK"
129+
INFO: ==> Node Executed: [ANALYST]
130+
INFO: - Updated state 'findings': [{'title': 'Overly Permissive CORS Configuration', 'severity': 'Medium', 'description': 'The server is configured with Access-Control-Allow-Origin: * which allows any website to make cross-origin requests to this domain. This could potentially allow malicious websites to interact with the API on behalf of authenticated users, leading to data theft or unauthorized actions if sensitive endpoints exist.', 'evidence': 'Access-Control-Allow-Origin: *\naccess-control-allow-headers: *\naccess-control-allow-methods: GET, HEAD, OPTIONS'}, {'title': 'Missing Security Headers', 'severity': 'Low', 'description': 'The response is missing several recommended security headers including X-Frame-Options (clickjacking protection), Content-Security-Policy (XSS and injection protection), and Strict-Transport-Security (HSTS for enforcing HTTPS). While some headers like X-Content-Type-Options and Referrer-Policy are present, the absence of these headers reduces the overall security posture.', 'evidence': 'HTTP/1.1 200 OK\nDate: Fri, 27 Feb 2026 13:28:07 GMT\nContent-Type: text/html; charset=utf-8\n[Headers present: x-content-type-options: nosniff, referrer-policy: strict-origin-when-cross-origin]\n[Missing: X-Frame-Options, Content-Security-Policy, Strict-Transport-Security]'}]
131+
```
132+
133+
> ⚠️ **Disclaimer:** The `--apikey` argument requires the exact **property name** of the variable stored inside your `.env` file (e.g., `MY_GROQ_KEY`), *not* the raw API key string itself. This prevents your secrets from leaking into bash history.
134+
135+
**Supported Providers Include:**
136+
- Anthropic
137+
- OpenAI
138+
- OpenRouter
139+
- Litellm
140+
- Amazon Bedrock
141+
- Vercel AI Gateway
142+
- Moonshot AI
143+
- Mistral
144+
- MiniMax
145+
- OpenCode Zen
146+
- GLM Models
147+
- Z.AI
148+
- Synthetic
149+
- Qianfan
150+
- **Any custom HTTP URLs** (Acts as a drop-in OpenAI-compatible endpoint, automatically routing requests via LangChain's `ChatOpenAI` client)
151+
- Others: https://docs.litellm.ai/docs/providers
152+
153+
**Example CLI Execution (Custom Endpoint):**
154+
```bash
155+
python -m watchtower.main -t https://example.com --provider=https://api.dgrid.ai/api/v1 --model=anthropic/claude-opus-4.5 --apikey "API_KEY"
156+
```
157+
158+
---
159+
160+
## 🗺️ Roadmap
161+
162+
- [x] Initial LangGraph Planner/Worker architecture.
163+
- [x] Integrate core web and network reconnaissance tools.
164+
- [x] Add Pydantic structured output fallback for open-source OpenRouter models.
165+
- [ ] Add support for authenticated pentesting workflows (e.g cookie injection).
166+
167+
---
168+
169+
## 📌 Important Notes
170+
171+
- **API Costs**: The multi-agent workflow consumes tokens rapidly during active scanning as the Planner loops through observations. Be mindful of your API budgets.
172+
- **Hallucinations**: While the Analyst agent filters false positives, LLMs can still hallucinate conclusions based on ambiguous tool outputs. **Always manually verify findings.**
173+
- **Network Stability**: Some tools (like `masscan` or `ffuf`) are extremely noisy. You may trigger upstream edge-protections (Cloudflare) on your targets, which will pollute the observation logs with 403s.
174+
175+
---
176+
177+
## ❓ FAQ & Troubleshooting
178+
179+
### Q: `model: [model_name] does not support feature: structured-outputs`
180+
This error occurs when using experimental, free, or unsupported models via OpenRouter (e.g. some Qwen or DeepSeek variants). Watchtower relies on LangChain's Structured Outputs mechanism to force the AI to return perfectly formatted JSON objects. If you see this error, switch your `OPENROUTER_MODEL_NAME` in the `.env` file to a fully-supported model like:
181+
- `anthropic/claude-3.5-sonnet`
182+
- `openai/gpt-4o`
183+
- `google/gemini-1.5-pro`
184+
- `meta-llama/llama-3.1-70b-instruct`
185+
186+
*Note: The framework includes a custom string-fallback parser for models that don't natively support API structured outputs, but using supported commercial models yields significantly better pentesting logic.*
187+
188+
### Q: `429 Too Many Requests: [model]:free is temporarily rate-limited upstream`
189+
This means you are using an explicitly `:free` model tier on OpenRouter, and the upstream providers (like Venice or Novita) are currently rate-limiting free-tier requests due to high global traffic. You simply need to wait out the timeout or switch to a slightly different (or paid) model endpoint.
190+
191+
---
192+
193+
## 📄 License
194+
195+
This project is licensed under the **MIT License**. See the `LICENSE` file for details.
196+
197+
By using this software, you agree to the conditions outlined in the [Legal Disclaimer](#-legal-disclaimer). Watchtower's developers assume no liability for the misuse of this tool.
198+
199+
---
200+
201+
## 🙏 Author & Acknowledgements
202+
203+
Created and maintained by **[fzn0x](https://github.com/fzn0x)**.
204+
205+
A deep and sincere thank you to the open-source security community. Watchtower stands on the shoulders of giants—this framework would not exist without the incredible developers who built and maintain the underlying penetration testing and reconnaissance tools that power the core worker engine. Thank you for making security accessible.

0 commit comments

Comments
 (0)