用RVI方法,对iOS进行抓包

本文介绍了一种使用RVI方法在Mac上对iOS设备进行抓包的过程。首先通过rvictl工具创建远程虚拟接口,然后利用tcpdump抓取数据包,并最终借助tcprewrite工具将数据转换成可视化工具可读的格式。

用RVI方法,对iOS进行抓包

一、创建远程虚拟接口Remote Virtual Interface(RVI)

该方法适用于iOS 5.0以上设备,需要Mac并且安装Xcode。

1.将iOS设备通过USB连接到Mac上;

2.通过iTools等工具获取iOS设备的UDID;

3.打开终端terminal,建立RVI:

<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#获取当前的接口列表</span>
$ ifconfig <span class="hljs-operator" style="box-sizing: border-box;">-l</span>
lo0 gif0 stf0 en0 en1 en2 bridge0 p2p0 awdl0
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#然后以设备的UDID运行工具</span>
$ rvictl <span class="hljs-operator" style="box-sizing: border-box;">-s</span> UDID
Starting device UDID [SUCCEEDED] with interface rvi0 
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#再次获取接口列表,会看到有新的虚拟接口rvi0</span>
$ ifconfig <span class="hljs-operator" style="box-sizing: border-box;">-l</span>
lo0 gif0 stf0 en0 en1 en2 bridge0 p2p0 awdl0 rvi0</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li></ul>

rvi0就是Remote Virtual Interface,意味着在Mac上虚拟了一个iOS设备接口rvi0。

二、通过tcpdump抓包

1.运行tcpdump:

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ sudo tcpdump <span class="hljs-attribute" style="box-sizing: border-box;">-i</span> rvi0 <span class="hljs-attribute" style="box-sizing: border-box;">-w</span> dump<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>pcap</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

参量的意义:-i rvi0 选择需要抓取的接口为rvi0(远程虚拟接口) 
-w dump.pcap 设置保存的文件名称;

2.在iOS设备的App上进行操作;

3.结束操作之后,在terminal上ctrl+c终止tcpdump;

4.这个时候可以删除RVI:

<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>rvictl -x <span class="hljs-constant" style="box-sizing: border-box;">UDID</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

三、处理tcpdump的抓包数据

使用tcprewrite将tcpdump抓包后的数据转换为可视化抓包工具可以解析的数据 
1.通过HomeBrew安装tcprewrite:

<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>brew install tcpreplay</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

2.将原始数据包转换为以太网数据包 
tcprewrite重写第二层以太网层:

<code class="hljs brainfuck has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">$</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">tcprewrite</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">dlt=enet</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">enet</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">dmac=00:11:22:33:44:55</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">enet</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">smac=66:77:88:99:AA:BB</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">infile=dump</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">pcap</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">outfile=dumpFileFinal</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">pcap</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

或者tcprewrite重写第四层TCP、UDP层:

<code class="hljs brainfuck has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">$</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">tcprewrite</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">portmap=80:8080</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">,</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">22:8022</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">infile=dump</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">pcap</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">outfile=dumpFileFinal</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">pcap</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

3.用可视化抓包工具打开dumpFileFinal.pcap文件,比如Charles。然后就可以进行包分析、查看统计流量等等。

根据原作 https://pan.quark.cn/s/459657bcfd45 的源码改编 Classic-ML-Methods-Algo 引言 建立这个项目,是为了梳理和总结传统机器学习(Machine Learning)方法(methods)或者算法(algo),和各位同仁相互学习交流. 现在的深度学习本质上来自于传统的神经网络模型,很大程度上是传统机器学习的延续,同时也在不少时候需要结合传统方法来实现. 任何机器学习方法基本的流程结构都是通用的;使用的评价方法也基本通用;使用的一些数学知识也是通用的. 本文在梳理传统机器学习方法算法的同时也会顺便补充这些流程,数学上的知识以供参考. 机器学习 机器学习是人工智能(Artificial Intelligence)的一个分支,也是实现人工智能最重要的手段.区别于传统的基于规则(rule-based)的算法,机器学习可以从数据中获取知识,从而实现规定的任务[Ian Goodfellow and Yoshua Bengio and Aaron Courville的Deep Learning].这些知识可以分为四种: 总结(summarization) 预测(prediction) 估计(estimation) 假想验证(hypothesis testing) 机器学习主要关心的是预测[Varian在Big Data : New Tricks for Econometrics],预测的可以是连续性的输出变量,分类,聚类或者物品之间的有趣关联. 机器学习分类 根据数据配置(setting,是否有标签,可以是连续的也可以是离散的)和任务目标,我们可以将机器学习方法分为四种: 无监督(unsupervised) 训练数据没有给定...
<think> 我们正在解决用户的问题:使用Wireshark抓包获取UUID的方法 引用[1]提到:使用Wireshark捕获手机上的数据包时,需要配置RVI虚拟网络接口,并且虚拟接口的创建必须关联手机UUID。但这里并没有直接说明如何获取UUID。 实际上,UUID是指iOS设备的唯一标识符(对于Android设备,通常不需要UUID)。因此,我们需要获取iOS设备的UUID来创建RVI接口。 步骤: 1. 获取iOS设备的UUID(唯一设备标识符) 2. 使用该UUID创建虚拟网络接口 3. 使用Wireshark在该虚拟接口上抓包 如何获取UUID? 方法1:通过Xcode获取 - 将iOS设备连接到Mac电脑 - 打开Xcode,选择菜单Window -> Devices and Simulators - 在Devices选项卡中,选择已连接的设备,在设备信息中可以看到Identifier,这就是UUID(通常是一串由数字和字母组成的40个字符的字符串,例如:00008020-000A0C9A0140002E) 方法2:通过iTunes获取(旧版iTunes支持,新版可能已移除) - 连接设备到电脑,打开iTunes - 点击设备图标,在摘要页面中连续点击序列号,会显示UUID(但新版本iTunes可能不再显示) 方法3:通过命令行获取(需要安装libimobiledevice工具) - 在Mac上安装libimobiledevice:`brew install libimobiledevice` - 使用命令:`idevice_id -l` 列出所有连接设备的UUID 注意:Android设备不需要UUID,通常通过设置网络代理或者使用USB网络共享(tethering)的方式抓包。 创建虚拟接口并抓包: 1. 获取到UUID后,使用命令行创建虚拟接口(例如rvi0): ```bash rvictl -s <UUID> ``` 执行后,系统会创建一个虚拟网络接口(如rvi0)。 2. 启动Wireshark,选择该虚拟接口(rvi0)开始抓包。 3. 抓包完成后,关闭虚拟接口: ```bash rvictl -x <UUID> ``` 注意:引用[1]中还提到,手机必须通过数据线连接电脑,并且手机和电脑在同一个WiFi网络下(实际上,使用RVI方式并不要求WiFi,因为数据是通过USB传输的,但要求手机通过数据线连接电脑)。 另外,引用[2]和[3]是关于Wireshark抓包的一般操作,与获取UUID无直接关系。 因此,总结获取UUID的方法主要是通过Xcode或者命令行工具(idevice_id)。 相关问题: 1. 如何通过命令行获取iOS设备的UUID? 2. Android设备使用Wireshark抓包需要UUID吗? 3. 使用RVI虚拟接口抓包有什么限制? </think> ### 使用Wireshark获取设备UUID的方法 UUID(通用唯一标识符)是设备的唯一识别码,在抓包场景中通常用于关联特定设备。以下是详细操作流程: --- #### 一、获取设备UUID的核心步骤 1. **连接设备** - 将iOS设备通过数据线连接至Mac电脑(**必须满足条件**)[^1] - 确保设备与电脑在**同一WiFi网络**下[^1] 2. **通过Xcode查询UUID** ```mermaid graph LR A[打开Xcode] --> B[Window → Devices] B --> C[选择目标设备] C --> D[复制Identifier字段] ``` - 在设备信息中,"Identifier"即为40位字符的UUID(如`00008020-001A643402E2002E`) 3. **命令行验证UUID** ```bash idevice_id -l # 列出所有连接设备的UUID ``` - 需提前安装`libimobiledevice`: ```bash brew install libimobiledevice ``` --- #### 二、配置Wireshark抓包环境 1. **创建虚拟接口** 使用获取的UUID创建虚拟网络接口`rvi0`: ```bash rvictl -s <UUID> # 示例:rvictl -s 00008020-001A643402E2002E ``` - 成功提示:`Starting device <UUID> [SUCCEEDED] with interface rvi0` 2. **启动Wireshark捕获** - 在Wireshark中选择`rvi0`接口 - 使用过滤规则聚焦目标流量: ```bash http # 仅HTTP流量 ip.addr == 192.168.1.100 # 按设备IP过滤 ``` 3. **捕获设备流量** - 在设备上执行目标操作(如访问网页/使用APP) - 停止捕获后保存为`.pcap`文件分析 --- #### 三、关键注意事项 1. **必需条件** - 仅支持iOS设备(Android无需此步骤) - 必须通过数据线连接电脑[^1] - Mac系统需安装Xcode命令行工具 2. **常见问题处理** | 错误提示 | 解决方案 | |---------------------------|------------------------------| | `rvictl: command not found` | 安装Xcode命令行工具:`xcode-select --install` | | `No device found` | 检查USB连接或重启`usbmuxd`服务 | --- #### 四、应用案例 通过UUID关联设备分析抖音流量: 1. 创建虚拟接口`rvi0`捕获加密流量 2. 使用过滤规则: ```bash quic # QUIC协议分析 http.request.uri contains "aweme" # 聚焦抖音API[^3] ``` 3. 导出特定请求的UUID关联数据: ```bash tshark -r capture.pcap -Y "http" -T fields -e ip.src -e http.user_agent ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值