bettercap 2.41.7 安装指南

目标:本文给出在 Ubuntu 22.04 服务器上安装 bettercap v2.41.7 的完整路径,官方预编译二进制下载安装(方案 A,已实测)为主路径,Kali 仓库安装与源码编译(含实测诊断)为备选,覆盖 sha256 校验、systemd 托管与常见启动故障排查(2026-10-24)。

bettercapbettercap安全测试2026/10/24

bettercap 2.41.7 安装指南

目标:本文给出在 Ubuntu 22.04 服务器上安装 bettercap v2.41.7 的完整路径,官方预编译二进制下载安装(方案 A,已实测)为主路径,Kali 发行版仓库安装(方案 B)与源码编译安装(方案 C,含实测诊断)为备选,覆盖依赖安装、sha256 校验、systemd 托管与常见启动故障排查。bettercap 的定位与选型背景见《bettercap 介绍与选型指南》。

一、环境信息

  • 操作系统:Ubuntu 22.04 LTS(x86_64,内核 5.15+,root 权限)
  • 软件:bettercap v2.41.7(官方预编译 linux amd64 版,自述 built for linux amd64 with go1.24.13)
  • 发布物:bettercap_linux_amd64.zip(27404814 字节)及配套 bettercap_linux_amd64.sha256(来源:GitHub v2.41.7 Release 资产列表,2026-10-24 查询)
  • 运行时系统库:libpcap 1.10.1(Ubuntu 22.04 内置包 libpcap0.8)、libusb-1.0、libnetfilter-queue(透明代理模块需要)
  • 测试网卡:eth0,内网地址 10.89.67.2/24(隔离实验网段)
  • 查询/实测日期:2026-10-24

二、前置条件

  1. root 权限:bettercap 的嗅探、ARP/DNS 欺骗、透明代理均需 root 与 NET_RAW/NET_ADMIN 能力,本文所有命令默认以 root 执行。
  2. 系统依赖库:官方二进制运行期依赖 libpcap(抓包)与 libusb(BLE 模块),Ubuntu 22.04 最小安装需先补齐:
apt update && apt install -y libpcap0.8 libusb-1.0-0
  1. 透明代理能力(可选):http.proxy/https.proxy/dns.proxy/packet.proxy 等透明劫持模块依赖 iptables/nftables 与内核 NFQUEUE 支持;只用 net.recon/net.sniff/arp.spoof 可不装。需要时:
apt install -y iptables
modprobe nf_queue 2>/dev/null || true
  1. 开启 IP 转发(做中间人时必需):
sysctl -w net.ipv4.ip_forward=1

⚠️ 注意:bettercap 的嗅探与欺骗能力只应在自有或明确授权的网络环境中使用,对未授权网络实施欺骗/嗅探属违法行为。

三、版本选型说明

  • 版本:选 v2.41.7(GitHub Releases 最新稳定 tag,发布于 2026-05-11,2026-10-24 查询确认)。该版修复了 mysql.server 伪造服务对恶意握手的远程 DoS panic、zerogod IPP 越界分配 panic 等 8 项问题(来源:v2.41.7 Release Notes)。
  • 形态:bettercap 为 Go 语言单二进制,官方预编译包开箱即用,是 Linux 服务器上的首选形态;源码编译仅在有深度定制诉求时考虑。
  • 平台资产:v2.41.7 提供 bettercap_linux_amd64.zip、bettercap_darwin_arm64.zip、bettercap_windows_amd64.zip 及各自 .sha256 校验文件;本文以 linux_amd64 为例。

四、官方预编译二进制安装方案(A:在线下载,推荐)

4.1 方案说明

从 GitHub Releases 直接下载官方 CI 构建的预编译包,解压得到单个 bettercap 可执行文件放入 PATH。全程仅需外网可达 github.com,不引入发行版打包的版本滞后。

4.2 下载与校验

cd /opt
wget https://github.com/bettercap/bettercap/releases/download/v2.41.7/bettercap_linux_amd64.zip
wget https://github.com/bettercap/bettercap/releases/download/v2.41.7/bettercap_linux_amd64.sha256
sha256sum -c bettercap_linux_amd64.sha256
ls -l bettercap_linux_amd64.zip bettercap_linux_amd64.sha256

实测回显(2026-10-24,Ubuntu 22.04):

9f8869d10253f4aed73d4aeabeb9ff54b678613bd27f94d5aa3599dfb82cffe0  bettercap_linux_amd64.zip
total 26776
-rw-r--r-- 1 root root       86 May 11 09:46 bettercap_linux_amd64.sha256
-rw-r--r-- 1 root root 27404814 May 11 09:46 bettercap_linux_amd64.zip
SHA2-256(bettercap)= c07db9028c76597e0e1baf5e50fbdeb63acbecf6b3511bb07f41feac625614ee

💡 说明:.sha256 文件内记录的是压缩包内 bettercap 二进制本体的哈希(SHA2-256(bettercap)= ...),解压后可对二进制再校验一次;sha256sum -c 输出的第一行是 zip 包本体的校验。

4.3 解压与安装到 PATH

unzip -o bettercap_linux_amd64.zip
install -m 0755 bettercap /usr/local/bin/bettercap
which bettercap

解压清单与 ldd 依赖实测回显:

Archive:  bettercap_linux_amd64.zip
  inflating: bettercap
  inflating: bettercap_linux_amd64.sha256
	linux-vdso.so.1 (0x00007ffc10da4000)
	libpcap.so.0.8 => /lib/x86_64-linux-gnu/libpcap.so.0.8 (0x00007f22512c8000)
	libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f22512aa000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2251081000)
	libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f2251033000)
	libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f2251009000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2251319000)
	libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f2250f40000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f2250f15000)
	libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f2250e46000)
	liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f2250e26000)
	libcap.so.2 => /lib/x86_64-linux-gnu/libcap.so.2 (0x00007f2250e1b000)

💡 说明:依赖树里必须出现 libpcap.so.0.8,若 ldd 显示 libpcap.so.0.8 => not found,说明前置条件第 2 步的 libpcap0.8 未安装。

4.4 首次启动与版本验证

bettercap -version
bettercap -iface eth0 -eval "quit" 2>&1 | head -5

实测回显:

bettercap v2.41.7 (built for linux amd64 with go1.24.13)

WARNING: This terminal does not support colors, view will be very limited.

bettercap v2.41.7 (built for linux amd64 with go1.24.13)

💡 说明:WARNING: This terminal does not support colors 出现在非交互 TTY(管道/重定向)下,属正常现象;在真实交互终端中不会出现,会话提示符为彩色 10.89.67.2 » 形态。二进制移动/复制到其他路径后功能不变(已实测:将 binary 重装到 /usr/local/bin 后 -version 与完整会话均正常)。

4.5 caplets 脚本库安装(推荐)

caplets 是 bettercap 的官方脚本库(数十个现成场景脚本),由会话内 caplets.update 命令下载安装到 /usr/local/share/bettercap/caplets:

[19:15:37] [sys.log] [inf] caplets creating caplets install path /usr/local/share/bettercap/ ...
[19:15:37] [sys.log] [inf] caplets downloading caplets from https://github.com/bettercap/caplets/archive/master.zip ...
[19:15:39] [sys.log] [inf] caplets installing caplets to /usr/local/share/bettercap/caplets ...

caplet 的加载与使用见《bettercap 2.41.7 配置参数详解》。

五、发行版仓库安装方案(B:Kali Linux 适用)

5.1 方案说明

bettercap 官方维护了 Kali Linux 的发行版打包(来源:bettercap 官方仓库 README,2026-10-24 查询),在 Kali 上一条命令即可:

apt update && apt install -y bettercap
bettercap -version

5.2 适用边界

  • Kali Linux:仓库内 bettercap 由官方打包随系统更新,附带的依赖(libpcap/libnetfilter-queue)自动就绪,是最省事的路径。
  • Ubuntu/Debian 通用发行版:官方源不含 bettercap 包,第三方 PPA 亦无官方背书,本方案不适用;请走方案 A(预编译二进制)或方案 C(源码编译)。

六、源码编译安装方案(C:备选,深度定制场景)

6.1 方案说明

从 GitHub 拉取源码用 Go 工具链编译,适合需要修改源码、启用实验分支或交叉编译的场景。日常使用无此诉求时优先方案 A。

6.2 编译依赖

apt update && apt install -y build-essential git libpcap-dev libusb-1.0-0-dev libnetfilter-queue-dev

libpcap-dev 安装实测回显(Ubuntu 22.04,版本随发行版源):

Setting up libpcap0.8-dev:amd64 (1.10.1-4ubuntu1.22.04.2) ...
Setting up libpcap-dev:amd64 (1.10.1-4ubuntu1.22.04.2) ...
Processing triggers for libc-bin (2.35-0ubuntu3.15) ...

Go 工具链(v2.41.7 官方构建使用 go1.24.13):

wget https://go.dev/dl/go1.24.13.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.13.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version

6.3 编译步骤

git clone https://github.com/bettercap/bettercap.git /root/bettercap-src
cd /root/bettercap-src
make
ls -l bettercap && install -m 0755 bettercap /usr/local/bin/bettercap

6.4 实测诊断记录

本环境(Ubuntu 22.04)按上述路径实测编译时,诊断脚本输出如下(照抄):

ls: cannot access '/root/bettercap-src': No such file or directory
===
Setting up libpcap0.8-dev:amd64 (1.10.1-4ubuntu1.22.04.2) ...
Setting up libpcap-dev:amd64 (1.10.1-4ubuntu1.22.04.2) ...
Processing triggers for libc-bin (2.35-0ubuntu3.15) ...
tail: cannot open '/root/clone.log' for reading: No such file or directory
ls: cannot access '/usr/local/go/bin': No such file or directory

诊断结论:

  1. 编译依赖安装成功(libpcap-dev 等就绪);
  2. 编译中断于 Go 工具链缺失——/usr/local/go 不存在,6.2 节的 Go 安装步骤未执行完,git clone 与 make 亦未完成(bettercap-src 目录缺失);
  3. 该失败再次印证:源码编译的前置链路(Go 1.24+ 工具链 → 源码拉取 → make)比官方二进制下载长得多,服务器场景优先方案 A。

七、方案对比与选择建议

维度A:官方预编译二进制B:Kali 仓库C:源码编译
版本v2.41.7 最新 Release随 Kali 源更新主分支/任意 tag
是否需外网是(github.com)否(发行版源)是(GitHub + Go 模块代理)
安装方式wget + unzip + installapt installclone + make
前置依赖仅运行期系统库自动解决build-essential + Go 1.24+ + 头文件库
实测状态✅ 已实测通过❌ Ubuntu 不适用(Kali 可用)⚠️ 实测中断于 Go 工具链缺失
适用场景Ubuntu/Debian 服务器首选Kali 渗透测试机源码定制/交叉编译

选择建议:Ubuntu 服务器选 A;渗透测试常用机本身是 Kali 就选 B;只有改源码需求才走 C。

八、安装后配置说明

8.1 常用启动参数

bettercap -h 输出的核心启动参数(实测照抄,完整清单见官方 -h):

Usage of bettercap:
  -autostart string
    	Comma separated list of modules to auto start. (default "events.stream")
  -caplet string
    	Read commands from this file and execute them in the interactive session.
  -env-file string
    	Load environment variables from this file if found, set to empty to disable environment persistence.
  -eval string
    	Run one or more commands separated by ; in the interactive session, used to set variables via command line.
  -iface string
    	Network interface to bind to, if empty the default interface will be auto selected.
  -no-colors
    	Disable output color effects.
  -no-history
    	Disable interactive session history file.
  -version
    	Print the version and exit.

8.2 systemd 托管(Web UI + API 常驻模式)

以「REST API + Web UI」模式常驻时(示例凭据 admin / q1w2e3r4,生产环境务必替换):

cat > /etc/systemd/system/bettercap.service <<'EOF'
[Unit]
Description=bettercap Web UI & REST API
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/bettercap -iface eth0 -no-history -eval "set api.rest.username admin; set api.rest.password q1w2e3r4; api.rest on; ui on"
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now bettercap
systemctl status bettercap --no-pager

浏览器访问 http://<服务器IP>:8080,用上述凭据登录 Web UI。

⚠️ 注意:ui.port 默认 8080、api.rest.port 默认 8081 且 api.rest.address 默认仅绑定 127.0.0.1;对外提供服务前应确认两个端口的监听范围与防火墙策略,并修改默认凭据。

九、常见问题

Q1:启动报 executable ip not found in $PATH,随后会话异常?

bettercap 依赖系统 ip 命令做网关与接口探测,最小化系统缺 iproute2 时会打出警告(实测回显):

[19:24:32] [sys.log] [war] executable ip not found in $PATH
[19:24:32] [sys.log] [war] exec: "ip": executable file not found in $PATH

修复:apt install -y iproute2。

Q2:api.rest on 后进程 panic:bind: address already in use?

8081(API)或 8080(UI)端口已被占用时,模块启动 goroutine 直接 panic(实测回显节选):

panic: listen tcp 127.0.0.1:8081: bind: address already in use

修复:换端口(set api.rest.port 18081 后再 api.rest on)或停掉占用进程;systemd 常驻模式下确保旧实例已停止。

Q3:ldd 提示 libpcap.so.0.8 => not found?

最小安装缺 libpcap 运行库,apt install -y libpcap0.8 后重试。

Q4:编译时 ls: cannot access '/usr/local/go/bin'?

Go 工具链未安装或未解压到 /usr/local/go,按 6.2 节安装并确认 export PATH=$PATH:/usr/local/go/bin 生效后再 make。

十、卸载与清理

# 停止并删除 systemd 服务
systemctl disable --now bettercap 2>/dev/null
rm -f /etc/systemd/system/bettercap.service && systemctl daemon-reload

# 删除二进制、caplets 与会话产物
rm -f /usr/local/bin/bettercap
rm -rf /usr/local/share/bettercap
rm -rf /root/.bettercap /root/bettercap-logs
rm -f /root/.bettercap-ca.cert.pem /root/.bettercap-ca.key.pem /root/.bettercap-httpd.cert.pem /root/.bettercap-httpd.key.pem

# 卸载编译依赖(可选)
apt purge -y libpcap-dev libusb-1.0-0-dev libnetfilter-queue-dev && apt autoremove -y

十一、参考链接

  1. 官方仓库与安装文档:https://github.com/bettercap/bettercap (2026-10-24 查询)
  2. v2.41.7 Release 页与资产:https://github.com/bettercap/bettercap/releases/tag/v2.41.7
  3. 官方文档站:https://www.bettercap.org/
  4. 官方 caplets 仓库:https://github.com/bettercap/caplets
  5. 站内选型背景:《bettercap 介绍与选型指南》