cd ../blog
#security#pentest#mcp#kali#local-llm

An Offline AI Pentest Lab: Kali, MCP, and a Local Model Against My Own Apps

I put Kali in a container, installed the Kali MCP server, and let a model running on my Mac with vMLX drive the attack: nmap and nikto for recon, then a SQL injection on the login that gets admin and defaces the shop. A small local model drives the tools, a bigger one writes the report, all offline and isolated, against targets I own.

Jaba Macharashvili 8 min read

In this post
  1. The pieces
  2. Kali and the MCP server
  3. Keeping it in a box
  4. Letting the model drive
  5. Where model size shows up
  6. Off the leash
  7. OWASP Juice Shop
  8. Pointing it at your own code
An animated flow: a local model on vMLX talks to a Kali MCP tool bridge, which runs nmap and nikto against a target. Kali and the target sit inside an isolated lab with no route to the internet. A dot travels along the path from the model to the target. The model never leaves the Mac, the target never leaves the lab.

Let me say this first, because the rest of the post makes no sense without it: this is not hacking. Everything here runs against software I build, on a network that cannot reach the internet, on my own Mac. The one third-party target is OWASP Juice Shop, an app that exists so people can attack it. There is no victim, no one else’s server, and nothing leaving the laptop. If you take one thing from this post, take the setup, point it at your own code, and keep it that way.

With that out of the way: I wanted to see how far a local model could get at running security tools on its own, something that stays on my machine and never phones home. The short answer is that even a tiny model can run the scans and pick the attack, and a bigger one writes it all up. Here is the whole thing.

The pieces

Three parts, each doing one job.

The model runs on my Mac with vMLX, an MLX inference server for Apple Silicon. It serves an OpenAI-compatible API, so anything that can talk to OpenAI can talk to it. I ran two sizes through it: a 4-bit Qwen2.5 1.5B that loads in a few seconds, and a 31B when I wanted a readable report at the end. Same server, same API, one line to switch.

The tools run in Kali. Kali ships mcp-kali-server, which is two programs: an API server that runs the actual tools, and an MCP bridge that exposes them as MCP tools over stdio. I ran Kali as a container so I could throw it away and rebuild it, and so the target could sit on the same private network.

The glue is a small agent loop. It asks the model what to do, the model answers with a tool call, the loop runs that tool through the MCP bridge, and the result goes back to the model for the next step.

Terminal: vmlx serves the Gemma-4-31B model with the Apple MLX backend on port 8080, and curling the models endpoint returns the model id. OpenAI and Anthropic compatible, offline. A comment notes the 1.5B swaps in by changing one line.

Kali and the MCP server

Kali in a container is one line, and the MCP server is an apt package:

sudo apt install -y mcp-kali-server nmap nikto
kali-server-mcp &          # the API that runs the tools
curl -s localhost:5000/health | jq

The health check is worth a look, because it tells you which tools the API can actually find on the box:

Terminal: installing mcp-kali-server, nmap and nikto on Kali, starting the API server, and a health check that reports status healthy with nmap, nikto, dirb and gobuster all available.

The MCP bridge turns that API into tools a model can pick from. When I asked it what it offers, this is the list:

Terminal: the Kali MCP server lists its tools, including nmap_scan, nikto_scan, gobuster_scan, dirb_scan, sqlmap_scan, wpscan_analyze, hydra_attack, enum4linux_scan, server_health and execute_command.

That last one, execute_command, runs anything on the box. For a lab that is fine. On anything you care about it is a loaded gun, and it is the main reason this whole thing lives on a throwaway network with nowhere to go.

Keeping it in a box

The target has to be reachable by Kali and by nothing else. I put both on a Docker network marked internal, which means it has no gateway out. Juice Shop running on it complained in its own logs that it could not reach the internet, which is exactly what I wanted to see.

docker network create --internal lab
docker run -d --name juice --network lab bkimminich/juice-shop
docker network connect lab kali

Those docker commands are not Docker Desktop. On this Mac the containers run in Kiri, a Docker-compatible container runtime for Apple Silicon, so docker is really Kiri’s CLI. kiri ps, kiri network, and the rest work the same, and kiri ui opens a window with the same containers if you would rather click than type.

The Kiri app on macOS, Containers view, showing the three lab containers kali, juice and juiceview all running, with the Kiri sidebar, a Docker-compatible layout, and a Linux VM running indicator.

The same thing from the terminal, since docker here is Kiri:

Terminal: kiri ps lists the three lab containers (kali, juice, juiceview) running in Kiri, a Docker-compatible runtime for Apple Silicon, with a note that every docker command in the post is really Kiri.

The model lives on the Mac and talks to the tools over a local channel. The tools live in the lab and talk to the target. Neither half can reach past its own box. That is the whole safety story, and it is worth getting right before you run a single scan.

Letting the model drive

The agent loop is short. It hands the model the tool schemas, sends the first instruction, and then runs whatever the model asks for. For the first run I kept the model on a tight leash and only exposed the read-only scanners: nmap, nikto, and the health check. No execute_command, no password tools.

I started with the 1.5B, pointed it at Juice Shop, and watched:

Terminal: the small local model runs the scan. Step one calls nmap_scan and finds port 3000 open running Juice Shop. Step two calls nikto_scan and reports an open /ftp/ path, a wildcard CORS header, and missing CSP and HSTS headers. Step three the model summarises the findings.

Even at 1.5B, the model found the open port, picked nikto next, pointed it at the web service, and read back real findings: the /ftp/ directory reachable through robots.txt, a wildcard Access-Control-Allow-Origin, and missing security headers. All of that is true, and all of it came from the model deciding what to run.

Where model size shows up

The scanning works at 1.5B. The write-up does not. When the small model reached the summary step, it started fine and then got stuck in a loop, repeating “the X header is *” for a dozen lines until it ran out of tokens. It can pick a tool and read a result, but it cannot hold a report together.

So I switched the model and left everything else alone. vMLX serves a 31B on the same machine, and the agent loop points at it by changing one line. Same tools, same lab, same prompt:

Terminal: the same agent loop running on a 31B model. It calls nmap_scan and nikto_scan against Juice Shop, then writes a clean structured summary naming the open directories, the missing HSTS, CSP and referrer-policy headers, and the wide-open CORS.

The 31B ran the same two scans and then wrote the part the small one choked on: Juice Shop named, the interesting directories listed, the missing headers and the wide-open CORS laid out in order. The tools do the real work and they do not care how big the model is. The model chooses the next step and explains the output, and the explaining is where size earns its keep. The trade is load time and memory: the 1.5B is ready in seconds, the 31B takes longer and wants the RAM.

Off the leash

Recon is polite. It reads, it does not touch. To see the other half I took the read-only limit off and gave the agent execute_command, the tool that runs anything on the Kali box. In the lab that is the point. Juice Shop is built to be broken into, so I pointed the 31B at it and told it to get in.

It went straight for the right attack: a SQL injection on the login, POST /rest/user/login, the exact endpoint and technique Juice Shop is known for. The payload that lands is the classic one, ' OR 1=1-- in the email field. It logs you in as the first row in the users table, which is the admin, and from that admin token the break-in writes to the product API and rewrites a product to deface the shop.

Terminal: the exploit chain. Step one, a SQL injection on the login logs in as admin@juice-sh.op and returns a session token. Step two, a PUT to the product API using the stolen token renames product one to OWNED BY A LOCAL MODEL.

The storefront proves it. The product now carries the defacement, and Juice Shop’s own banner pops up to say the “Login Admin” challenge is solved. That green bar is the app confirming the break-in worked.

The OWASP Juice Shop storefront in the lab, with a product renamed to OWNED BY A LOCAL MODEL, tested in an offline lab, and a green banner from the app confirming the Login Admin challenge was solved.

Choosing this attack is the model’s job, and it went for it without being told how: a scan, a look at the results, and it reaches for the login. The same small-versus-big split from the recon shows up again in how precisely a model lands the exact payload, but the part that stands out is that a model running on a laptop can read a scan, pick the way in, and take it.

None of this left the lab. The network has no way out, the target is a practice app that ships with these holes on purpose, and the only account I logged into is one that exists to be logged into. That is the line: run the fun part against something built to be attacked, on a network that cannot reach anything real.

OWASP Juice Shop

I used Juice Shop as the practice target because it is built to be scanned and broken. Its own welcome screen says it is “the opposite of a best practice application,” full of intended vulnerabilities, made for training and demos. Running tools at it, and then an exploit, is the point of it existing.

Pointing it at your own code

The reason I built this is to run it against my own apps before anyone else does. The flow does not change. You build a dev image of your app, put it on the same internal network, and give the agent its hostname instead of juice. nmap finds the ports, nikto reads the headers, and if you let it reach for gobuster_scan it starts walking for paths you forgot you shipped. Keep it on the isolated network, keep the model local, and the whole run stays between you and your own code.

A few rules I hold myself to, and would ask you to hold too: only ever aim this at targets you own or have written permission to test, keep the lab network offline, and never wire the execute_command tool to anything that matters. The tooling is the easy bit. Staying inside those lines is what makes it fine to publish.

← All posts

Got it working, or stuck? [email protected]