Loki is an advanced AI-powered CTF (Capture The Flag) solver and security analysis assistant that combines the intelligence of Google's Gemini Flash model with a comprehensive suite of cybersecurity tools. Built with a modern terminal user interface (TUI), Loki helps security researchers, penetration testers, and CTF enthusiasts identify vulnerabilities, analyze code, and solve security challenges.
- Intelligent Security Analysis: Leverages Google Gemini Flash to reason about vulnerabilities, attack vectors, and security flaws
- Expert-Level Reasoning: Trained to think like a world-class security analyst, identifying bugs, logic errors, and common CVE-like vulnerabilities
- Interactive TUI: Beautiful terminal interface built with React and OpenTUI for seamless interaction
Loki includes a powerful set of security tools organized into several categories:
- Subdomain enumeration (Amass)
- DNS interrogation (A, AAAA, MX, TXT, NS, SOA, CNAME records)
- WHOIS lookups
- Search engine dorking (Google, Bing, DuckDuckGo, Shodan, Censys)
- Certificate transparency search (crt.sh)
- Shodan and Censys integration
- Port scanning (Nmap, Masscan, RustScan)
- Web directory bruteforcing (Gobuster, ffuf)
- Web vulnerability scanning (OWASP ZAP)
- Network vulnerability scanning
- Service version detection
- Metasploit Framework integration
- SQL injection exploitation (SQLMap)
- XSS fuzzing and testing
- Custom exploit module execution
- Static Application Security Testing (SAST) with Semgrep
- CodeQL analysis for multiple languages
- Secret discovery (Bandit, TruffleHog)
- Dependency vulnerability checking
- Source code security analysis
- Execute shell commands directly
- File system exploration
- System information gathering
- Custom tool execution
- Bun (JavaScript runtime)
- Node.js 18+ (if not using Bun)
- Python 3.8+ (for Python tools)
- Google API key for Gemini
-
Clone the repository
git clone <repository-url> cd ctf-solver
-
Install dependencies
bun install
-
Configure environment variables
Create a
.envfile in the root directory:GOOGLE_GENERATIVE_AI_API_KEY=your_api_key_here # Optional: For advanced features SHODAN_API_KEY=your_shodan_key CENSYS_UID=your_censys_uid CENSYS_SECRET=your_censys_secret MSF_USER=metasploit_user MSF_PASSWORD=metasploit_password -
Install Python dependencies (for Python tools)
pip install -r requirements.txt # If available # Or install individually: pip install fastmcp dnspython python-whois requests shodan pymetasploit3 python-nmap
bun devThis will:
- Start the local chat API server on
http://localhost:3001 - Launch the TUI interface
- Connect to Google Gemini Flash model
- Query
GET /healthfor a structured status payload that now includes log summaries, skill-loading insights, and helpful recovery notes. - Use
GET /logs?level=infoto stream recent log entries when debugging issues reported by the diagnostics block.
- Type your query: Enter your security question, CTF challenge description, or analysis request
- Press Enter: Submit your message
- Press ESC: Stop the current operation or exit the application
- Ctrl+C: Exit the application
- "Analyze this code for SQL injection vulnerabilities: [code snippet]"
- "Perform a port scan on 192.168.1.100"
- "Enumerate subdomains for example.com"
- "Find secrets in this codebase: /path/to/code"
- "Help me solve this CTF challenge: [description]"
- Enable the feature by setting
LOKI_SKILLS=truebefore starting Loki. - Skill files now live inside this repo under
skills/**/SKILL.mdby default, so you can keep your procedural knowledge versioned alongside Loki. Each file needs YAML front matter withname(≤100 chars) anddescription(≤500 chars); the body remains on disk until the skill is triggered. - Custom directories are supported via
LOKI_SKILLS_DIR=/path/to/skillsif you want to relocate skills elsewhere. - Loki lists each discovered skill in the runtime prompt so the agent can mention available helpers without loading their full bodies.
- Invalid skill files are skipped with a warning logged in the terminal; fix the front matter and restart to reload them.
Loki is built with:
- Frontend: React + OpenTUI for the terminal interface
- Backend: Bun HTTP server with AI SDK integration
- AI Model: Google Gemini Flash (via
@ai-sdk/google) - Tools: Modular tool system supporting both TypeScript and Python tools
- Communication: RESTful API for chat interactions
Loki uses a flexible tool system that allows the AI to:
- Execute shell commands via the
local_shelltool - Call Python tools for specialized security operations (recon, scanning, exploitation, analysis)
- Chain operations together to perform complex security assessments
The AI automatically selects and uses the appropriate tools based on your queries.
- Only use Loki on systems you own or have explicit permission to test
- Be aware that some tools (port scanning, exploitation) may be illegal if used without authorization
- Always follow responsible disclosure practices
- Review and understand what commands Loki executes before running them
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
[Add your license here]
- Built with OpenTUI for the terminal interface
- Powered by Vercel AI SDK and Google Gemini
- Inspired by the CTF and security research community
Happy Hacking! 🚀