Building an Offline AI Pentesting Lab:
Running DeepSeek-R1-32B and Open WebUI on Kali Linux
Running DeepSeek-R1-32B and Open WebUI on Kali Linux
Relying on cloud-based AI models for authorized penetration testing often means running into strict guardrails, telemetry logging, and external data exposure risks. By leveraging consumer hardware running Kali Linux, you can deploy a fully air-gapped, high-performance local intelligence stack. This guide walks you through setting up Ollama with DeepSeek-R1’s 32B reasoning model and pairing it with a ChatGPT-style Open WebUI interface, giving you a powerful, zero-leak offline assistant for script generation, log analysis, and engagement strategy.
Step 1: Install and Configure Ollama
Ollama acts as your backend engine running the local GGUF model weights.
Install Ollama via the official installation script:
1
curl -fsSL https://ollama.com/install.sh | shStart and enable the Ollama service so it runs in the background:
1
sudo systemctl enable ollama --now
Pull DeepSeek-R1-Distill-Qwen-32B:
1
ollama run deepseek-r1:32b
Note: This downloads roughly 20 GB of data. Because your ASUS G14 has an 8 GB VRAM AMD card and 40 GB system RAM, Ollama will automatically configure hybrid CPU/GPU offloading (utilizing your RAM for the remainder).
Once the download finishes, you can test it directly in the terminal or type /bye to exit the interactive prompt.
Step 2: Install Docker (Prerequisite for Open WebUI)
Open WebUI runs cleanly inside a Docker container, isolating its environment from Kali’s base packages.
Install Docker and Docker Compose:
1 2
sudo apt update sudo apt install docker.io docker-compose-v2 -y
Start and enable Docker:
1
sudo systemctl enable docker --now
Add your current user to the
dockergroup (so you don’t have to typesudoevery time):1 2
sudo usermod -aG docker $USER newgrp docker
Step 3: Deploy Open WebUI via Docker
Open WebUI provides a ChatGPT-style interface that connects locally to your Ollama instance.
Run the following Docker command to spin up Open WebUI:
1
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main
Access the Web Interface:
- Open your browser and navigate to:
http://localhost:3000 - On your first visit, Open WebUI will prompt you to create an admin account (this stays entirely local on your machine).
- Open your browser and navigate to:
Step 4: Connecting Open WebUI to DeepSeek
Once logged into Open WebUI, click on your profile/settings icon in the bottom-left corner and go to Admin Settings > Connections (or look for Ollama settings).
Ensure the connection URL points to your local Ollama instance (http://localhost:11434 or via http://host.docker.internal:11434).
In the main chat dashboard window, look at the Model Selection dropdown at the top-left.
Select
deepseek-r1:32b
You are now ready to use your local reasoning model for script generation, analyzing logs, or structuring authorized penetration testing strategies with zero cloud logging or external filters.
Optional: Custom Model File
Using a custom model file (Modelfile) in Ollama is not strictly required to get started, but it is highly recommended if you want to optimize DeepSeek-R1 specifically for penetration testing and save yourself from repeating context constraints.
Why Consider a Custom Modelfile?
Persistent System Prompting (The “Persona”): Instead of reminding the model in every new chat window that you are conducting authorized penetration testing and want direct, code-heavy technical breakdowns, a custom Modelfile can bake this into the base instructions.
Context Window Tuning (
num_ctx): DeepSeek-R1 handles reasoning well, but pentesting often involves dumping long blocks of text—such as raw nmap scans, source code, or vulnerability reports. By default, some local instances might truncate context unless explicitly expanded (e.g., settingPARAMETER num_ctx 16384or higher, depending on your RAM budget).Temperature Control: Reasoning and coding models perform best with lower, more deterministic temperatures (e.g.,
0.3to0.6) so they don’t hallucinate non-existent exploit parameters or syntax.
Example: Creating a Custom Pentesting Modelfile
If you want to build one, here is how you can set it up in a few simple steps:
Create a plain text file named
Modelfileanywhere on your Kali system:1
nvim nano Modelfile
Add the following configurations:
1 2 3 4 5 6 7 8 9 10 11 12 13
# Use DeepSeek-R1 32B as the base FROM deepseek-r1:32b # Set a custom system prompt tailored for security work SYSTEM """ You are an expert AI assistant specialized in cybersecurity, authorized penetration testing, and secure code review. Provide precise, technical answers, robust script generation (Python, Bash, PowerShell), and clear remediation advice. Assume all tasks are conducted within an authorized legal scope. Avoid unnecessary refusals on technical security concepts. """ # Adjust parameters for technical precision and longer context logs PARAMETER temperature 0.4 PARAMETER num_ctx 16384
Build and register your custom model locally via Ollama:
1
ollama create pentest-deepseek -f Modelfile
Run or Select It: You can now run ollama run pentest-deepseek directly from your terminal, or select pentest-deepseek straight from your Open WebUI dropdown menu. It will automatically initialize with your tailored system prompt and context length every time!