[Kali Linux] Building a Local LLM Agent for Pentesting

This time, to save as much time as possible on penetration testing practice
and bug hunting in bug bounty programs,
I’m going to build a local LLM, which is still a hot topic (?) right now.
The setup is as follows.
1. Update the Package List and Install Docker
1 | $ sudo apt update && sudo apt install -y docker.io |
If you see the output below, the installation was successful.
1 | ┌──(root💀kali)-[/home/kali/H■■n■/■■■ls] |
1. Installation Double-Check
1 | $ sudo docker run hello-world |
If you see the output below, the installation is complete
1 | ┌──(root💀kali)-[/home/kali/H■■k■■■/■■■ls] |
3. Pull the Open WebUI Image
1 | $ docker pull ghcr.io/open-webui/open-webui:main |
If you see the output below, it was successful
1 | ┌──(root💀kali)-[/home/kali/H■■■■■g/■■■ls] |
3-1. Verify the Image
1 | $ ddocker ps -a |
4. Run the Container
1 | $ docker run -d -p 3000:8080 -v open-webui:/app/backend/data --name open-webui ghcr.io/open-webui/open-webui:main |
4-1. Enable GPU Support
To support an Nvidia GPU, add the --gpus all option to the docker run command
1 | # Ex) |
5. Install Ollama
This command line is official, so you can type it in and run it with confidence
1 | $ curl -fsSL https://ollama.com/install.sh | sh |
If you see the output below, the installation was successful.
1 | ┌──(root💀kali)-[/home/kali/H■■■■■■/■■■ls] |
Start the Service
1 | $ systemctl start ollama |
6. How to Run a Model (The Most Important Part)
[1]. [Recommended] Download a Low-Spec Model
$ ollama run qwen2.5-coder:3b
[2]. Download + Run a Model (All in One Go)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 ```$ ollama run deepseek-r1:7b # Most recommended```
[3]. Popular Model Examples <br>
```$ ollama run gemma3:12b``` <br>
```$ ollama run qwen2.5:14b``` <br>
```$ ollama run phi4``` <br>
```$ ollama run mistral:7b``` <br>
```$ ollama run deepseek-r1:8b``` <br>
[4]. Korean-Specialized Model <br>
```$ ollama run EEVE-Korean-Instruct-10.8B``` <br>
[5]. Japanese-Specialized Model (Japanese-English Translation) <br>
```$ ollama pull 7shi/gemma-2-jpn-translate:2b-instruct-q8_0``` <br>
```$ ollama run 7shi/gemma-2-jpn-translate:2b-instruct-q8_0``` <br>
[5-1]. Japanese-Specialized Model [Coding] <br>
A classic model for coding<br>
- Model: ```qwen2.5-coder(0.5B ~ 32B)```<br>
. Points<br>
- Supports a large number of programming languages and is strong at code completion,<br>
refactoring, test generation, and more.<br>
- Without a GPU, 3B or smaller; with a GPU, 7B ~ 14B is realistic for a laptop<br>
```$ ollama pull qwen2.5-coder:3b```<br>
```$ ollama run qwen2.5-coder:3b```<br>
[6-1]. Tips for Speeding Up Low-Spec CPU Environments <br>
- Secure swap memory: If your physical RAM is 8GB or less,<br>
make sure a swap file of at least 4GB is enabled<br>
on the Linux host (free -h). This prevents the container<br>
from dying during momentary memory spikes.<br>
- Auxiliary model for bypassing censorship (optional): If qwen2.5-coder:3b<Br>
refuses to write a particular attack payload, among 3B-class lightweight models,<br>
instead of the uncensored dolphin-mistral, pull the ultra-lightweight<br>
mannix/llama3.2-3b-abliterated tag as well<br>
and use it as a secondary model; it runs without trouble even in an 8GB environment.<br>
Additionally, if you tell me the CPU core count of the host Linux<br>
or the Linux distribution (Kali, Ubuntu, etc.),<br>
I can also put together thread optimization (num_thread) settings or<br>
a one-liner shell function that automates scanning tools (for registering in ```~/.bashrc```)<br>
as well
[7]. 🔧Frequently Used Commands <br>
``` bash
$ ollama list # List of Installed Models
$ ollama pull llama3 # Model download
$ ollama run llama3 # Model execution
$ ollama rm llama3 # Model deletion
$ ollama ps # Check running models
$ ollama show llama3 # Model Details
[8]. Running via the API (the OpenAI format can be used as is)
1 | # Basics Generate API |
[9]. Things to Check When It Won’t Run
Windoes
-Install with administrator privileges
-Check that Ollama is running in the background
-Test ollama --version in PowerShell
Linux
-Check the service status
$
-Change the port if there is a conflict
$ OLLAMA_HOST=0.0.0.0:11435 ollama serve
Extras
👉 Click to expand
🧩 1. GPU Usage Settings (Ollama)
✔️ Conditions for Using an NVIDIA GPU
• Windows: CUDA is not required; Ollama uses the GPU on its own
• Linux: CUDA Toolkit + NVIDIA Driver required
• You must choose a model according to your GPU memory (VRAM)
• DeepSeek-R1 7B → requires about 6GB of VRAM
• DeepSeek-R1 14B → requires about 9GB of VRAM
• DeepSeek-R1 32B → requires about 20GB of VRAM (RTX 3090/4090 recommended)
✔️ Verify GPU Activation
1 | $ ollama run llama3 "nvidia-smi Show me the output." |
→ If the GPU is detected, everything is working.
✔️ Setting a GPU Memory Limit (When VRAM Is Insufficient)
1 | $ set OLLAMA_GPU_MEMORY=6GB |
🧠2. Optimizing DeepSeek-R1 (Speed·Quality·VRAM)
✔️ 1) Choosing Quantization (Q4 recommended)
• Q4_K_M: Best balance of speed and quality (officially recommended by DeepSeek)
• Q8 if you have VRAM to spare
• FP16 only when you have plenty of VRAM
✔️ 2) Model Selection Strategy
• 7B Distill: Optimal for laptops and 8GB GPUs
• 14B Distill: Stable on a 12GB GPU
• 32B Distill: Best quality on a 24GB GPU (stronger than o1-mini)
✔️ 3) Performance Tuning Points
Based on the DeepSeek optimization guide:
• Reduce TTFT (time to first token) → shorten the prompt length, use Q4
• Improve TPOT (speed per token) → keep GPU utilization at 70% or higher
• Optimize the KV Cache → avoid using an overly long context length (VRAM spikes above 8K)
✔️ 4) Running DeepSeek-R1 in Ollama
1 | $ ollama pull deepseek-r1:7b |
3. Installing & Running Open WebUI (The Easiest Method)
Open WebUI is the best local LLM UI, with automatic integration with Ollama.
3-1. How to Download
✔️ Common to Windows / macOS / Linux
Official site:
📥 https://openwebui.com → Click “Download”
✔️ Docker Installation (Most Stable)
1 | $ docker pull ghcr.io/open-webui/open-webui:latest |
3-2. Installation Method (Docker-based)
✔️ 1) Basic Run
1 | $ docker run -d -p 3000:8080 \ |
✔️ 2) Ollama Integration
If Ollama is running on the default port (11434), it connects automatically.
If manual configuration is needed:
Open WebUI → Settings → LLM Providers → Enter the Ollama URL
1 | $ http://localhost:11434 |
4. Optimizing Open WebUI + DeepSeek-R1
✔️ 1) Preloading the Model (Speed Improvement)
Open WebUI → Settings → Models → Preload Model
→ Select deepseek-r1:7b
✔️ 2) Enable Chain-of-Thought(COT)
Since DeepSeek-R1 is a COT-based model,
add the following to the Prompt:
1 | # DeepSeek-R1 Reasoning Mode |
✔️ 3) GPU Memory-Saving Options
Open WebUI → Settings → Performance
• Enable KV Cache
• Reduce Context Length (4096 recommended)
🧱 5. Overall Configuration Summary
| Item | Recommendation |
|---|---|
| GPU | RTX 3060/4060 or higher |
| Model | DeepSeek-R1 7B or 14B |
| Quantization | Q4_K_M |
| UI | Open WebUI (Docker) |
| API | Ollama(OpenAI-compatible) |
🟦 1. Installing Open WebUI on Windows Without Docker (Python Method)
The most stable official way to run Open WebUI on Windows
without Docker is a standalone Python-based run (pip installation).
🧩 1-1. What You Need
• Windows 10/11
• Install Python 3.11
• Install Ollama (assuming it is already installed)
Install: https://ollama.com/download
🧩 1-2. Create a Python Virtual Environment
In PowerShell or CMD, move to the folder you want, then:
1 | $ python -m venv openwebui-env |
Activate the virtual environment
1 | $ openwebui-env\Scripts\activate |
🧩 1-3. Install Open WebUI
With the virtual environment active:
1 | $ pip install open-webui |
🧩 1-4. Run Open WebUI
1 | $ open-webui serve |
The default port is 8080
🧩 1-5. Accessing It
In your browser:
1 | $ http://localhost:8080 |
The first time you connect, the Sign Up screen appears,
and the account information you enter is stored only on your PC
🟦 2. Connecting Ollama + Open WebUI on Windows
Open WebUI automatically detects the API server (http://localhost:11434) provided by Ollama.
🧩 2-1. Verify That Ollama Is Running
In PowerShell:
1 | $ ollama serve |
Or check whether it is running:
1 | $ ollama --version |
🧩 2-2. Verify the Ollama Connection in Open WebUI
After accessing Open WebUI:
Settings → Models → Ollama Models
The models installed in Ollama appear here automatically.
Example:
1 | $ ollama pull llama3 |
🧩 2-3. When the Models Don’t Show Up
Manually specify the Ollama API address in Open WebUI:
Settings → LLM Providers → Ollama → API Base URL
Enter:
1 | $ http://localhost:11434 |
On Windows, since this is not Docker, use localhost instead of host.docker.internal.
📌 Flow Summary (Reconstructed Based on the Exact Structure)
① Install Ollama
• Download the Windows installer
• Test a model with ollama run llama3, etc.
② Install Open WebUI
• Choose between the Docker and Python methods
• On Windows, the Python method is the lightest and conflict-free
③ Run Open WebUI
• open-webui serve
• Go to localhost:8080 in your browser
• Create the first account
④ Automatic Integration with Ollama
• Open WebUI automatically detects the Ollama API (11434)
• Check the installed models under Settings → Models
⑤ Download a Model
• In the terminal, run ollama pull llama3
• Can be used right away in Open WebUI
⑥ Troubleshooting
• Models not showing → check the API Base URL
• Port conflict → open-webui serve –port 9000
• Ollama not running → re-run ollama serve
🟦 4. Optimal Windows Configuration (Recommended)
| Component | Recommendation |
|---|---|
| Installation method | Python method (Open WebUI) |
| Ollama | Standard installation (Windows EXE) |
| Model | llama3 / qwen2.5 / mistral |
| GPU | NVIDIA RTX 3060 or higher |
| Run | open-webui serve + ollama serve |
🟦 5. Overall Installation Flow Summary (Windows, Without Docker)
1 | 1) Python Install |
Resolving GPU (VRAM) Shortages, Installing Plugins, and Using RAG
Below, for a Windows + Ollama + Open WebUI environment, is a guide covering
everything from resolving GPU (VRAM) shortages → installing Open WebUI plugins → setting up RAG (document upload),
written as a practical, detailed guide that you can apply right away.
It is organized in the following order:
How to Fix GPU (VRAM) Shortages (for Ollama + Open WebUI)
How to Install Open WebUI Plugins (Extensions / Pip Plugins)
Setting Up the RAG (Document Upload) Feature (Vector DB + Document Management + Search)
🟦 1. How to Fix GPU (VRAM) Shortages
VRAM shortages are the most common problem when using
large models such as DeepSeek-R1, Llama3.1, Qwen2.5.
Ways to resolve VRAM shortages in a Windows + Ollama environment, organized by priority
✅ 1) Lowering Quantization — Most Effective
A way to make the model lighter.
Running a Model at Q4 in Ollama
1 | $ ollama run deepseek-r1:7b-q4 |
When Creating a Model Yourself
Specify it in the Modelfile like this:
1 | FROM deepseek-r1:7b |
Recommended Quantization
| Component | Recommendation | Quality | Recommendation |
|---|---|---|---|
| Q4_K_M | Very low | Good | ⭐ Optimal |
| Q5_K_M | Medium | Better | When you have VRAM to spare |
| Q8 | High | Best | GPU with 24GB or more |
✅ 2) Reducing the Context Length (Open WebUI Setting)
A long context length eats up a lot of VRAM.
Open WebUI → Settings → Models → Advanced → Context Length
• Default: 4096
• When VRAM is insufficient: reduce it to 2048 or 1024
✅ 3) Disable or Reduce the KV Cache
The KV Cache increases speed but uses a lot of VRAM.
Open WebUI → Settings → Performance
• Enable KV Cache → Turn off
• Or reduce the KV Cache Size
✅ 4) Setting a GPU Memory Limit (Windows)
Ollama can limit GPU usage through an environment variable.
PowerShell:
1 | $ setx OLLAMA_GPU_MEMORY 6GB |
Example:
• 8GB GPU → 5~6GB
• 6GB GPU → 4GB
• 4GB GPU → 3GB
✅ 5) Force CPU Mode (Almost No VRAM Used)
It gets slower, but the VRAM problem is completely resolved.
1 | $ ollama run deepseek-r1:7b --cpu |
🟩 Summary of Fixes for VRAM Shortages
Use Q4 quantization
Reduce the context length
Reduce the KV Cache
Limit GPU memory
Use CPU mode
🟧 2. How to Install Open WebUI Plugins
Open WebUI is extended in two ways: Extensions(Extension Features) and Pip plugins.
✔️ 2-1. Installing Extensions (Easiest)
Open WebUI → Settings → Extensions
A list of plugins you can install right away appears here.
Example plugins:
1 |
|
Example:
1 | $ pip install open-webui-plugin-rag |
Activating the Plugin
Open WebUI → Settings → Extensions → Installed
→ Plugin ON
✔️ 2-3. Installing Custom Plugins
You can also pull a plugin directly from GitHub.
1 | $ git clone https://github.com/Username/pluginname.git |
🟪 3. Setting Up the RAG (Document Upload) Feature
RAG is a feature that takes PDF, Word,
and text files you upload → embeds them in a vector DB →
and gives document-based answers when you ask a question.
Open WebUI has the RAG feature built in by default.
✔️ 3-1. Enabling RAG
Open WebUI → Settings → RAG
Turn on the following items:
• Enable RAG
• Enable Document Upload
• Enable Embeddings
✔️ 3-2. Choosing a Vector DB
Open WebUI uses ChromaDB by default
Settings path:
1 | $ Settings → RAG → Vector Database |
Available options:
• ChromaDB (default)
• Milvus
• Weaviate
• Qdrant
On Windows, ChromaDB is the most stable.
✔️ 3-3. Uploading Documents
Open WebUI left menu → Documents
Supported files:
• DOCX
• TXT
• Markdown
• HTML
Once uploaded, embeddings are generated automatically.
✔️ 3-4. How to Use RAG
When asking a question in the chat window:
1 | #RAG |
Or you can just ask a question, and a document-based answer comes out automatically.
✔️ 3-5. Advanced RAG Settings
Settings → RAG → Advanced
• Chunk Size: 512~1024 recommended
• Chunk Overlap: 50~100
• Embedding Model:
• nomic-embed-text
• bge-large
• sentence-transformers
🟩 Overall Summary (Windows + Ollama + Open WebUI)
✔️ Resolving VRAM Shortages
• Q4 quantization
• Reduce the context length
• Reduce the KV Cache
• Limit GPU memory
• CPU mode
✔️ Installing Plugins
• Settings → Extensions → Install
• Or pip install
✔️ RAG Setup
• Settings → RAG → Enable
• Upload files from the Documents menu
• ChromaDB used by default