IOS怎么抓取网络请求包

好吧,苹果提供了命令行监控的方法,将iPhone连接到Mac电脑的USB,输入特定命令来监听iPhone的所有网络请求。 

请求的内容会写入到一个文件,读取该文件即可获取所有网络请求。 

而该文件需要特定工具才能打开,用WireShark,它再次派上了用场。

——————监控网络请求的步骤—————– 

1.将iPhone连接到Mac电脑 

2.从Xcode或者iTunes获得iPhone的UUID,一串32位的标示,类似0B6814B3-EB2F-5B85-929D-7C5C5SS8DB64 

3.命令行输入rvictl -s [你的手机UUID标示],打开Mac监听 

4.命令行输入sudo tcpdump -i rv0 -n -s 0 -w dumpFile.pcap tcp,开始向文件写入监控数据

结束监听时,ctrl+c关闭tcpdump进程。 

关闭Mac监听,命令是 rvictl -v [你的手机UUID标示]

——————步骤结束———————–

以下是苹果官方文档

iOS Packet Tracing

iOS does not support packet tracing directly. However, if you’re developing for iOS you can take a packet trace of your app in a number of different ways:

If the problem you’re trying to debug occurs on Wi-Fi, you can put your iOS device on a test Wi-Fi network. See Wi-Fi Capture for details. 

If your app uses HTTP, you can configure your iOS device to use a debugging HTTP proxy (such as Charles HTTP Proxy). 

In iOS 5 and later you can use the remote virtual interface facility. 

Remote Virtual Interface 

iOS 5 added a remote virtual interface (RVI) facility that lets you use OS X packet trace programs to capture traces from an iOS device. The basic strategy is:

Connect your iOS device to your Mac via USB. 

Set up an RVI for that device. This creates a virtual network interface on your Mac that represents the iOS device’s networking stack. 

Run your OS X packet trace program, and point it at the RVI created in the previous step. 

To set up an RVI, you should run the rvictl tool as shown below.

# First get the current list of interfaces.# First get the current list of interfaces. ifconfig -l 

lo0 gif0 stf0 en0 en1 p2p0 fw0 ppp0 utun0 

# Then run the tool with the UDID of the device.# Then run the tool with the UDID of the device. rvictl -s 74bd53c647548234ddcef0ee3abee616005051ed

Starting device 74bd53c647548234ddcef0ee3abee616005051ed [SUCCEEDED]

# Get the list of interfaces again, and you can see the new virtual# Get the list of interfaces again, and you can see the new virtual # network interface, rvi0, added by the previous command. 

$ ifconfig -l 

lo0 gif0 stf0 en0 en1 p2p0 fw0 ppp0 utun0 rvi0 

Now that you know the name of the RVI, you can point your packet trace tool at it. For example, here’s how you might run tcpdump to take a packet trace from the RVI and write it to the file trace.pcap.

$ sudo tcpdump -i rvi0 -w trace.pcap 

tcpdump: WARNING: rvi0: That device doesn’t support promiscuous mode 

(BIOCPROMISC: Operation not supported on socket) 

tcpdump: WARNING: rvi0: no IPv4 address assigned 

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 

listening on rvi0, link-type RAW (Raw IP), capture size 65535 bytes 

When you’re done you can remove the RVI with the following command.

$ rvictl -x 74bd53c647548234ddcef0ee3abee616005051ed

Stopping device 74bd53c647548234ddcef0ee3abee616005051ed [SUCCEEDED] 

Important: The RVI represents the entire networking stack of the iOS device; there’s no way to trace a specific interface on the device, or even learn which packets were transferred on which interface.

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 175,490评论 5 419
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 74,060评论 2 335
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 124,407评论 0 291
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 47,741评论 0 248
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 56,543评论 3 329
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 43,040评论 1 246
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 34,107评论 3 358
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 32,646评论 0 229
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 36,694评论 1 271
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 32,398评论 2 279
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 33,987评论 1 288
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 30,097评论 3 285
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 35,298评论 3 282
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 27,278评论 0 14
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 28,413评论 1 232
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 38,397评论 2 309
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 38,099评论 2 314

推荐阅读更多精彩内容