ios 超级签名 如何获取 ios 设备的 uuid

作者: cayman 分类: 加密签名,源码分享,编程技术 发布时间: 2020-03-25 00:11

苹果允许通过描述文件获取 获取用户的uuid

uuid.mobileconfig 描述文件格式为

<?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>你的域名</string>
            <key>DeviceAttributes</key>
            <array>
                <string>UDID</string>
                <string>IMEI</string>
                <string>ICCID</string>
                <string>VERSION</string>
                <string>PRODUCT</string>
                <string>DEVICE_NAME</string>
            </array>
        </dict>
        <key>PayloadOrganization</key>
        <string>dev.szwyll.com</string>
        <key>PayloadDisplayName</key>
        <string>应用安装</string>
        <key>PayloadVersion</key>
        <integer>1</integer>
        <key>PayloadUUID</key>
        <string>'.uuid().'</string>
        <key>PayloadIdentifier</key>
        <string>dev.szwyll.profile-service</string>
        <key>PayloadDescription</key>
        <string>本文件仅用来获取设备ID</string>
        <key>PayloadType</key>
        <string>Profile Service</string>
    </dict>
</plist>

这里面有个坑 就是上面URL那里发送地址 需要https 现在免费证书一大片 自己创建一个放在上面就可以了

使用php 编写生成代码

一、 生成描述文件代码

<?php
header('Content-type: application/x-apple-aspen-config; chatset=utf-8');
        header('Content-Disposition: attachment; filename="company.mobileconfig"');

        $url = '你的域名';//包名
        $xml = '<?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>'.$url.'</string>
            <key>DeviceAttributes</key>
            <array>
                <string>UDID</string>
                <string>IMEI</string>
                <string>ICCID</string>
                <string>VERSION</string>
                <string>PRODUCT</string>
                <string>DEVICE_NAME</string>
            </array>
        </dict>
        <key>PayloadOrganization</key>
        <string>dev.szwyll.com</string>
        <key>PayloadDisplayName</key>
        <string>应用安装</string>
        <key>PayloadVersion</key>
        <integer>1</integer>
        <key>PayloadUUID</key>
        <string>'.uuid().'</string>
        <key>PayloadIdentifier</key>
        <string>dev.szwyll.profile-service</string>
        <key>PayloadDescription</key>
        <string>本文件仅用来获取设备ID</string>
        <key>PayloadType</key>
        <string>Profile Service</string>
    </dict>
</plist>';
        echo $xml;die();
    

二、接收文件就是上面url填的地址

<?
       $data = file_get_contents('php://input');
        $plistBegin   = '<?xml version="1.0"';
        $plistEnd   = '</plist>';
        $pos1 = strpos($data, $plistBegin);
        $pos2 = strpos($data, $plistEnd);
        $data2 = substr ($data,$pos1,$pos2-$pos1);
        $xml = xml_parser_create();
        xml_parse_into_struct($xml, $data2, $vs);
        xml_parser_free($xml);

        $UDID = "";

        $CHALLENGE = "";

        $DEVICE_NAME = "";

        $DEVICE_PRODUCT = "";

        $DEVICE_VERSION = "";

        $iterator = 0;

        $arrayCleaned = array();
        foreach($vs as $v){
            if($v['level'] == 3 && $v['type'] == 'complete'){

                $arrayCleaned[]= $v;

            }
            $iterator++;

        }

        $data = "";
        $iterator = 0;

        foreach($arrayCleaned as $elem){

            $data .= "\n==".$elem['tag']." -> ".$elem['value']."<br/>";

            switch ($elem['value']) {

                case "CHALLENGE":

                    $CHALLENGE = $arrayCleaned[$iterator+1]['value'];

                    break;

                case "DEVICE_NAME":

                    $DEVICE_NAME = $arrayCleaned[$iterator+1]['value'];

                    break;

                case "PRODUCT":

                    $DEVICE_PRODUCT = $arrayCleaned[$iterator+1]['value'];

                    break;

                case "UDID":

                    $UDID = $arrayCleaned[$iterator+1]['value'];

                    break;

                case "VERSION":

                    $DEVICE_VERSION = $arrayCleaned[$iterator+1]['value'];

                    break;

            }
            $iterator++;

        }
        $params = "UDID=".$UDID."&CHALLENGE=".$CHALLENGE."&DEVICE_NAME=".$DEVICE_NAME."&DEVICE_PR ODUCT=".$DEVICE_PRODUCT."&DEVICE_VERSION=".$DEVICE_VERSION;

        header('HTTP/1.1 301 Moved Permanently');
        header("Location:".回调地址.'?'.$params);
        die();

三、在回调地址上接收 get数据 就可以了 包含 设备的 UUID 设备版本 设备型号

<?php
$params = $_GET;

var_dumo($params); #打印出接收数据  可以进行数据库写入操作

发表评论

电子邮件地址不会被公开。 必填项已用*标注