Skip to content

About

Safety-first AI assistant for purple teaming and adversary emulation with Sliver C2 and local LLMs (Ollama). Human-in-the-loop, zero telemetry.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

AdversarySim-AI

Python 3.12 | 3.13 Tests License: MIT Zero Telemetry by kadohack12

A lightweight, safety-first AI assistant for purple teaming and adversary emulation with Sliver C2 and local LLMs via Ollama.

AdversarySim-AI is an open-source project that helps defenders think like attackers — in a controlled, auditable way. It pairs a native Sliver C2 connector with a locally hosted language model so your operator notes, session data and target details never leave your machine.

Nothing executes without explicit operator approval. Every action passes through a human-in-the-loop gate before it runs.

📖 New here? Follow the 5-minute lab walkthrough to reproduce a complete purple-teaming loop — listener, sandbox, implant, telemetry, cleanup — end to end.


Architecture

                        ┌──────────────────────────────────────────────┐
                        │                 Operator                     │
                        │        (human-in-the-loop, approves)         │
                        └───────────────────────┬──────────────────────┘
                                                │  CLI / interactive shell
                                                ▼
              ┌───────────────────────────────────────────────────────────┐
              │             AdversarySim-AI CLI  +  Local LLM             │
              │   ┌─────────────────────┐      ┌─────────────────────┐    │
              │   │  typer + rich CLI   │◄────►│  Ollama (local LLM) │    │
              │   │  /status /beacons   │      │  reason & propose   │    │
              │   └──────────┬──────────┘      └─────────────────────┘    │
              └──────────────┼────────────────────────────────────────────┘
                             │  every action is screened
                             ▼
              ┌───────────────────────────────────────────────────────────┐
              │                     Safety Gate (HITL)                    │
              │   read-only → allow   ·   state-changing → deny           │
              │   destructive → deny  ·   dry-run → print only            │
              └──────────────────────────┬────────────────────────────────┘
                                         │  approved actions only
                                         ▼
              ┌───────────────────────────────────────────────────────────┐
              │                    Sliver C2 Server                       │
              │            mTLS / HTTP(S) listeners · jobs                 │
              └──────────────────────────┬────────────────────────────────┘
                                         │  callback (loopback only)
                                         ▼
              ┌───────────────────────────────────────────────────────────┐
              │                    Sandbox Target                         │
              │        disposable container (podman/docker --rm)          │
              └───────────────────────────────────────────────────────────┘

The operator drives everything. The local LLM reasons and proposes, the Safety Gate decides what may run, and Sliver executes only what the operator approved — against a throwaway sandbox.


Why

Purple teams need to reproduce real adversary behaviour to validate detection and response. That work is powerful, so it needs guardrails. AdversarySim-AI is built around three principles:

  1. Operator control first. Destructive actions default to deny; the operator must explicitly approve them. Read-only enumeration defaults to allow, but is still confirmed.
  2. Local by default. The LLM runs on your own hardware through Ollama. No API keys, no telemetry, no data leaving your environment.
  3. Defensive research. The goal is to improve detection and hardening, not to build a turnkey attack platform.

Safety model

Risk level Examples Default on Enter
read-only list sessions, beacons, jobs allow [Y/n]
state-changing run a discovery command (T1082/T1083), modify state deny [y/N]
destructive generate / deploy an implant deny [y/N]

Two environment switches make automation and audits easier:

  • ADVERSARYSIM_DRY_RUN=true — never execute; print exactly what would run.
  • ADVERSARYSIM_ASSUME_YES=true — auto-approve (use only in a sandbox you fully control).

Interactive implant control (interact, shell, execute) is deliberately out of scope. AdversarySim-AI enumerates, generates, and runs a narrow allow-list of read-only discovery commands on an already-established session. It does not provide a general-purpose remote command runner.


Features

  • Native Sliver C2 integration — sliver_status, sliver_list_sessions, sliver_list_beacons, sliver_list_jobs, sliver_generate_payload, sliver_run_discovery.
  • Local LLM connector — async client for Ollama's /api/chat (streaming and non-streaming), defaulting to qwen2.5-coder:7b.
  • LLM tool calling — the local model can invoke the read-only Sliver tools (sliver_status, sliver_list_sessions, sliver_list_beacons, sliver_list_jobs), the allow-listed discovery tool (sliver_run_discovery) and the dynamic MITRE agent (mitre_run_technique) directly from the interactive shell, with every call routed through the Safety Gate.
  • Defensible discovery (MITRE T1082 + T1083 + T1057 + T1016) — sliver_run_discovery emulates System Information Discovery (whoami, id, uname -a, hostname, uptime), File and Directory Discovery (pwd, ls -la, and a canary read confined to /tmp/canary_*.txt), Process Discovery (ps aux) and System Network Configuration Discovery (ip a, route -n). Commands are emitted in Sliver console syntax — native commands where Sliver has one, execute -o <cmd> for real system binaries (the -o flag is required to capture stdout). Paths are fixed literals, never operator- or model-supplied. Anything else is refused before it reaches the target, and the action is state-changing ([y/N]).
  • Open, dynamic MITRE ATT&CK agent — you are not limited to four hard-coded techniques. In adversarysim shell you can ask for any technique in natural language ("Je veux tester T1033", "Simule MITRE T1082", "Comment simuler la persistance T1053 ?"). The local model identifies the technique, maps it to a defensible read-only discovery command, and calls mitre_run_technique. Curated ids use their dedicated command; any other valid T#### id is emulated generically and the report is labelled as such. Every run still goes through the Safety Gate.
  • MITRE ATT&CK emulation catalogue — adversarysim mitre list shows the curated techniques with their safety status; adversarysim mitre run <ID> accepts any valid technique id, resolves the active beacon automatically, routes the run through the Safety Gate, and writes a Purple Team report.
  • Purple Team reports — every mitre run writes reports/<ID>_<timestamp>.md with metadata, the technique, the Sliver console command, the raw Sliver evidence, and defensive recommendations written by the local LLM (Sigma / auditd / YARA), falling back to curated detections when Ollama is unavailable. The reports/ directory is created automatically.
  • Human-in-the-loop safety layer — a single approval gate that every action goes through.
  • Hyper-dark terminal UI — a neon-on-black rich theme (by kadohack12), colourised tables for sessions and jobs, a risk-coloured Safety Gate header, and an interactive shell with slash commands.
  • Graceful degradation — if sliver-client is missing or the server is down, you get a clear, actionable message instead of a traceback.
  • Small dependency surface — httpx, pydantic, rich, typer.

🧠 The Role of Local AI in AdversarySim

The language model is the reasoning layer of AdversarySim-AI — not an execution engine. It runs entirely on your own hardware through Ollama and is deliberately kept on a short leash.

Privacy-First / Zero-Telemetry architecture

Offensive and purple-team work generates exactly the data you can never afford to leak: target IP addresses, internal hostnames, usernames, listener ports, payload paths, and the audit trail of what you emulated. Sending any of that to a third-party API would hand an external provider a map of your environment and the timeline of your exercise.

AdversarySim therefore talks only to a local Ollama instance (OLLAMA_HOST, default http://127.0.0.1:11434). There are:

  • no API keys and no provider SDKs,
  • no outbound calls to any hosted model,
  • no telemetry or usage reporting of any kind.

Your prompts, session data and detection notes stay on the machine. That is what makes the tool usable in a regulated or air-gapped audit.

Role #1 — Context assistant & purple teaming

The model is a context-aware teammate for the operator. Given the Sliver telemetry AdversarySim surfaces (beacons, sessions, listeners), it can explain what an action looks like on the wire and suggest matching detection logic — Sigma rules, auditd policies, or YARA signatures — that correspond to the Sliver behaviour just observed.

adversarysim ask "Suggest an auditd rule for an ELF beacon executing from /tmp."

It proposes; the detection engineer decides. This is the purple-team loop: emulate, observe, and turn the observation into a detection.

The same loop is wired into adversarysim mitre run: after a technique executes, the model drafts the "Recommandations défensives" section of the generated report (Sigma / auditd / YARA) from the raw Sliver evidence. When Ollama is offline, the report is still written using the curated detections in the technique catalogue, so the audit trail never depends on the model being up.

Because the model knows MITRE ATT&CK, it also acts as an open, dynamic agent: ask for any technique and it identifies the id, picks a defensible read-only discovery command, and drives the report flow. There is no fixed list of four techniques — T1033, T1053, or any other T#### id is handled, with out-of-catalogue ids emulated generically and clearly labelled.

Role #2 — Conversational interface

Inside adversarysim shell, the model is a natural-language interface to the lab. You can ask it to summarise the current state — "how many beacons are checking in, and over which transport?" — and it reasons over the same data the CLI exposes.

Through Ollama tool calling, the model can go further than narrating: when a question needs live data, it requests the matching Sliver tool (sliver_status, sliver_list_sessions, sliver_list_beacons, sliver_list_jobs) or a defensible discovery command (sliver_run_discovery) by name. It can also drive the full MITRE flow with mitre_run_technique — you say "Simule MITRE T1033" and it identifies the technique, picks the command, and writes the report. AdversarySim intercepts every request, runs it through the Safety Gate for approval, executes the Sliver function, and feeds the real output back so the model can answer precisely. Detection is robust: it accepts both the structured tool_calls field and a tool invocation the model emits as raw JSON in its text (e.g. {"name": "sliver_list_beacons", "arguments": {}}), so the call is never merely echoed back:

adversarysim> Sur quelle machine se trouve mon implant ?
→ model requested tool sliver_list_beacons
  Run Sliver tool 'sliver_list_beacons' requested by the local model
  command: sliver_list_beacons
  risk: read-only
Proceed? [Y/n] y
Ton implant tourne sur target-node (transport mtls).

adversarysim> Qui est l'utilisateur sur la session ?
→ model requested tool sliver_run_discovery
  Run Sliver tool 'sliver_run_discovery' requested by the local model
  command: sliver_run_discovery session_id='ab12cd34' command='whoami'
  risk: state-changing
Proceed? [y/N] y
L'utilisateur de la session ab12cd34 est root.

It coexists with the slash shortcuts rather than replacing them: /status, /beacons, /jobs, /sessions and /help remain deterministic, instant, and model-independent, so you always have a reliable path when the model is slow or unavailable.

adversarysim> /beacons                 # deterministic Sliver query
adversarysim> où est mon implant ?     # LLM + tool calling, Safety-Gated

Role #3 — Strict separation of execution (Safety Gate)

The model reasons and proposes; it never executes. Even when it uses tool calling, it can only request a tool by name — AdversarySim intercepts the call and routes it through the Safety Gate for explicit human approval before the Sliver function runs. The model has no ability to run a system command, generate a payload, or drive a C2 channel on its own, and it cannot invoke anything outside the tools declared to it.

The discovery tool is the clearest example: sliver_run_discovery is exposed to the model, but it is state-changing (deny-by-default [y/N]) and accepts only a strict allow-list — System Information Discovery (whoami, id, uname -a, hostname, uptime), File and Directory Discovery (pwd, ls -la, and a canary read confined to /tmp/canary_*.txt), Process Discovery (ps aux) and Network Configuration Discovery (ip a, route -n). Paths are fixed literals, so any other command is refused before it reaches the target: even a prompt-injected or hallucinated command cannot turn the agent into a general-purpose remote runner. sliver_generate_payload is deliberately not exposed as a tool at all.

The dynamic MITRE tool mitre_run_technique respects the same boundary. It accepts any T#### id, but the command it can run is still drawn from the allow-list — a technique id is a label, never a command. An unknown or out-of-catalogue id is emulated with a fixed, read-only discovery command and the report is marked generic. So "Simule T1053" cannot smuggle in a persistence command: the agent proposes, the Safety Gate decides, and only allow-listed read-only commands ever reach the target.

The LLM can describe how to generate an implant; only the operator's y at the confirmation prompt lets AdversarySim actually build one. There is no path from "the model said so" to "the system did it" that bypasses the operator (strict Human-in-the-Loop).


Requirements

  • Python 3.11+
  • sliver-client on your PATH (only for Sliver features)
  • Ollama running locally (only for LLM features)

Installation

git clone https://github.com/kadohack12/AdversarySim-AI.git
cd AdversarySim-AI

python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate

pip install -e ".[dev]"

Or with uv:

uv venv && uv pip install -e ".[dev]"

Set up the LLM (optional)

ollama serve
ollama pull qwen2.5-coder:7b

Set up Sliver (optional)

Start a Sliver server, generate an operator config, and import it into the client:

sliver-server
sliver-client import operator.cfg

Usage

Prefer a guided tour? The 5-minute walkthrough runs the whole loop — listener, sandbox, implant, telemetry, cleanup — step by step.

adversarysim --help

Check the Sliver connection

adversarysim status

Enumerate sessions, beacons and listeners

adversarysim sessions
adversarysim beacons
adversarysim jobs

Run a discovery command on a session (approval required)

adversarysim discover ab12cd34 whoami
adversarysim discover ab12cd34 "uname -a"
adversarysim discover ab12cd34 ls
adversarysim discover ab12cd34 "cat /tmp/canary_data.txt"
adversarysim discover ab12cd34 "ps aux"
adversarysim discover ab12cd34 "ip a"

You can pass either the bare Linux command (uname -a) or the Sliver console form (execute -o uname -a) — both resolve to the same safe literal. Only the allow-listed read-only commands are accepted:

Technique Bare commands Sliver console command
T1082 System Information Discovery whoami, id, uname -a, hostname, uptime whoami, execute -o id, execute -o uname -a, …
T1083 File and Directory Discovery pwd, ls -la, cat /tmp/canary_*.txt execute -o pwd, ls -la, execute -o cat /tmp/canary_*.txt
T1057 Process Discovery ps aux ps
T1016 System Network Configuration Discovery ip a, route -n execute -o ip a, execute -o route -n

Paths are fixed literals — a canary read is confined to /tmp/canary_*.txt — so discovery can never be aimed at an arbitrary file. The action is state-changing and prompts for [y/N].

MITRE ATT&CK emulation with automatic reports

List the curated techniques and their safety status:

adversarysim mitre list

Run a technique and write a Purple Team report — any valid T#### id is accepted:

adversarysim mitre run T1082                 # auto-selects the active beacon
adversarysim mitre run T1083 ab12cd34        # explicit target
adversarysim mitre run T1033                 # outside the catalogue → generic emulation
adversarysim mitre run T1057 --no-report     # skip the LLM, use curated detections

mitre run resolves the target automatically (beacon first, then session) when no session id is given, routes the command through the Safety Gate ([y/N]), executes it, and writes reports/<ID>_<timestamp>.md containing the metadata, the technique, the Sliver console command, the raw Sliver evidence, and defensive recommendations drafted by the local LLM. Curated ids use their dedicated discovery command; any other valid id is emulated with a generic read-only command and the report is labelled as such. The reports/ directory is created automatically if missing.

Generate an implant (operator approval required)

adversarysim generate --os windows --lhost 10.0.0.1 --lport 8888
adversarysim generate --os linux --lhost 10.0.0.1 --lport 443 --format elf --beacon

Generated implants are written to ./implants by default. Override with ADVERSARYSIM_WORKSPACE=/path/to/dir.

Ask the local model

adversarysim ask "Summarise the detection opportunities for an mTLS beacon over HTTPS."

Interactive shell

adversarysim shell

Inside the shell:

Command Action
/status check Sliver client and server
/sessions list active sessions
/beacons list beacons
/jobs list listeners
/mitre list the curated MITRE ATT&CK technique catalogue
/mitre T1033 run any technique (Safety-Gated) and write a report
/help show help
/quit exit

You can also drive the MITRE flow in natural language, for any technique id — the agent identifies it, maps it to a defensible command, and calls the report tool:

▚ adversarysim › Je veux tester T1033
▚ adversarysim › Simule MITRE T1082
▚ adversarysim › Comment simuler la persistance T1053 ?

Every one of these still passes through the Safety Gate ([y/N]) before anything runs, and writes reports/<ID>_<timestamp>.md on approval.


Configuration

Variable Default Purpose
ADVERSARYSIM_SLIVER_CLIENT sliver-client Path or name of the Sliver client binary.
ADVERSARYSIM_WORKSPACE ./implants Where generated implants are written.
ADVERSARYSIM_REPORTS_DIR ./reports Where Purple Team reports are written.
ADVERSARYSIM_OPERATOR $USER Operator name recorded in report metadata.
ADVERSARYSIM_MODEL qwen2.5-coder:7b Ollama model to use.
OLLAMA_HOST http://127.0.0.1:11434 Ollama server URL.
ADVERSARYSIM_DRY_RUN false Print actions without executing them.
ADVERSARYSIM_ASSUME_YES false Auto-approve actions (sandbox use only).

Project layout

src/adversary_sim/
├── __init__.py     # package metadata
├── cli.py          # rich + typer terminal interface
├── core.py         # async Ollama connector
├── reports.py      # purple-team audit report generator
├── safety.py       # human-in-the-loop approval gate
├── sliver.py       # standalone sliver-client wrapper
└── techniques.py   # allow-listed MITRE ATT&CK catalogue
tests/
├── test_cli.py
├── test_core.py
├── test_safety.py
├── test_sliver.py
├── test_techniques.py    # technique catalogue + report generator
└── test_tool_calling.py  # LLM tool calling through the Safety Gate
docs/
└── WALKTHROUGH.md  # end-to-end purple-teaming lab guide

The Sliver wrapper in src/adversary_sim/sliver.py has no dependency on the rest of the project beyond the standard library, so it can be reused or vendored on its own.


Development

pytest                # run the test suite
ruff check .          # lint
ruff format .         # format

All Sliver and LLM calls in the test suite are mocked, so the tests run offline and require neither a Sliver server nor Ollama.


Legal and ethical use

AdversarySim-AI is intended only for authorised security testing, purple-team exercises, detection engineering and education on systems you own or have explicit written permission to test. Using it against systems without authorisation is illegal in most jurisdictions and is not supported by this project. You are responsible for complying with all applicable laws and for obtaining the necessary authorisation before you begin.


License

MIT — see LICENSE.

Copyright (c) 2026 kadohack12.

About

Safety-first AI assistant for purple teaming and adversary emulation with Sliver C2 and local LLMs (Ollama). Human-in-the-loop, zero telemetry.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages