无法使用Node连接到iOS模拟器中的Mobile Safari

我试图在远程debugging(使用Node)时模拟Safari和Mobile Safari之间的消息交换。

我嗅了两人之间的交通。 他们正在通过TCP交换二进制plists。 我已经设法复制数据包,直到select一个特定的选项卡进行debugging(“套接字设置”),但在这之后,Mobile Safari忽略了我的plist指令,而是发回了一个列表。

以下是Safari发送的套接字设置数据包的原始tcpdump,以及它包含的plist的JSON表示:

10:36:42.318662 IP6 localhost.58028 > localhost.27753: Flags [P.], seq 1601:1930, ack 803, win 9125, options [nop,nop,TS val 69074378 ecr 69074378], length 329 0x0000: 6000 0000 0169 0640 0000 0000 0000 0000 `....i.@........ 0x0010: 0000 0000 0000 0001 0000 0000 0000 0000 ................ 0x0020: 0000 0000 0000 0001 e2ac 6c69 344e 2443 ..........li4N$C 0x0030: 4e32 497b 8018 23a5 0171 0000 0101 080a N2I{..#..q...... 0x0040: 041d fdca 041d fdca 6270 6c69 7374 3030 ........bplist00 0x0050: d201 0203 0c5a 5f5f 6172 6775 6d65 6e74 .....Z__argument 0x0060: 5a5f 5f73 656c 6563 746f 72d4 0405 0607 Z__selector..... 0x0070: 0809 0a0b 5f10 1b57 4952 4170 706c 6963 ...._..WIRApplic 0x0080: 6174 696f 6e49 6465 6e74 6966 6965 724b ationIdentifierK 0x0090: 6579 5f10 1a57 4952 436f 6e6e 6563 7469 ey_..WIRConnecti 0x00a0: 6f6e 4964 656e 7469 6669 6572 4b65 795c onIdentifierKey\ 0x00b0: 5749 5253 656e 6465 724b 6579 5f10 1457 WIRSenderKey_..W 0x00c0: 4952 5061 6765 4964 656e 7469 6669 6572 IRPageIdentifier 0x00d0: 4b65 795f 1016 636f 6d2e 6170 706c 652e Key_..com.apple. 0x00e0: 6d6f 6269 6c65 7361 6661 7269 5f10 2441 mobilesafari_.$A 0x00f0: 3535 3134 3645 372d 3244 4544 2d34 3832 55146E7-2DED-482 0x0100: 412d 3839 3133 2d31 3033 3337 4537 4634 A-8913-10337E7F4 0x0110: 3330 465f 1024 3230 3041 3935 3146 2d30 30F_.$200A951F-0 0x0120: 3839 432d 3445 3741 2d41 3642 322d 3331 89C-4E7A-A6B2-31 0x0130: 4235 4432 3737 4341 3635 1001 5f10 185f B5D277CA65.._.._ 0x0140: 7270 635f 666f 7277 6172 6453 6f63 6b65 rpc_forwardSocke 0x0150: 7453 6574 7570 3a00 0800 0d00 1800 2300 tSetup:.......#. 0x0160: 2c00 4a00 6700 7400 8b00 a400 cb00 f200 ,.Jgt........ 0x0170: f400 0000 0000 0002 0100 0000 0000 0000 ................ 0x0180: 0d00 0000 0000 0000 0000 0000 0000 0001 ................ 0x0190: 0f . { __argument: { WIRApplicationIdentifierKey: 'com.apple.mobilesafari', WIRConnectionIdentifierKey: 'A55146E7-2DED-482A-8913-10337E7F430F', WIRSenderKey: '200A951F-089C-4E7A-A6B2-31B5D277CA65', WIRPageIdentifierKey: 1 }, __selector: '_rpc_forwardSocketSetup:' } 

而我用JSON plist发送的内容是:

 16:39:18.669088 IP6 localhost.63836 > localhost.27753: Flags [P.], seq 413:742, ack 1, win 9175, options [nop,nop,TS val 89654016 ecr 89654016], length 329 0x0000: 6000 0000 0169 0640 0000 0000 0000 0000 `....i.@........ 0x0010: 0000 0000 0000 0001 0000 0000 0000 0000 ................ 0x0020: 0000 0000 0000 0001 f95c 6c69 0226 fab5 .........\li.&.. 0x0030: 6fff d8d3 8018 23d7 0171 0000 0101 080a o.....#..q...... 0x0040: 0558 0300 0558 0300 6270 6c69 7374 3030 .X...X..bplist00 0x0050: d201 0203 0c5a 5f5f 6172 6775 6d65 6e74 .....Z__argument 0x0060: 5a5f 5f73 656c 6563 746f 72d4 0405 0607 Z__selector..... 0x0070: 0809 0a0b 5f10 1b57 4952 4170 706c 6963 ...._..WIRApplic 0x0080: 6174 696f 6e49 6465 6e74 6966 6965 724b ationIdentifierK 0x0090: 6579 5f10 1a57 4952 436f 6e6e 6563 7469 ey_..WIRConnecti 0x00a0: 6f6e 4964 656e 7469 6669 6572 4b65 795c onIdentifierKey\ 0x00b0: 5749 5253 656e 6465 724b 6579 5f10 1457 WIRSenderKey_..W 0x00c0: 4952 5061 6765 4964 656e 7469 6669 6572 IRPageIdentifier 0x00d0: 4b65 795f 1016 636f 6d2e 6170 706c 652e Key_..com.apple. 0x00e0: 6d6f 6269 6c65 7361 6661 7269 5f10 2465 mobilesafari_.$E 0x00f0: 3962 6431 6564 312d 6164 3161 2d34 6266 9BD1ED1-AD1A-4BF 0x0100: 302d 6238 3066 2d61 3331 3136 3962 6434 0-B80F-A31169BD4 0x0110: 3431 315f 1024 6630 3538 6663 3761 2d63 411_.$F058FC7A-C 0x0120: 6232 332d 3465 3339 2d61 6535 312d 3734 B23-4E39-AE51-74 0x0130: 6363 3730 6333 6262 3033 1001 5f10 185f CC70C3BB03.._.._ 0x0140: 7270 635f 666f 7277 6172 6453 6f63 6b65 rpc_forwardSocke 0x0150: 7453 6574 7570 3a00 0800 0d00 1800 2300 tSetup:.......#. 0x0160: 2c00 4a00 6700 7400 8b00 a400 cb00 f200 ,.Jgt........ 0x0170: f400 0000 0000 0002 0100 0000 0000 0000 ................ 0x0180: 0d00 0000 0000 0000 0000 0000 0000 0001 ................ 0x0190: 0f . { __argument: { WIRApplicationIdentifierKey: 'com.apple.mobilesafari', WIRConnectionIdentifierKey: 'E9BD1ED1-AD1A-4BF0-B80F-A31169BD4411', WIRSenderKey: 'F058FC7A-CB23-4E39-AE51-74CC70C3BB03', WIRPageIdentifierKey: 1 }, __selector: '_rpc_forwardSocketSetup:' } 

除了钥匙(从我的实验来看,这似乎没有什么区别 – 我尝试过Safari无法使用的钥匙),这两个钥匙是字节对字节相同的,并且产生相同的plists。 我可以比较Safari和移动Safari和我的代码和移动Safari并排的stream量,他们只是在这一点上分歧。

我不知道问题是什么,但是我可以看到有几个可能性:

  • 包是不一样的,我拼写错了/别的东西了
  • 密钥不正确(也许发件人密钥需要从连接ID密钥生成)
  • 有两个在其他地方传递的数据

只是为了清理我调查过的一些途径:

  • 这不是时间敏感(另一个项目 – 不是我的 – 可以成功连接,但一次发送所有连接数据包)
  • 我检查了是否有(tcp)数据通过另一个端口传递 – 没有我可以告诉

有什么可能出错? 为什么移动Safari拒绝我的连接?

该项目在Github上 。

问题是第36行:

 data.__argument.WIRSocketDataKey = JSON.stringify(data.__argument.WIRSocketDataKey); 

bplistCreator.jsWIRSocketDataKey视为一个string,当它实际上是bplist条款中的数据时。

第36行应该是:

 data.__argument.WIRSocketDataKey = new Buffer(JSON.stringify(data.__argument.WIRSocketDataKey)); 

为了这个工作,从GH的bplistCreator.js的版本是必需的,因为数据支持的版本似乎不可以通过npm https://github.com/nearinfinity/node-bplist-creator


以下只保留历史logging仅供参考:

在执行过程中做了更多的挖掘和观察system.log

tail -f /var/log/system.log

当浏览器崩溃时,我会看到以下内容

 -[__NSCFString bytes]: unrecognized selector sent to instance 0xa947af0 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString bytes]: unrecognized selector sent to instance 0xa947af0' *** First throw call stack: (0x48b012 0x1578e7e 0x5164bd 0x47abbc 0x47a94e 0x413390 0x43b763 0xb55415 0x44bf0f5 0x45080d8 0x45085f1 0x3557548 0x40ef3f 0x40e96f 0x431734 0x430f44 0x430e1b 0x3556c50 0x9026e557 0x90258cee) com.apple.launchd.peruser.501[237] (UIKitApplication:com.apple.mobilesafari[0x10ee][59604]): Job appears to have crashed: Abort trap: 6 backboardd[54902]: Application 'UIKitApplication:com.apple.mobilesafari[0x10ee]' exited abnormally with signal 6: Abort trap: 6 ReportCrash[59611]: Saved crash report for MobileSafari[59604] version 1659.13 to /Users/xx/Library/Logs/DiagnosticReports/MobileSafari_2013-01-29-212042_Andy-Daviess-MacBook-Pro.crash 

(我已经从上面删除了时间和date)

编辑:

我认为问题是WIRSocketDataKey是作为一个string发送时,它应该是数据

看起来不像node-bplist-creator目前支持数据types,所以这是我们需要修复的第一件事情。

编辑2:

GH版本的node-bplist-creater支持数据types,但似乎没有打包(???)

编辑3:

明天工作会给你一个拉请求!