An open API service indexing awesome lists of open source software.

https://github.com/saramazal/ghostshell

๐Ÿ‰ GhostShell โ€” AI Pentesting Assistant GhostShell is a local AI-powered penetration testing assistant built with Node.js and Ollama. It analyzes scan results, suggests attack paths, and outputs real commands to accelerate your penetration testing workflow.
https://github.com/saramazal/ghostshell

ai-assistant ai-tools axios curl dig ethical-hacking ethical-hacking-tools ffuf javascript llama3 login mistral nmap nodejs ollama penetration-testing penetration-testing-framework penetration-testing-tools scanner whois

Last synced: 10 days ago
JSON representation

๐Ÿ‰ GhostShell โ€” AI Pentesting Assistant GhostShell is a local AI-powered penetration testing assistant built with Node.js and Ollama. It analyzes scan results, suggests attack paths, and outputs real commands to accelerate your penetration testing workflow.

Awesome Lists containing this project

README

          

* _project_in_progress_
# ๐Ÿ‰ GhostShell โ€” AI Pentesting Assistant

GhostShell is a local AI-powered penetration testing assistant built with Node.js and Ollama.

It analyzes scan results, suggests attack paths, and outputs real commands to accelerate your penetration testing workflow.

---

## โš™๏ธ Features

* ๐Ÿง  **AI-powered scan analysis** โ€” Uses Llama3 for deep analysis
* โš”๏ธ **Attack path suggestions** โ€” Auto-detects exploit chains
* ๐Ÿ”„ **Multi-model routing** โ€” Smart model selection (llama3 + mistral)
* ๐Ÿงพ **Persistent memory** โ€” RAG-based knowledge storage
* ๐Ÿ”“ **Login detection** โ€” Identifies authentication endpoints
* ๐Ÿ’ป **Command generation** โ€” Outputs actionable exploitation commands
* ๐Ÿ”ง **Tool integration** โ€” nmap, ffuf, whois, dig, whatweb, curl

---

## ๐Ÿงฑ Tech Stack

* **Node.js** โ€” Runtime
* **Ollama** โ€” Local LLM inference engine
* **Llama3** โ€” Deep analysis model
* **Mistral** โ€” Fast task execution model
* **Axios** โ€” HTTP client for Ollama API
* **fs-extra** โ€” File utilities

---

## ๐Ÿš€ Quick Start

### 1. Install Ollama

Download from [ollama.ai](https://ollama.ai)

### 2. Pull models

```bash
ollama pull llama3
ollama pull mistral
```

### 3. Clone & setup

```bash
git clone https://github.com/saramazal/ghostshell
cd ghostshell
npm install
```

### 4. Start Ollama (in separate terminal)

```bash
ollama serve
```

### 5. Run GhostShell

```bash
node index.js 10.10.10.10 analysis
```

---

## ๐Ÿ“– Usage

### Option 1: Direct Node.js

**Analyze target directly:**
```bash
node index.js 10.10.10.10 analysis
```

**Analyze scan results file:**
```bash
node index.js scan.txt analysis
```

### Option 2: CLI (Global Install)

**Install as global command:**
```bash
npm install -g .
```

**Use anywhere:**
```bash
ghostshell scan 10.10.10.10
ghostshell recon 192.168.1.1
```

### Option 3: Direct Node CLI

**Without global install:**
```bash
node cli.js scan 10.10.10.10
node cli.js recon 192.168.1.1
```

---

## ๐Ÿ“ Project Structure

```
ghostshell/
โ”œโ”€โ”€ index.js # Main entry point
โ”œโ”€โ”€ cli.js # CLI interface (#!/usr/bin/env node)
โ”œโ”€โ”€ agent.js # AI agent orchestration
โ”œโ”€โ”€ package.json # Dependencies & bin config
โ”œโ”€โ”€ scan.txt # Sample scan file
โ”œโ”€โ”€ memory/
โ”‚ โ”œโ”€โ”€ history.json # Execution history
โ”‚ โ””โ”€โ”€ ragStore.js # RAG memory persistence
โ””โ”€โ”€ tools/
โ”œโ”€โ”€ runTool.js # Tool executor
โ”œโ”€โ”€ analyzer.js # Generic analyzer
โ”œโ”€โ”€ nmap.js # Port scanning
โ”œโ”€โ”€ ffuf.js # Web fuzzing
โ”œโ”€โ”€ whois.js # Domain WHOIS lookup
โ”œโ”€โ”€ dig.js # DNS queries
โ”œโ”€โ”€ whatweb.js # Web fingerprinting
โ”œโ”€โ”€ curl_headers.js # HTTP header analysis
โ”œโ”€โ”€ exploitPlanner.js # Exploit chain builder
โ””โ”€โ”€ parsers/
โ”œโ”€โ”€ ffufParser.js # Parse ffuf output
โ””โ”€โ”€ loginDetector.js # Detect login forms
```

---

## ๐ŸŽฏ How It Works

1. **Input** โ†’ Target IP or scan file
2. **Recon Planning** โ†’ Mistral AI selects relevant tools
3. **Tool Execution** โ†’ Runs whois, dig, nmap, ffuf, whatweb, etc.
4. **Intel Gathering** โ†’ Detects logins, parses results
5. **Analysis** โ†’ Llama3 deep analysis of findings
6. **Exploitation** โ†’ Suggests attack chains and commands
7. **Memory** โ†’ Saves results for future reference (RAG)

---

## โš™๏ธ Configuration

### Choose LLM Models

Edit `agent.js` `chooseModel()` function:

```javascript
function chooseModel(taskType, inputLength) {
if (taskType === "analysis") return "llama3";
return inputLength > 1500 ? "llama3" : "mistral";
}
```

### Ollama API Endpoint

Edit `agent.js` `queryOllama()` function:

```javascript
async function queryOllama(model, prompt) {
const res = await axios.post("http://localhost:11434/api/generate", {
model,
prompt,
stream: false
});
return res.data.response;
}
```

---

## ๐Ÿ”ง Troubleshooting

### โŒ `Error: connect ECONNREFUSED localhost:11434`

**Problem:** Ollama is not running

**Solution:**
```bash
ollama serve
```

### โŒ `Model not found: llama3`

**Problem:** Model not downloaded

**Solution:**
```bash
ollama pull llama3
ollama pull mistral
```

### โŒ `JSON parse failed`

**Problem:** Corrupted memory file

**Solution:**
```bash
rm memory/rag.json
rm memory/history.json
```

---

## ๐Ÿ“Š Memory System

GhostShell learns from past scans using RAG (Retrieval Augmented Generation):

- **rag.json** โ€” Stores all discovered intelligence
- **history.json** โ€” Logs all executions with timestamps

Query past knowledge:
```javascript
const { searchMemory } = require("./memory/ragStore");
const past = searchMemory("10.10.10.10");
```

---

## ๐Ÿ› ๏ธ Development

### Run tests
```bash
npm test
```

### Debug mode
```bash
DEBUG=* node index.js 10.10.10.10 analysis
```

### Check history
```bash
cat memory/history.json | jq .
```

---

## โš ๏ธ Legal Notice

GhostShell is for **authorized security testing only**. Unauthorized access to computer systems is illegal. Always obtain written permission before running penetration tests.

---

## ๐Ÿ“ License

ISC

---

## ๐Ÿค Contributing

Contributions welcome! Feel free to:
- Add new reconnaissance tools
- Improve AI prompts
- Enhance memory system
- Fix bugs

Open a PR! ๐Ÿš€