Skip to content

0xb4bal/specter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SPECTER β€” HTB Penetration Testing Agent

Autonomous Hack The Box agent powered by Hermes + DeepSeek V4 Pro

Hermes DeepSeek HTB Telegram License

 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
 β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘        β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
 β•šβ•β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘        β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘
 β•šβ•β•β•β•β•β•β•β•šβ•β•     β•šβ•β•β•β•β•β•β• β•šβ•β•β•β•β•β•   β•šβ•β•   β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•

SPECTER is a fully autonomous HTB penetration testing agent built on Hermes Agent β€” the self-improving AI agent framework from Nous Research. Unlike Claude Code-based agents, SPECTER has persistent cross-session memory, self-improving skills, Telegram-native notifications, and automatic IP continuity when HTB resets machines.


Why Hermes Over Claude Code

Feature Claude Code SPECTER (Hermes)
Memory across sessions ❌ Starts blank every time βœ… MEMORY.md β€” persists every finding
Self-improving skills ❌ Static skill files βœ… Skills patch themselves after each machine
Cross-session search ❌ No history βœ… FTS5 SQLite β€” recall any past session
Telegram interface ❌ Terminal only βœ… Native gateway β€” full conversation from phone
Cron automation ❌ Manual triggers only βœ… Scheduled IP monitor, auto-checkpoint
IP change handling ❌ Manual /etc/hosts edit βœ… HTB API auto-resolves, zero user input
Flag auto-submission ❌ Manual βœ… Regex detects + submits via HTB API
Context window recovery ❌ Start over βœ… Checkpoint every 8 iterations, resume anywhere

How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      SPECTER LOOP                       β”‚
β”‚                                                         β”‚
β”‚  Telegram ──► Hermes Gateway ──► DeepSeek V4 Pro        β”‚
β”‚                     β”‚                                   β”‚
β”‚              SOUL.md (identity)                         β”‚
β”‚              AGENTS.md (project context)                β”‚
β”‚              MEMORY.md (persistent findings)            β”‚
β”‚              skills/ (evolving playbooks)               β”‚
β”‚                     β”‚                                   β”‚
β”‚  OBSERVE β†’ HYPOTHESIZE β†’ PLAN β†’ EXECUTE β†’ REFINE        β”‚
β”‚                     β”‚                                   β”‚
β”‚  HTB API ◄─────────── auto-submit flags                 β”‚
β”‚  /etc/hosts ◄──────── auto-update on IP change          β”‚
β”‚  Telegram β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ flag capture / checkpoint notify  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The IP Change Problem β€” Solved

When HTB resets a machine and assigns a new IP (same machine, different address), SPECTER handles it automatically:

  1. Cron job polls HTB API every 5 minutes (wakeAgent: false when no change β†’ zero LLM cost)
  2. On IP change detected: updates /etc/hosts, state/.env, MEMORY.md entry
  3. Sends Telegram: πŸ”„ TwoMillion IP updated: 10.10.11.227 β†’ 10.10.11.235
  4. Continues from last checkpoint β€” no context lost

You never touch /etc/hosts manually.


Features

🧠 Persistent Memory (Hermes-Native)

SPECTER's MEMORY.md grows with every machine:

active_machine: TwoMillion (10.10.11.227)
last_phase: PRIVESC
TwoMillion ports: 22/ssh OpenSSH 8.2, 80/http Apache 2.4.41
TwoMillion owned via: LFI β†’ log poisoning β†’ RCE, then sudo /usr/bin/dd SUID
[TECHNIQUE] LFI log poison works on: Apache, Nginx with error logging
[TECHNIQUE] sudo dd privesc: copy /etc/passwd, add root user

Next machine on Apache β†’ SPECTER tries LFI first because it remembers.

⚑ Self-Improving Skills

After owning a machine, SPECTER patches its own skill files:

skill_manage(action="patch", name="exploit",
             old_string="# LFI payloads",
             new_string="# LFI payloads\n# βœ“ Apache 2.4.41: /var/log/apache2/access.log via User-Agent")

Skills get smarter with every engagement. Never re-derive what already worked.

πŸ“± Telegram Interface

Talk to SPECTER from your phone while it works. All notifications fire automatically:

You:      Start machine TwoMillion and begin recon

SPECTER:  Machine spawned. IP: 10.10.11.227
          Nmap fast scan running.
          
          Ports: 22/ssh, 80/http
          Apache 2.4.41 on port 80.
          Running feroxbuster.

SPECTER:  🚩 TwoMillion USER FLAG: HTB{r3v3rs3_3ng1n33r1ng_...}
          
SPECTER:  ☠️ TwoMillion ROOT FLAG: HTB{4dm1n_t0k3n_...}
SPECTER:  🎯 OWNED: TwoMillion β€” user+root in 2h 14m

πŸ• Cron Automation

Two scheduled jobs run without any user interaction:

IP Monitor (every 5 min) β€” uses wakeAgent: false when IP unchanged, meaning near-zero cost to run constantly. Wakes the agent only when the IP actually changes.

Checkpoint saver (every 8 iterations) β€” writes compressed state to wiki/sessions/, sends Telegram summary. Restart any session from any checkpoint.


Project Structure

specter-htb/
β”œβ”€β”€ SOUL.md                    ← Agent identity (Hermes global personality)
β”œβ”€β”€ AGENTS.md                  ← Project context (loaded at every session start)
β”œβ”€β”€ config.yaml                ← Hermes config: DeepSeek, Telegram, cron, skills
β”œβ”€β”€ setup.sh                   ← One-command setup wizard
β”œβ”€β”€ .env.example               ← Environment variables template
β”‚
β”œβ”€β”€ skills/                    ← Hermes SKILL.md files (slash commands)
β”‚   β”œβ”€β”€ htb-api/SKILL.md       β†’ /htb-api   (spawn, IP resolve, flag submit)
β”‚   β”œβ”€β”€ recon/SKILL.md         β†’ /recon     (nmap, web enum, service fingerprint)
β”‚   β”œβ”€β”€ exploit/SKILL.md       β†’ /exploit   (web, network, Metasploit)
β”‚   β”œβ”€β”€ privesc/SKILL.md       β†’ /privesc   (Linux + Windows LPE)
β”‚   └── report/SKILL.md        β†’ /report    (HTB writeup generator)
β”‚
β”œβ”€β”€ wiki/                      ← LLM-maintained knowledge base
β”‚   β”œβ”€β”€ targets/               ← One .md per HTB machine
β”‚   β”œβ”€β”€ techniques/            ← Reusable attack patterns
β”‚   β”œβ”€β”€ sessions/              ← Checkpoint files (resume points)
β”‚   └── flags/                 ← Captured flags archive
β”‚
β”œβ”€β”€ state/
β”‚   β”œβ”€β”€ session.json           ← Current machine, phase, findings, iteration count
β”‚   β”œβ”€β”€ scope.txt              ← Authorized IP ranges (HTB standard ranges pre-loaded)
β”‚   └── .htb_token             ← HTB API token (gitignored)
β”‚
└── tools/
    β”œβ”€β”€ htb.py                 ← HTB API v4: spawn/ip/reset/submit-flag
    └── save.py                ← Auto-save engine + checkpoint generator

How Hermes Context Files Work Here

File Hermes Role What SPECTER Uses It For
SOUL.md Global personality Agent identity β€” loaded every session, every platform
AGENTS.md Project context Session start protocol, architecture, memory strategy
skills/*/SKILL.md Slash commands /recon, /exploit, /privesc, /report, /htb-api
MEMORY.md Persistent memory Cross-session findings, owned machines, technique patterns

Prerequisites


Quick Start

1. Install Hermes

curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash
source ~/.bashrc

2. Clone and Setup

git clone https://github.com/0xb4bal/specter.git
cd specter
chmod +x setup.sh
./setup.sh

The setup wizard will ask for:

  • DeepSeek API key
  • HTB App Token
  • Telegram bot token + your user ID

3. Start SPECTER

# Start the Hermes gateway (runs in background, enables Telegram)
HERMES_HOME=~/.hermes-specter hermes gateway start

# Or run interactive CLI
HERMES_HOME=~/.hermes-specter hermes

4. Begin a Machine (via Telegram or CLI)

Start machine TwoMillion and begin recon

SPECTER resolves the machine name β†’ spawns it β†’ gets IP β†’ updates /etc/hosts β†’ begins Phase 1.


Slash Commands

Inside any Hermes session (CLI or Telegram):

Command What it does
/htb-api Verify/refresh target IP, spawn machine, submit flags
/recon Phase 1: nmap, web enum, service fingerprint
/exploit Phase 3: web/network exploitation, reverse shells
/privesc Phase 5: Linux/Windows privilege escalation
/report Generate HTB writeup from wiki + memory
/compress Compress context when approaching token limit
/skills List all available skills
/cron list Show scheduled jobs

Session Flow

                    You: "Start TwoMillion"
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   /htb-api              β”‚
              β”‚   Resolve name β†’ ID     β”‚
              β”‚   Spawn machine         β”‚
              β”‚   Get IP (poll API)     β”‚
              β”‚   Update /etc/hosts     β”‚
              β”‚   Save to MEMORY.md     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   /recon                β”‚
              β”‚   Check MEMORY.md first β”‚  ← Did we do this stack before?
              β”‚   nmap fast + full      β”‚
              β”‚   Web/SMB/SSH enum      β”‚
              β”‚   Save all to MEMORY    β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   /exploit              β”‚
              β”‚   Check session_search  β”‚  ← What worked on Apache 2.4.x?
              β”‚   Try proven techniques β”‚
              β”‚   Get shell             β”‚
              β”‚   Flag detected β†’ auto  β”‚
              β”‚   submit + Telegram     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   /privesc              β”‚
              β”‚   Run linpeas           β”‚
              β”‚   Check memory for LPE  β”‚
              β”‚   Escalate to root      β”‚
              β”‚   Root flag β†’ auto      β”‚
              β”‚   submit + Telegram     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   /report               β”‚
              β”‚   Compile writeup       β”‚
              β”‚   Update skills (patch) β”‚
              β”‚   Update MEMORY.md      β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Configuration

DeepSeek V4 Pro (default)

# config.yaml
model: deepseek/deepseek-chat-v4-pro
provider: deepseek

Switch Model

HERMES_HOME=~/.hermes-specter hermes model
# Interactive picker β€” change to any Hermes-supported model
# Works with: OpenRouter, Anthropic, OpenAI, local endpoints

Telegram Setup

  1. Message @BotFather β†’ /newbot β†’ name it "SPECTER HTB"
  2. Copy the token into setup.sh when prompted
  3. Get your user ID from @userinfobot
  4. Start the gateway: HERMES_HOME=~/.hermes-specter hermes gateway start
  5. Send any message to your bot to activate it

Memory Architecture

SPECTER uses two Hermes memory files stored in ~/.hermes-specter/memories/:

MEMORY.md (~800 tokens) β€” agent's working notes:

active_machine: TwoMillion (10.10.11.227)
last_phase: PRIVESC | iteration: 12
TwoMillion ports: 22/ssh, 80/http Apache 2.4.41
TwoMillion owned via: LFI log poison β†’ RCE β†’ sudo dd privesc
[TECH] Apache 2.4.41 β€” check LFI first, /var/log paths work

USER.md (~500 tokens) β€” your preferences:

Prefers caveman output mode
HTB focus: medium/hard Linux machines
Notify Telegram on every flag, every checkpoint

Memory is bounded (2,200 chars max) and auto-consolidated. The agent manages it β€” you don't.


Security

  • HTB API token stored in state/.htb_token (gitignored)
  • Never stored in MEMORY.md or wiki/
  • Scope enforcement: only targets listed in state/scope.txt are tested
  • All actions logged to wiki/log.md (audit trail)
  • Responsible use: HTB lab machines only

Inspired By

Project What was taken
Hermes Agent Agent runtime, skills system, memory, Telegram gateway, cron
PHANTOM HTB Agent HTB methodology, recursive loop, wiki pattern
Karpathy autoresearch Observe β†’ hypothesize β†’ execute recursive loop
LLM Wiki Three-layer knowledge architecture

License

MIT β€” see LICENSE

For authorized use on HTB lab machines only. Never test systems without explicit written permission.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages