文章总结: 这篇文章详细介绍了在KaliLinux上完全本地化部署大语言模型的完整流程,涵盖NVIDIAGPU驱动配置、Ollama安装与模型测试、MCPKaliServer部署以及5ire客户端配置。通过这些步骤可实现离线AI辅助安全测试环境,让本地LLM调用Kali安全工具进行渗透测试,适合有Linux基础的安全从业者实操参考。 综合评分: 79 文章分类: AI安全,安全工具,实战经验,渗透测试,安全建设
Kali 与 LLM:完全本地化,使用 Ollama 与 5ire
APT-101 APT-101
APT-101
2026年3月12日 09:20 陕西
注意:本地 LLM 对硬件要求很高. 成本因素在于购买硬件及运行开销。如果你能复用现有设备,那再好不过!
目录
- GPU(NVIDIA)
- Ollama
- MCP 服务器(MCP Kali Server)
- 5ire
- 回顾
GPU(NVIDIA)
首先,我们来确认一下我们的硬件:
$ lspci | grep -i vga07:00.0 VGA compatible controller: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] (rev a1)$
NVIDIA GeForce GTX 1060(6 GB).
驱动程序
我们将通过检查“非自由”专有驱动是否已安装,来确认硬件准备就绪。非自由选项允许 CUDA 支持,而开源的 nouveau 驱动则不具备此功能。
同时,请确保内核与头文件为最新版本:
$ sudo apt update[...]$$ sudo apt install -y linux-image-$(dpkg --print-architecture) linux-headers-$(dpkg --print-architecture) nvidia-driver nvidia-smi[...]│ Conflicting nouveau kernel module loaded ││ The free nouveau kernel module is currently loaded and conflicts with the non-free nvidia kernel module. ││ The easiest way to fix this is to reboot the machine once the installation has finished. |[...]$$ sudo reboot
使用 AMD 或 Intel 等其他厂商 GPU 的情况不在本文讨论范围内。
测试
重启后重新登录,我们可用 nvidia-smi 快速验证:
$ lspci -s 07:00.0 -v | grep KernelKernel driver in use: nvidiaKernel modules: nvidia$$ lsmod | grep '^nouveau'$$ lsmod | grep '^nvidia'nvidia_drm 126976 2nvidia_modeset 16632 3 nvidia_drmnvidia 60710912 29 nvidia_drm,nvidia_modeset$$ nvidia-smiTue Jan 27 14:33:31 2026+-----------------------------------------------------------------------------------------+| NVIDIA-SMI 550.163.01 Driver Version: 550.163.01 CUDA Version: 12.4 ||-----------------------------------------+------------------------+----------------------+| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC || Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. || | | MIG M. ||=========================================+========================+======================|| 0 NVIDIA GeForce GTX 1060 6GB Off | 00000000:07:00.0 On | N/A || 0% 30C P8 6W / 120W | 25MiB / 6144MiB | 0% Default || | | N/A |+-----------------------------------------+------------------------+----------------------++-----------------------------------------------------------------------------------------+| Processes: || GPU GI CI PID Type Process name GPU Memory || ID ID Usage ||=========================================================================================|| 0 N/A N/A 969 G /usr/lib/xorg/Xorg 21MiB |+-----------------------------------------------------------------------------------------+$
一切看起来都正常。
Ollama
接下来,我们需要安装 Ollama。Ollama 将允许我们加载本地 LLM。
Ollama 是 llama.cpp 的封装。5ire 支持 Ollama,但不支持 llama.cpp。
如果你不想执行 curl | bash,请参阅手动安装方法;或按以下方式操作(针对 v0.15.2,撰写时最新版,2026-01-27)
$ sudo apt install -y curl[...]$$ curl --fail --location https://ollama.com/download/ollama-linux-amd64.tar.zst > /tmp/ollama-linux-amd64.tar.zst[...]$$ file /tmp/ollama-linux-amd64.tar.zst/tmp/ollama-linux-amd64.tar.zst: Zstandard compressed data (v0.8+), Dictionary ID: None$ sha512sum /tmp/ollama-linux-amd64.tar.zst1c16259de4898a694ac23e7d4a3038dc3aebbbb8247cf30a05f5c84f2bde573294e8e612f3a9d5042201ebfe148f5b7fe64acc50f5478d3453f62f85d44593a1 /tmp/ollama-linux-amd64.tar.zst$$ sudo tar x -v --zstd -C /usr -f /tmp/ollama-linux-amd64.tar.zst[...]$$ sudo useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama$$ sudo usermod -a -G ollama $(whoami)$$ cat <<EOF | sudo tee /etc/systemd/system/ollama.service >/dev/null[Unit]Description=Ollama ServiceAfter=network-online.target[Service]ExecStart=/usr/bin/ollama serveUser=ollamaGroup=ollamaRestart=alwaysRestartSec=3Environment="PATH=\$PATH"[Install]WantedBy=multi-user.targetEOF$$ sudo systemctl daemon-reload$$ sudo systemctl enable --now ollamaCreated symlink '/etc/systemd/system/multi-user.target.wants/ollama.service' → '/etc/systemd/system/ollama.service'.$$ systemctl status ollama● ollama.service - Ollama ServiceLoaded: loaded (/etc/systemd/system/ollama.service; enabled; preset: disabled)Active: active (running) since Tue 2026-01-27 14:44:39 GMT; 18s ago[...]$$ oama -vollama version is 0.15.2$
服务报告为活跃且正在运行(日志中无错误)。
LLM
现在我们需要一个供 Ollama 运行的 LLM!有几个地方可获取预生成的 LLM:
- Ollama.com
- HuggingFace.co(简称 HF)
你想要哪种模型?是时候实验了!
- 我们需要一个支持 “Tools” 功能的模型。我们稍后会解释为什么这很重要。
- 你的硬件将决定你能运行多复杂的模型。我们使用的硬件有 6GB VRAM,因此我们需要小于该容量的模型。
我们选择了 3 个进行测试:
$ ollama listNAME ID SIZE MODIFIEDllama3.1:8b 46e0c10c039e 4.9 GB 8 minutes agollama3.2:3b a80c4f17acd5 2.0 GB 29 minutes agoqwen3:4b 359d7dd4bcda 2.5 GB 39 minutes ago$
测试
让我们测试 Ollama 是否工作正常:
$ ollama run qwen3:4b
首次运行时, 它需要将模型加载到内存中。这可能需要一段时间,具体取决于你的硬件。
当 LLM 加载完成后, 我们将看到提示符。让我们输入 “Hello world!”:
>>> Hello world!Thinking...Okay, the user said "Hello world!" and wants me to respond. Let me think about how to approach this. First, I should acknowledge their greeting. Since they used the classic "Hello World!" which is oftenthe first program in many programming languages, maybe I can relate that to my capabilities. I should make sure to keep the tone friendly and open for further conversation. Let me check if there'sanything specific they might need help with. Maybe they're just testing me or want to start a discussion. I'll keep the response simple and welcoming, inviting them to ask questions or share what theyneed help with. Also, I should avoid any markdown and keep it natural. Alright, time to put that together....done thinking.Hello! How can I assist you today? Whether you have questions, need help with something, or just want to chat, I'm here for you! What's on your mind?>>> /exit$
我们可通过以下命令检查 Ollama 状态:
$ ollama psNAME ID SIZE PROCESSOR CONTEXT UNTILqwen3:4b 359d7dd4bcda 3.5 GB 100% GPU 4096 4 minutes from now$
很好,看起来一切正常!
MCP 服务器(MCP Kali Server)
我们现在需要安装并运行一个 MCP 服务器。
对于本指南, 我们使用的是 Kali 的最小安装版, 意味着没有预装工具。
继续使用 mcp-kali-server:
$ sudo apt install -y mcp-kali-server dirb gobuster nikto nmap enum4linux-ng hydra john metasploit-framework sqlmap wpscan wordlists[...]$$ sudo gunzip -v /usr/share/wordlists/rockyou.txt.gz/usr/share/wordlists/rockyou.txt.gz: 61.9% -- replaced with /usr/share/wordlists/rockyou.txt$$ kali-server-mcp2026-01-27 15:54:01,339 [INFO] Starting Kali Linux Tools API Server on 127.0.0.1:5000* Serving Flask app 'kali_server'* Debug mode: off2026-01-27 15:54:01,352INFO] WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.* Running on http://127.0.0.1:50002026-01-27 15:54:01,352 [INFO] Press CTRL+C to quit
长期来看, 有多种方式让 kali-server-mcp 在后台运行, 例如使用 tmux/screen 会话或创建 systemd.unit, 但这超出了本文范围。
测试
现在手动运行 mcp-server:
$ mcp-server2026-01-27 15:54:18,802 [INFO] Initialized Kali Tools Client connecting to http://localhost:50002026-01-27 15:54:18,811 [INFO] Successfully connected to Kali API server at http://localhost:50002026-01-27 15:54:18,811 [INFO] Server health status: healthy2026-01-27 15:54:18,826 [INFO] Starting Kali MCP server2026-01-27 15:54:18,804 [INFO] Executing command: which nmap2026-01-27 15:54:18,806 [INFO] Executing command: which gobuster2026-01-27 15:54:18,807 [INFO] Executing command: which dirb2026-01-27 15:54:18,808 [INFO] Executing command: which nikto2026-01-27 15:54:18,810 [INFO] 127.0.0.1 - - [27/Jan/2026 15:54:18] "GET /health HTTP/1.1" 200 -
一切看起来都很好!无错误或警告。
我们还可以看到 kali-server-mcp 的日志中新增了额外行。很好。
5ire
因此,我们有一个本地 LLM 和一个 MCP 服务器。Ollama 不支持 MCP(目前?),所以我们需要一个能桥接两者的工具。这就是 5ire ——“一个简洁的 AI 助手与 MCP 客户端”。
接下来,下载 5ire 的 AppImage(撰写时为 5ire-0.15.3-x86_64.AppImage,2026-01-27)并创建菜单项:
$ curl --fail --location https://github.com/nanbingxyz/5ire/releases/download/v0.15.3/5ire-0.15.386_64.AppImage > 5ire-x86_64.AppImage[...]$$ file 5ire-x86_64.AppImage5ire-x86_64.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, stripped$ sha512sum 5ire-x86_64.AppImagebdf665fc6636da240153d44629723cb311bba4068db21c607f05cc6e1e58bb2e45aa72363a979a2aa165cb08a12db7babb715ac58da448fc9cf0258b22a56707 5ire-x86_64.AppImage$$ sudo mkdir -pv /opt/5ire/mkdir: created directory '/opt/5ire/'$$ sudo mv -v 5ire-x86_64.AppImage /opt/5ire/5ire-x86_64.AppImagerenamed '5ire-x86_64.AppImage' -> '/opt/5ire/5ire-x86_64.AppImage'$$ chmod -v 0755 /opt/5ire/5ire-x86_64.AppImagemode of '/opt/5ire/5ire-x86_64.AppImage' changed from 0664 (rw-rw-r--) to 0755 (rwxr-xr-x)$$ mkdir -pv ~/.local/share/applications/mkdir: created directory '/home/kali/.local/share/applications/'$$ cat <<EOF | sudo tee ~/.local/share/applications/5ire.desktop >/dev/null[Desktop Entry]Name=5ireComment=5ire Desktop AI AssistantExec=/opt/5ire/5ire-x86_64.AppImageTerminal=falseType=ApplicationCategories=Utility;Development;StartupWMClass=5ireEOF$$ sudo ln -sfv /opt/5ire/5ire-x86_64.AppImage /usr/local/bin/5ire'/usr/local/bin/5ire' -> '/opt/5ire/5ire-x86_64.AppImage'$$ sudo apt install -y libfuse2t64[...]$
我们现在既可以通过菜单,也可以从终端调用它。
现在我们需要配置 5ire 以使用 Ollama(LLM)和 mcp-kali-server(MCP 服务器):
打开 5ire,然后:
- 5ire → Workspace → Providers → Ollama 启用默认设置,并为每个 Ollama 模型启用 “Tools” 和 “Enabled” → 保存。对每个模型重复此操作。
(如需,可选择一个模型作为默认)
测试
现在让我们测试 5ire!
- 新建聊天 → Ollama Hello world!
再次检查状态:
$ ollama psNAME ID SIZE PROCESSOR CONTEXT UNTILqwen3:4b 359d7dd4bcda 3.5 GB 100% GPU 4096 2 minutes from now$
看起来运行良好!现在设置 MCP。
MCP 客户端(5ire)
我们可以使用 5ire 的 GUI:
- 5ire → Tools → Local
现在填写字段:
- 名称:
mcp-kali-server - 描述:
MCP Kali Server - 批准策略:……由你决定
- 命令:
/usr/bin/mcp-server保存 别忘了启用它!
我们可以查看现在有什么可用的。... → 浏览
测试
- 新建聊天 → Ollama
你能帮我扫描一下
scanme.nmap.org的端口吗?目标端口:TCP 80、443、21、22?
原文:https://www.kali.org/blog/kali-llm-ollama-5ire/?utm_source=dlvr.it&utm_medium=twitter
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:APT-101 APT-101 APT-101《Kali 与 LLM:完全本地化,使用 Ollama 与 5ire》
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。









评论