Metadata-Version: 2.4
Name: pentestllm
Version: 0.2.0
Summary: PentestLLM in the terminal: pipe nmap, Burp or code into a security model, run pentest playbooks, or point the OpenAI and Anthropic SDKs at api.pentestllm.ai. For authorized testing.
Project-URL: Homepage, https://pentestllm.ai
Project-URL: Documentation, https://pentestllm.ai/docs
Project-URL: Models, https://pentestllm.ai/models
Project-URL: Playbooks, https://pentestllm.ai/tools/pentest-playbooks
Project-URL: Acceptable use, https://pentestllm.ai/acceptable-use
Author-email: PentestLLM <hello@pentestllm.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: cli,ctf,cybersecurity,kali,llm,nmap,openai compatible,penetration testing,pentest,red team
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Provides-Extra: all
Requires-Dist: anthropic>=0.34; extra == 'all'
Requires-Dist: openai>=1.40; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.34; extra == 'anthropic'
Provides-Extra: openai
Requires-Dist: openai>=1.40; extra == 'openai'
Description-Content-Type: text/markdown

# pentestllm

```bash
pipx install pentestllm        # or: pip install pentestllm
```

`ptl` (also `pentestllm`) puts [PentestLLM](https://pentestllm.ai)'s security models in your terminal. Pipe nmap, a Burp request or a code snippet into it, or run one of the six pentest playbooks. No dependencies beyond Python 3.9+ (Kali included; on Kali use pipx, since its system Python refuses a global pip install). No telemetry: the only network calls go to `api.pentestllm.ai`, and only when you run a command.

For authorized security testing only: systems you own or have written permission to test ([acceptable use](https://pentestllm.ai/acceptable-use)).

## Key

```bash
ptl login                      # paste an sk-ptl- key; saved to ~/.config/pentestllm/config.json, mode 0600
export PENTESTLLM_API_KEY=...  # or this, which wins over the saved key
```

On Linux and macOS the key file is written as a new 0600 file and renamed into place (a folder it creates is 0700), and a symlinked path is refused. On Windows it goes to `%APPDATA%\pentestllm\config.json`, and its protection is your user profile's permissions.

Get a key at [pentestllm.ai](https://pentestllm.ai/?utm_source=cli&utm_medium=pypi&utm_campaign=ptl-login). Credit is prepaid, with no subscription.

## Examples

Real runs on 2026-11-29, trimmed where marked with `...`. The scan is of a Metasploitable 2 VM on a host-only lab network, saved to a file first; the request is OWASP Juice Shop on localhost.

```console
$ ptl ask "does a vsftpd 2.3.4 banner on a lab VM prove the backdoor is there? two sentences"
No — the "vsftpd 2.3.4" banner only reports the version string, and the backdoor (CVE-2011-2523) was
injected into the source tarball rather than baked into the version, so a distro-rebuilt or manually
patched 2.3.4 may carry the same banner without the flaw (and the banner itself is trivially spoofable). ...
```

```console
$ ptl triage < scan.txt
...
6. 80/tcp Apache 2.2.8 with DAV/2: WebDAV enabled is notable. Check: `OPTIONS` request, `PROPFIND`/PUT
   against writable paths, browse for vulnerable web apps.

7. 22/tcp OpenSSH 4.7p1 (Debian/Ubuntu): very old; Debian OpenSSL PRNG weakness era affects keys, not
   direct SSH exploitation. Check: banner-consistent weak host keys, brute-force only if authorized
   policy allows.
...
```

```console
$ cat burp-request.txt | ptl ask "Juice Shop on my own laptop. What would you test here? Short list."
That endpoint is the canonical Juice Shop SQLi (the `q` param feeds an unbounded Sequelize query) ...

**1. SQLi in `q` — high confidence**
- `q=apple'` → expect 500 / Sequelize error (confirms injectable)
...
```

Piping a scan straight in also works, against a target in your scope: `nmap -sV -oN - 192.168.56.101 | ptl triage`.

## Commands

| Command | What it does |
|---|---|
| `ptl ask "question"` | Streams an answer. Anything on stdin is added after the question. |
| `ptl recon-triage` (`ptl triage`) | Scan output in, the services to check first and the first manual check for each out. |
| `ptl web-finding-triage` | One scanner or proxy issue: real or false positive, severity, how to confirm by hand. |
| `ptl finding-writer` | Rough notes in, a report finding out: title, description, impact, remediation. |
| `ptl ctf-hint-coach` | The next hint for a practice challenge, never the flag. |
| `ptl detection-rule` | A Sigma rule for behaviour you saw in a lab. |
| `ptl code-review` | The lines in a snippet that carry a vulnerability class, with the CWE and the fix. |
| `ptl playbooks` | Lists the playbooks above. |
| `ptl models` | Lists the model ids the API serves now (no key needed). |
| `ptl login` | Saves your key. |

The playbooks use the same system prompts as [pentestllm.ai/tools/pentest-playbooks](https://pentestllm.ai/tools/pentest-playbooks). `ptl ask` defaults to `red-team-flash` and the playbooks to `glm-5.3-flash-cybersecurity`; `-m <model>` picks another, `--max-tokens` caps the answer (default 1500).

When an API or network call fails, `ptl` prints one line saying how to fix it and exits 1: a rejected key (401) points at `ptl login`, an empty balance (402) at the billing page, a rate limit (429) at the tier table, and a network failure at your connection or `HTTPS_PROXY`. A redirect from the API is refused rather than followed, so the key is never sent to another host. Any other failure (a disk that refuses the key file, a connection cut mid-stream) is also one line and exit 1; set `PTL_DEBUG=1` to see the traceback for a bug report. Bad arguments, including a `--max-tokens` or `--max-input` below 1, exit 2 with the usage line; Ctrl-C exits 130.

Piped input is capped at 1,000,000 bytes (`--max-input` raises it). Model text and error bodies are printed with terminal control and escape sequences removed, since scan banners and proxy pages are attacker-controlled.

## In Python

The package also points the official OpenAI and Anthropic SDKs at `https://api.pentestllm.ai/v1`:

```bash
pip install "pentestllm[openai]"      # or [anthropic], or [all]
```

```python
import pentestllm

client = pentestllm.openai_client()   # reads PENTESTLLM_API_KEY
reply = client.chat.completions.create(
    model="auto/security",
    messages=[{"role": "user", "content": "Say hi in five words."}],
)
print(reply.choices[0].message.content)
```

`pentestllm.anthropic_client()` does the same for the Anthropic SDK, and `pentestllm.models()` returns every chat model with its price per 1M tokens, no key needed. Without this package, set `OPENAI_BASE_URL` or `ANTHROPIC_BASE_URL` to `https://api.pentestllm.ai/v1` and use your key.

- Models and prices: [pentestllm.ai/models](https://pentestllm.ai/models)
- API docs: [pentestllm.ai/docs](https://pentestllm.ai/docs)
- Acceptable use: [pentestllm.ai/acceptable-use](https://pentestllm.ai/acceptable-use)
