IOS システムにおける mobileconfig の機能、mobileconfig ファイルの使用方法、および Apple のスーパー シグネチャの実装

.mobileconfig は Apple システム構成記述ファイルであり、現在デバイスの UDID を取得するために Apple のスーパーサインで一般的に使用されています。

公式紹介:

構成プロファイルは、デバイス セキュリティ ポリシー、VPN 構成情報、Wi-Fi 設定、APN 設定、Exchange アカウント設定、メール設定、iPhone および iPod touch がエンタープライズ システムと連携できるようにする証明書が含まれる XML ファイルです。

「iPhone 構成ユーティリティ」を使用すると、構成プロファイルの作成、保守、インストール、構成プロファイルの暗号化、事前構成プロファイルと許可されたアプリケーションの追跡とインストール、コンソール ログを含むデバイス情報の収集が簡単に行えます。(このツールは公式サイトからダウンロードできます)

私たちが知る限り、この構成ファイルをインストールするための上記の「iPhone 構成ユーティリティ」に加えて、電子メールの添付ファイルを通じて、または Safari を使用してダウンロードを含む Web ページを参照することによってインストールをアクティブ化することもできます (インストール プロファイル ウィンドウ)。

1. コード例

<?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>
    <array>
        <dict>
            <key>PayloadDisplayName</key>
            <string>LDAP Settings</string>
            <key>PayloadType</key>
            <string>com.apple.ldap.account</string>
            <key>PayloadVersion</key>
            <integer>1</integer>
            <key>PayloadUUID</key>
            <string>6df7a612-ce0a-4b4b-bce2-7b844e3c9df0</string>
            <key>PayloadIdentifier</key>
            <string>com.example.iPhone.settings.ldap</string>
            <key>LDAPAccountDescription</key>
            <string>Company Contacts</string>
            <key>LDAPAccountHostName</key>
            <string>ldap.example.com</string>
            <key>LDAPAccountUseSSL</key>
            <false />
            <key>LDAPAccountUserName</key>
            <string>uid=username,dc=example,dc=com</string>
            <key>LDAPSearchSettings</key>
            <array>
                <dict>
                    <key>LDAPSearchSettingDescription</key>
                    <string>Company Contacts</string>
                    <key>LDAPSearchSettingSearchBase</key>
                    <string></string>
                    <key>LDAPSearchSettingScope</key>
                    <string>LDAPSearchSettingScopeSubtree</string>
                </dict>
                <dict>
                    <key>LDAPSearchSettingDescription</key>
                    <string>Sales Departments</string>
                    <key>LDAPSearchSettingSearchBase</key>
                    <string>ou=Sales,dc=example,dc=com</string>
                    <key>LDAPSearchSettingScope</key>
                    <string>LDAPSearchSettingScopeSubtree</string>
                </dict>
            </array>
        </dict>
        <dict>
            <key>PayloadDisplayName</key>
            <string>Email Settings</string>
            <key>PayloadType</key>
            <string>com.apple.mail.managed</string>
            <key>PayloadVersion</key>
            <integer>1</integer>
            <key>PayloadUUID</key>
            <string>362e5c11-a332-4dfb-b18b-f6f0aac032fd</string>
            <key>PayloadIdentifier</key>
            <string>com.example.iPhone.settings.email</string>
            <key>EmailAccountDescription</key>
            <string>Company E-mail</string>
            <key>EmailAccountName</key>
            <string>Full Name</string>
            <key>EmailAccountType</key>
            <string>EmailTypeIMAP</string>
            <key>EmailAddress</key>
            <string>[email protected]</string>
            <key>IncomingMailServerAuthentication</key>
            <string>EmailAuthPassword</string>
            <key>IncomingMailServerHostName</key>
            <string>imap.example.com</string>
            <key>IncomingMailServerUseSSL</key>
            <true />
            <key>IncomingMailServerUsername</key>
            <string>[email protected]</string>
            <key>OutgoingPasswordSameAsIncomingPassword</key>
            <true />
            <key>OutgoingMailServerAuthentication</key>
            <string>EmailAuthPassword</string>
            <key>OutgoingMailServerHostName</key>
            <string>smtp.example.com</string>
            <key>OutgoingMailServerUseSSL</key>
            <true />
            <key>OutgoingMailServerUsername</key>
            <string>[email protected]</string>
        </dict>
    </array>
    <key>PayloadOrganization</key>
    <string>Your Organization's Name</string>
    <key>PayloadDisplayName</key>
    <string>Organization iPhone Settings</string>
    <key>PayloadVersion</key>
    <integer>1</integer>
    <key>PayloadUUID</key>
    <string>954e6e8b-5489-484c-9b1d-0c9b7bf18e32</string>
    <key>PayloadIdentifier</key>
    <string>com.example.iPhone.settings</string>
    <key>PayloadDescription</key>
    <string>Sets up Organization's LDAP directories and email on the iPhone</string>
    <key>PayloadType</key>
    <string>Configuration</string>
</dict>
</plist>

2. スーパーサインを使用した UDID 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>http://127.0.0.1/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>com.sssss.orgName</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>dev.skyfox.profile-service</string>
     <key>PayloadDescription</key>
     <string>获取设备UDID</string>   <!--描述-->
     <key>PayloadType</key>
     <string>Profile Service</string>
 </dict>
</plist>

3. PHPサーバーがreceive.phpを受信します。

$data = file_get_contents('php://input');
$plistBegin     = '<?xml version="1.0"';
$plistEnd       = '</plist>';
$data2          = substr($data, strpos($data, $plistBegin), strpos($data, $plistEnd) - strpos($data, $plistBegin));
$xml            = xml_parser_create();
$UDID           = "";
$CHALLENGE      = "";
$DEVICE_NAME    = "";
$DEVICE_PRODUCT = "";
$DEVICE_VERSION = "";
$iterator       = 0;
$arrayCleaned   = array();
$data           = "";
xml_parse_into_struct($xml, $data2, $vs);
xml_parser_free($xml);
foreach ($vs as $v) {
    if ($v['level'] == 3 && $v['type'] == 'complete') {
                $arrayCleaned[] = $v;
     }
} 
foreach ($arrayCleaned as $elem) {
            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++;
}
header('HTTP/1.1 301 Moved Permanently');  //这⾥⼀定要301跳转,否则设备安装会提⽰"⽆效的描述⽂件"
$url = "127.0.0.1/udid.php?udid=".$UDID."&version='.$DEVICE_VERSION.'&device_name='.$DEVICE_PRODUCT;
header("Location: ".$url);

4. PHPサーバー情報処理 udid.php

$UDID =  $_GET['UDID'];
$version =  $_GET['version'];
$device_name =  $_GET['device_name'];

おすすめ

転載: blog.csdn.net/qq_24138677/article/details/128546025