AI-Powered Python & Python-Powered AI
AIPen is a secondary development project based on the aipyapp framework. It inherits the Agent 2.0 (Code is Agent) paradigm and is specifically tailored for Automated Web CTF Penetration Testing.
Instead of relying on rigid, pre-defined workflow nodes or heavily constrained tools, AIPen provides LLMs with a complete Python execution sandbox. The AI acts as a Security Commander, dynamically writing, executing, and correcting Python/Shell payloads to exploit vulnerabilities and capture flags.
Task → Plan → Code → Execute → Feedback
We have transformed the original generic AI Python interpreter into a highly specialized, parallel-capable penetration testing agent:
-
The "Commander" Architecture (SubTask Concurrency)
- The AI is no longer a single-threaded executioner blocked by slow network IO.
- It acts as a Commander, dispatching multiple asynchronous
SubTaskagents to perform parallel reconnaissance (e.g., fuzzing directories and testing SQL injections simultaneously). - Supports Heterogeneous Model Scheduling: Use expensive models (like GPT-4o) for reasoning and planning, while delegating repetitive tasks to faster, cheaper models (like
gpt-4o-minior localollama).
-
CTF Hacker Role & Context Isolation
- Built-in
CTF_Hackerrole prompt, trained with Web security methodology. - SubTask isolation prevents long, messy HTTP error logs from polluting the main Agent's reasoning context.
- Built-in
-
Advanced Security Plugins (
p_security_tools)- Equipped with high-performance, asynchronous fuzzing capabilities (
concurrent_fuzz) to bypass WAFs and test blind injections at scale. - Built-in payload encoding/decoding and proxy-aware request tools.
- Equipped with high-performance, asynchronous fuzzing capabilities (
-
MCP (Model Context Protocol) Integration
- Seamlessly integrates with professional security scanners (like Nmap, Sqlmap, Xray) via MCP, allowing the AI to consume structured vulnerability data rather than parsing raw terminal text.
Traditional AI (Agent 1.0) relies on Function Calling, Tools, MCP-Servers, Workflows, and plugin-based clients. These external "prosthetics" lead to high entry barriers and poor coordination between tools.
Python-Use introduces a radically simplified execution architecture: No Agents, No Workflow, No Clients… Code is Agent.
It gives models two core capabilities:
- API Calling: Automatically generate and execute Python code to invoke APIs.
- Packages Calling: Flexibly leverage Python's ecosystem (e.g.,
requests,pwntools) to orchestrate workflows.
Because the AI executes dynamically generated exploit scripts, we strongly recommend running AIPen in an isolated Docker container.
- Build the image:
docker build -t aipyapp/aipy:latest -f docker/Dockerfile . - Run the Agent:
# Standard interactive mode ./docker/run.sh - Switch to CTF Mode:
Once inside the terminal, activate the hacker role:
/role ctf_hacker
- Install dependencies using
uv:pip install uv uv sync
- Launch with CTF Role:
uv run aipy --role ctf_hacker
You:
"The target is
http://192.168.1.100/login.php. Please analyze the vulnerabilities and get the/flag."
AIPen Commander:
- Plan: Dispatch SubTask 1 to fuzz hidden directories. Dispatch SubTask 2 to test SQL injection on the login form.
- Execute: SubTasks run asynchronously using
concurrent_fuzz. - Feedback: SubTask 2 reports a syntax error indicating SQL injection.
- Code: Main Agent writes a customized Python script to exploit the blind SQL injection.
- Result:
flag{ai_is_the_new_hacker}captured.
- Sandboxing Required: The code generated by AI is unpredictable. Do not run this tool on your host machine with administrative privileges.
- Network Isolation: Restrict the Docker container's network access strictly to the target CTF environment to prevent unintended attacks on internal or external networks.
- Authorized Use Only: This tool is designed strictly for educational purposes, CTF competitions, and authorized penetration testing.
- Original
aipyappframework by the Python-use community. - AIPy: https://www.aipy.app/