自动化批量抓包配方
🤖 脚本化批量抓多个 App / 多次操作。
思路
r0capture 是命令行工具,易嵌入自动化脚本。配合 adb 自动化操作 App。
示例:批量抓多个 App
bash
#!/bin/bash
APPS=("com.app1" "com.app2" "com.app3")
for app in "${APPS[@]}"; do
adb shell am force-stop $app
timeout 60 python3 r0capture.py -U -f $app -v -p ${app}.pcap &
sleep 5
# adb 自动操作 App 触发请求
adb shell input tap 500 800
sleep 30
kill %1 2>/dev/null
done示例:配合 monkey 触发流量
bash
# 后台抓包
python3 r0capture.py -U com.app -v -p out.pcap &
PID=$!
# monkey 随机点击触发各种请求
adb shell monkey -p com.app 500
# 停止抓包
kill -INT $PID注意
- r0capture 用
sys.stdin.read()阻塞,后台运行需用kill -INT优雅退出(触发 stoplog flush pcap) - 多 App 分别输出不同 pcap(文件名带进程名+时间戳)
timeout防止卡死