File size: 9,072 Bytes
20f108c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# πŸ‘» PHANTOM

[![CI](https://github.com/Njap-png/Phantom/actions/workflows/ci.yml/badge.svg)](https://github.com/Njap-png/Phantom/actions/workflows/ci.yml)

**Multi-agent cybersecurity AI assistant** β€” autonomous penetration testing, reconnaissance, vulnerability analysis, and AI-powered security operations, all from your terminal.

```
Β·   Β·   Β·   Β·   Β·   Β·
  β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„
 β–ˆ ═══ ═══ ═══ ═══ β–ˆ
β–β–ˆ Β·   Β·   Β·   Β·   β–ˆβ–Œ
β–β–ˆ  ╔═══════════╗  β–ˆβ–Œ
β–β–ˆ  β•‘ β—ˆ     β—ˆ β•‘  β–ˆβ–Œ
β–β–ˆ  β•‘  β•² β•± β•² β•± β•‘  β–ˆβ–Œ
β–β–ˆ  β•šβ•β•β•β•β•β•β•β•β•β•β•β•  β–ˆβ–Œ
β–β–ˆ     ●         β–ˆβ–Œ
 β–€β–„ ═══════════ β–„β–€
  P H A N T O M
  cybersecurity AI Β· v0.2.0
```

## Quick Start

```bash
# Clone
git clone https://github.com/Njap-png/Phantom.git
cd Phantom

# Run (no install needed β€” zero-dep ESM)
node phantom.mjs

# Or Docker
docker build -t phantom .
docker run -it phantom
```

## Features

### πŸ”§ 108 Built-in Tools

| Category | Tools |
|---|---|
| **Core** | shell, web_fetch, decode, encode, hash, file_analyze, batch, code_analyze, code_gen, yara |
| **Recon** | dns_lookup, whois, sub_enum, subfinder (ext), port_scan, http_headers, ssl_check, crawl, geoip, dns_zone, reverse_dns, wayback, robots_txt, amass (ext), dnsx (ext), httpx (ext), naabu (ext), katana (ext), sub_takeover |
| **Web** | dir_bruteforce, xss_scan, sql_detect, open_redirect, cors_test, http_methods, ffuf (ext), arjun (ext) |
| **CVE/Exploit** | cve_search, searchsploit, shodan_search, nuclei (ext) |
| **Auth** | bruteforce, jwt_decode, hash_crack, hashcat (ext) |
| **OSINT** | email_verify, email_breach, github_dork, vt_check, cloud_enum, wayback |
| **Network** | netcat (ext), nmap (ext), masscan (ext), dig, ping, traceroute, netstat |
| **Crypto** | ssl_check, cert_expiry, encrypt, decrypt, random |
| **File** | file_read, file_write, file_edit, file_search, file_list |
| **Self** | self_info, self_read, self_edit, self_add_tool, distro |
| **Knowledge** | knowledge_add, knowledge_search |
| **Automation** | playbook_create, playbook_list, playbook_run, playbook_edit, recon, vuln_scan, report_save, report_export, session_save, session_load, schedule |

> Type `node phantom.mjs --list` for the full list. External tools (marked `ext`) require installation β€” Phantom detects them at runtime.

### πŸš€ New in v0.2.0

| Feature | Description |
|---|---|
| **`--json` output** | `phantom --tool --json <name> <input>` β€” structured `{ok, data}` JSON |
| **Tool piping** | `phantom --tool --pipe "subfinder\|dom\|httpx"` — chain output→input |
| **Scheduled scanning** | `@schedule\|daily\|recon\|target` β€” recurring automated scans |
| **Scope management** | `@scope\|add\|domain.com` β€” target scoping for batch ops |
| **Shell audit trail** | Every command logged, dangerous patterns blocked |
| **`--quiet` mode** | `PHANTOM_QUIET=1` or `--quiet` β€” suppress banner/status |
| **`--version`** | `phantom --version` β€” prints version and exits |
| **Docker** | `docker build -t phantom .` β€” Alpine-based container |
| **TAB autocomplete** | `@tool_name|` completion in REPL |

### πŸ€– Multi-Agent Team

4 specialized agents working in parallel:

| Agent | Role | Specialty |
|---|---|---|
| **Lyra** | Coordinator | Breaks down tasks, delegates, synthesizes results |
| **Nova** | Recon | DNS, OSINT, scanning, surface mapping |
| **Orion** | Exploit | Vulnerability research, pentesting, brute force |
| **Vega** | Defense | SSL, CORS, JWT, hardening, monitoring |

Use `@delegate|name|task` for agent-to-agent delegation.

### 🎯 One-Shot Commands

```bash
phantom --recon example.com              # Full recon (7 steps + report)
phantom --tool port_scan scanme.org      # Run a single tool
phantom --tool --json cve_search "apache 2.4.49"   # JSON output
phantom --tool --pipe "subfinder|dom|httpx|nuclei"  # Tool chain
phantom --list                           # List all 108 tools
phantom --list --json                    # List as JSON
phantom --gui                            # Web dashboard (port 8080)
phantom --api                            # REST API (port 9090)
phantom --quiet                          # Suppress banner
phantom --version                        # Show version
phantom --help                           # Full usage
```

### πŸ’¬ Interactive REPL

```bash
phantom
πŸ‘» recon example.com
πŸ‘» /model groq           # Switch LLM
πŸ‘» @schedule|daily|recon|example.com   # Schedule daily scan
πŸ‘» @scope|add|example.com              # Add to target scope
πŸ‘» @pipe|subfinder|example.com|httpx   # Chain tools inline
```

| Command | Description |
|---|---|
| `/help` | Show all commands |
| `/tools` | List available tools |
| `/model` | Show/switch LLM provider |
| `/delegate <agent> <task>` | Delegate to a specialist |
| `/talk <agent> <message>` | Chat directly with an agent |
| `/agents` | List agent team with status |
| `/gui` | Start web dashboard |
| `/api` | Start REST API |
| `/save <name>` | Save session |
| `/load <name>` | Load session |
| `/clear` | Clear screen |
| `/quit` | Exit |

REPL also supports:
- `@tool_name|args` β€” run any tool inline
- `@pipe|tool1|input|tool2` β€” chain tools
- `@schedule|interval|tool|target` β€” schedule recurring scans
- `@scope|add|domain` β€” manage target scope
- `@workspace_write|key|value` β€” save findings
- `TAB` β€” autocomplete tool names

## CI

Every push runs across Node.js 20 and 22:

- JS syntax check
- TypeScript build (`tsc --noEmit`)
- CLI verification (`--list` with tool count > 100)
- **34 test cases** (core runtime + features)

[![CI](https://github.com/Njap-png/Phantom/actions/workflows/ci.yml/badge.svg)](https://github.com/Njap-png/Phantom/actions/workflows/ci.yml)

## LLM Providers

Phantom auto-detects available providers on startup. Supported:

| Provider | Config |
|---|---|
| **Ollama** (local, default) | Auto-detected if running |
| **OpenAI** | `OPENAI_API_KEY` env or `@llm_config\|set\|openai_api_key\|sk-...` |
| **OpenCode** (via Hermes) | `@llm_config\|opencode\|deepseek-v4-flash-free` |
| **Groq** | `GROQ_API_KEY` env |
| **Anthropic** | `ANTHROPIC_API_KEY` env |
| **Gemini** | `GEMINI_API_KEY` env |
| **DeepSeek** | `DEEPSEEK_API_KEY` env |
| **Mistral** | `MISTRAL_API_KEY` env |
| **OpenRouter** | `OPENROUTER_API_KEY` env |

Set API keys via interactive prompt on first run, or directly in `~/.config/phantom/config.json`.

### Example: Hermes Agent / OpenCode provider

Phantom works with Hermes Agent's OpenCode provider chain:

```bash
# Via @llm_config interactive
πŸ‘» @llm_config|opencode|deepseek-v4-flash-free

# Or set env vars
export PHANTOM_LLM_PROVIDER=opencode
export HERMES_OPCODE_API_KEY=sk-your-key-here   # <-- REPLACE with your key
phantom
```

> ⚠ Never commit real API keys to Git. Use environment variables or the interactive `@llm_config` prompt instead.

## Configuration

All config lives in `~/.config/phantom/`:

- `config.json` β€” LLM provider settings, API keys, defaults
- `memories/` β€” Per-agent persistent memory
- `tools/` β€” Custom tool definitions
- `reports/` β€” Generated security reports
- `knowledge/` β€” Persistent knowledge base entries
- `scope.json` β€” Target scope definitions
- `projects/` β€” Per-project workspace data
- `schedules.json` β€” Scheduled scan definitions

## Environment Variables

| Variable | Default | Description |
|---|---|---|
| `PHANTOM_MAX_ITER` | `8` | Max ReAct loop iterations per request |
| `PHANTOM_TOOL_TIMEOUT` | `30000` | Shell command timeout (ms) |
| `PHANTOM_LLM_PROVIDER` | `openai` | Default LLM provider |
| `PHANTOM_PROVIDERS_READY` | β€” | Comma-separated ready providers |
| `PHANTOM_QUIET` | β€” | Suppress banner/status output |
| `HERMES_OPCODE_API_KEY` | β€” | Hermes Agent / OpenCode provider API key |

## Architecture

```
User Input
    β”‚
    β–Ό
  Lyra (Coordinator)
    β”‚
    β”œβ”€β”€ Nova (Recon) β€” DNS, ports, OSINT
    β”œβ”€β”€ Orion (Exploit) β€” CVEs, brute force, SQLi
    └── Vega (Defense) β€” SSL, CORS, hardening
    β”‚
    β–Ό
  Shared Workspace (agent-to-agent data)
    β”‚
    β–Ό
  Synthesized Response
```

- **Zero dependencies** β€” runs on vanilla Node.js ESM
- **EventBus** pattern for decoupled agent communication
- **ReAct loop** with 8 configurable tool iterations
- **Persistent memory** for each agent
- **Auto-save** conversations across sessions

## Requirements

- **Node.js** 20+ (ESM support)
- **Termux** / **Linux** / **macOS** / **WSL**
- LLM provider (Ollama recommended for local use)
- Docker (optional, for containerized use)

## Known Issues

- System tool detection runs once at startup β€” tools installed later won't show until restart
- Agent delegation requires an LLM provider (not available in tools-only mode)
- Some tools (vt_check, shodan_search) require API keys in environment
- Dashboard requires `blessed` for terminal split-panel UI (optional dep)

## License

MIT
# test