通过 Safari 浏览器获取 UDID
演示一下效果,在手机上 Safari 浏览器访问 https://www.exchen.net/udid,然后点击获取 UDID,会提示安装描述文件,安装好描述文件之后,网站页面上就显示了 UDID。
一、编写 mobileconfig
首先你要准备好一个 Web 服务器,编写一个 udid.mobileconfig 文件,上传到 Web 服务器,比如 URL 地址是 https://www.exchen.net/udid/udid.mobileconfig,
具体文件内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PayloadContent</key> <dict> <key>URL</key> <string>http://www.exchen.net/udid/receive.php</string> <!--接收数据的地址--> <key>DeviceAttributes</key> <array> <string>UDID</string> <string>IMEI</string> <string>ICCID</string> <string>VERSION</string> <string>PRODUCT</string> </array> </dict> <key>PayloadOrganization</key> <string>www.exchen.net</string> <!--组织名称--> <key>PayloadDisplayName</key> <string>获取设备 UDID</string> <!--安装时显示的标题--> <key>PayloadVersion</key> <integer>1</integer> <key>PayloadUUID</key> <string>3C4DC7D2-E475-3375-489C-0BB8D737A653</string> <!--自己随机填写的唯一字符串--> <key>PayloadIdentifier</key> <string>net.exchen.profile-service</string> <key>PayloadDescription</key> <string>本文件仅用来获取设备 ID</string> <!--描述--> <key>PayloadType</key> <string>Profile Service</string> </dict> </plist> |
udid.mobileconfig 文件里得有一个用于接受数据的 URL 地址,当安装了描述文件之后,会将获取到 UDID、IMEI 等信息发送给这个 URL 地址,比如是: https://www.exchen.net/udid/receive.php
二、编写 receive.php
编写 receive.php 用于接受返回的数据,将返回的数据保存成文本文件,代码如下:
1 2 3 4 5 6 7 8 |
<?php $data = file_get_contents('php://input'); $myfile = fopen("udid.txt", "w") or die("Unable to open file!"); fwrite($myfile, $data); fclose($myfile); header('HTTP/1.1 301 Moved Permanently'); ?> |
三、安装描述文件
使用 Safari 访问 https://www.exchen.net/udid/udid.mobileconfig, 提示安装描述文件,如下图所示:
如果系统设置了密码,会提示输入密码,如下图所示:
输入密码安装成功之后系统会返回信息给 receive.php,在 web 服务器目录找到 udid.txt,看到是一个 plist 文件,里面的内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<plist version="1.0"> <dict> <key>IMEI</key> <string>35 836106 265805 3</string> <key>PRODUCT</key> <string>iPhone7,2</string> <key>UDID</key> <string>69bc34bfa2af70e6dfb5a3bcf9c2c015e9efd239</string> <key>VERSION</key> <string>14D27</string> </dict> </plist> |
通过解析这个 plist 文件就能得到 UDID、IMEI 等信息。
四、给 mobileconfig 签名
安装描述文件显示未签名,看的很不爽,使用 ProfileSigner 给 mobileconfig 进行签名,下载地址是: https://github.com/nmcspadden/ProfileSigner,
下载完成后输入命令:
1 2 |
./profile_signer.py -n "iPhone Distribution: de chen (QQ4RE63T4U)" sign udid.mobileconfig udidSign.mobileconfig |
将 udidSign.mobileconfig 上传到 web 服务器,访问 https://www.exchen.net/udid/udidSign.mobileconfig,提示安装描述文件就显示的是已验证,如下图所示: