-
Notifications
You must be signed in to change notification settings - Fork 26
/
albert.apple.php
302 lines (272 loc) · 16.3 KB
/
albert.apple.php
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?php
/*
PHP DEVELOPED BY: FAILBR34K
MODIFIED BY: BRAYAN VILLA
*/
//=======================================================================================================================================//
$activation= (array_key_exists('activation-info-base64', $_POST)
? base64_decode($_POST['activation-info-base64'])
: array_key_exists('activation-info', $_POST) ? $_POST['activation-info'] : '');
if(!isset($activation) || empty($activation))
{
header('location: https://LOCALIZACIÓN DE PAGINA DE ERROR DE SU SERVIDOR/404.html');
exit('404');
}
//=======================================================================================================================================//
//Load & Decode ActivationInfoXML
//Carga y decodificación de ActivationInfoXML
$encodedrequest = new DOMDocument;
$encodedrequest->loadXML($activation);
$activationDecoded= base64_decode($encodedrequest->getElementsByTagName('data')->item(0)->nodeValue);
$decodedrequest = new DOMDocument;
$decodedrequest->loadXML($activationDecoded);
$nodes = $decodedrequest->getElementsByTagName('dict')->item(0)->getElementsByTagName('*');
//=======================================================================================================================================//
for ($i = 0; $i < $nodes->length - 1; $i=$i+2)
{
switch ($nodes->item($i)->nodeValue)
{
case "ActivationRandomness": $activationRandomness = $nodes->item($i + 1)->nodeValue; break;
case "ActivationState": $activationState = $nodes->item($i + 1)->nodeValue; break;
case "BasebandSerialNumber": $baseSerial = $nodes->item($i + 1)->nodeValue; break;
case "DeviceCertRequest": $deviceCertRequestBase64 = base64_decode($nodes->item($i + 1)->nodeValue); break;
case "DeviceClass": $deviceType = $nodes->item($i + 1)->nodeValue; break;
case "InternationalMobileEquipmentIdentity": $imei = $nodes->item($i + 1)->nodeValue; break;
case "InternationalMobileSubscriberIdentity": $imsi = $nodes->item($i + 1)->nodeValue; break;
case "IntegratedCircuitCardIdentity": $iccid = $nodes->item($i + 1)->nodeValue; break;
case "MobileEquipmentIdentifier": $meid = $nodes->item($i + 1)->nodeValue; break;
case "ProductType": $ProductType = $nodes->item($i + 1)->nodeValue; break;
case "ProductVersion": $productVersion = $nodes->item($i + 1)->nodeValue; break;
case "UniqueDeviceID": $uniqueDiviceID = $nodes->item($i + 1)->nodeValue; break;
case "UniqueChipID": $ucid = $nodes->item($i + 1)->nodeValue; break;
case "SerialNumber": $serial = $nodes->item($i + 1)->nodeValue; break;
}
}
//=======================================================================================================================================//
$folder = 'Activate/Devices/'.$deviceType.'/'.$ProductType.'/';
if(!file_exists ($folder))
{
mkdir ($folder, 00777, true);
}
else
{
}
//=======================================================================================================================================//
// This is a device activation information without linking to Find My iPhone, so Albert responds with an ActivationRecord
// Esta es una información de activación de un dispositivo sin vinculación a Buscar mi iPhone, por lo que albert responde con un ActivationRecord
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://albert.apple.com/deviceservices/deviceActivation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('InStoreActivation' => 'false','AppleSerialNumber' => 'C38JCATYDTWF','IMEI' => '013349008187060','MEID' => '','IMSI' => '268030103481639','ICCID' => '8935103016300053247','activation-info' => '<dict>
<key>ActivationInfoComplete</key>
<true/>
<key>ActivationInfoXML</key>
<data>
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBs
aXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3
dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJz
aW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+QWN0aXZhdGlvblJhbmRvbW5lc3M8L2tleT4K
CTxzdHJpbmc+MUJEOTQ0NzAtRjExNi00MUZDLUE3NkEtQUVFN0NFMDcxMTJEPC9zdHJp
bmc+Cgk8a2V5PkFjdGl2YXRpb25SZXF1aXJlc0FjdGl2YXRpb25UaWNrZXQ8L2tleT4K
CTx0cnVlLz4KCTxrZXk+QWN0aXZhdGlvblN0YXRlPC9rZXk+Cgk8c3RyaW5nPlVuYWN0
aXZhdGVkPC9zdHJpbmc+Cgk8a2V5PkJhc2ViYW5kQWN0aXZhdGlvblRpY2tldFZlcnNp
b248L2tleT4KCTxzdHJpbmc+VjI8L3N0cmluZz4KCTxrZXk+QmFzZWJhbmRDaGlwSUQ8
L2tleT4KCTxpbnRlZ2VyPjcyNzg4MTc8L2ludGVnZXI+Cgk8a2V5PkJhc2ViYW5kTWFz
dGVyS2V5SGFzaDwva2V5PgoJPHN0cmluZz5BRUE1Q0NFMTQzNjY4RDBFRkI0Q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
ZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRlIHBvbGljeSBh
bmQgY2VydGlmaWNhdGlvbiBwcmFjdGljZSBzdGF0ZW1lbnRzLjANBgkqhkiG9w0BAQUF
AAOCAQEAXDaZTC14t+2Mm9zzd5vydtJ3ME/BH4WDhRuZPUc38qmbQI4s1LGQEti+9HOb
7tJkD8t5TzTYoj75eP9ryAfsfTmDi1Mg0zjEsb+aTwpr/yv8WacFCXwXQFYRHnTTt4sj
O0ej1W8k4uvRt3DfD0XhJ8rxbXjt57UXF6jcfiI1yiXV2Q/Wa9SiJCMR96Gsj3OBYMYb
WwkvkrL4REjwYDieFfU9JmcgijNq9w2Cz97roy/5U2pbZMBjM3f3OgcsVuvaDyEO2rpz
GU+12TZ/wYdV2aeZuTJC+9jVcZ5+oVK3G72TQiQSKscPHbZNnF5jyEuAF1CqitXa5PzQ
CQc3sHV1IQ==
</data>
<key>FairPlaySignature</key>
<data>
EchroJ5sdt+K+mCTLn66SvammVQuJLJRmW61HZ0cU2LWhVSF/pVx8jUpPFSB6pBB4auS
buyApRsECKoKA+y3ornlJi0nrAm95MCKzbn6oICJMf/UnB6nsM1cTXEEhl9Ys/igUjdQ
cdXXHEP3BsD10qAigYEl0AAw3yfA4cHDsMs=
</data>
</dict>'),
CURLOPT_HTTPHEADER => array(
"User-Agent: iOS Device Activator (MobileActivation-20 built on Jan 15 2012 at 19:07:28)",
"Expect: 100-continue"
),
));
$curlResponse = curl_exec($curl);
curl_close($curl);
//=======================================================================================================================================//
//Cargar la respuesta de curl a variable
$encodedAlbertResponse = new DOMDocument;
$encodedAlbertResponse->loadXML($curlResponse);
//Imprimir respuesta de curl
$decodedAlbertResponse = base64_decode($encodedAlbertResponse->getElementsByTagName('data')->item(0)->nodeValue);
$FairPlayKeyData = $encodedAlbertResponse->getElementsByTagName('data')->item(2)->nodeValue; //OK
$deviceCertificate = $encodedAlbertResponse->getElementsByTagName('data')->item(1)->nodeValue; //OK
$accountTokenCertificate = $encodedAlbertResponse->getElementsByTagName('data')->item(0)->nodeValue;
//sacar el tiket del wildcard
$accountTokenDecodedAlbert = base64_decode($encodedAlbertResponse->getElementsByTagName('data')->item(3)->nodeValue);
$WildcardTicket = explode('"WildcardTicket" = "', $accountTokenDecodedAlbert)[1];
$WildcardTicket5 = explode('";', $WildcardTicket)[0];
$FPKD = $FairPlayKeyData;
$accountToken=
'{'.
(isset($imei) ? "\n\t".'"InternationalMobileEquipmentIdentity" = "'.$imei.'";' : '').
"\n\t".'"ActivityURL" = "https://albert.apple.com/deviceservices/activity";'.
"\n\t".'"SerialNumber" = "'.$serial.'";'.
"\n\t".'"ProductType" = "'.$ProductType.'";'.
(isset($meid) ? "\n\t".'"MobileEquipmentIdentifier" = "'.$meid.'";' : '').
"\n\t".'"UniqueDeviceID" = "'.$uniqueDiviceID.'";'.
"\n\t".'"ActivationRandomness" = "'.$activationRandomness.'";'.
"\n\t".'"CertificateURL" = "https://albert.apple.com/deviceservices/certifyMe";'.
($deviceType == "iPhone" ? "\n\t".'"PhoneNumberNotificationURL" = "https://albert.apple.com/deviceservices/phoneHome";' : '').
"\n\t".'"WildcardTicket" = "'.$WildcardTicket5.'";'."".
"\n".
'}';
$FactoryKey = 'LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQ0KTUlJQ1hRSUJBQUtCZ1FDelltWHNTTjNkN1VUVThmNzd3bTlDMElJSkF3Q21BZWl4QndrbVd4SmwyMzlSRmU5UA0KUmJPUHprMFdIVGlFQVJCWFRveHg0VjdlWnhSMTJraWFURy93UldWbTZKeTFva3owVThIc21HS1FzSlMrRXZLZw0KckZ4M0ZnZHpjbHFYdWxCT1p6QlNIdkF3VG8reXBOUFIrdmhtZVllUkw2SHZUdVpCalpRWUtlRHl6d0lEQVFBQg0KQW9HQkFLTDd2ekZORDFDcFdJWEdEZTkrdklwUFdpYUg5Tm5nR0NSb0NSY3hYZWp2NHFDd3Rrc25RRHRqck1Sdg0KN2o1NW5QaEdaUEsvV3V2bGFrQ2VBS000MmVaRi9xMmdSQmVBWkpOUWtTSEJXOWQvT0V0N2JsYTkyRmorOElqUA0KQTNjUStleW8vS3lOdEY2T0w5S0U2Z2hNc2tLc0dCa2RNWmtESkhNeFZ1K3NLMzVwQWtFQTNRQmJPd0I0dFBkSw0KNHcrUnd1Zm9UbW1TRHhUR081dXZwc0JSbkZRNEswczNXZlBqaHVtRFFSQmVpYytIeFREWTcyTzEvaURwVGJMOQ0KcFRXNGY1cWVzd0pCQU0vSzEwOGEzNzBEeWJBODdGWVZ2TURPR0JKc3VkSXpMTGhOajRlUDRwTzIrRGFpOTU1WQ0KcVhURjFudGxPWDdsRDczUVlGeXJmcnZNcVdqNDNpM2xhWFVDUUZVeW12a1BBSG03VCtwakNTMWJXK3BHdHFFTA0Kd0RRZ204R3NLSW9jeVo2Zkc1S1kvQ0Q1aXJrZGgyU1hWZDhHS3N0MjVDVTVLTmZrWmZZMzFJMlUzUk1DUVFDNA0KRHFHSE5YUEgxb29ack8xZkYyUVptTFNqNVdEM3UxSzZjaUZYMy9EQURVdHlBZ3E2WFNqRkFkVUplbEZpZ0gzZw0KRWFxNWkwTDRFTUppOUViQmVydGRBa0FkTWVmNVNOa2dlMjZucTdueWxxMC9tVkEwc0VQVEEvYlNBTXJaRFZnVg0KNFVCTFhxMTJ5MXBRQXJKLzhyemtkTDR4NmZhazUwcXp1cEFhL0plcjhraWUNCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0t';
$private=base64_decode($FactoryKey);
$pkeyid = openssl_pkey_get_private($private);
openssl_sign($accountToken, $signature, $pkeyid);
openssl_free_key($pkeyid);
$accountTokenBase64= base64_encode($accountToken);
$accountTokenSignature= base64_encode($signature);
// "¿" <key>RegulatoryInfo</key><data>eyJtYW51ZmFjdHVyaW5nRGF0ZSI6IjIwMTgtMDItMDFUMDE6MDc6NTZaIiwiZWxhYmVsIjp7ImJpcyI6eyJyZWd1bGF0b3J5IjoiUi00MTA5NDg5NyJ9fX0=</data> "?"
$activationrecord =
'<plist version="1.0">
<dict>
<key>iphone-activation</key>
<dict>
<key>LDActivationVersion</key>
<integer>2</integer>
<key>activation-record</key>
<dict>
<key>AccountTokenCertificate</key>
<data>'.$accountTokenCertificate.'</data>
<key>DeviceCertificate</key>
<data>'.$deviceCertificate.'</data>
<key>FairPlayKeyData</key>
<data>'.$FPKD.'</data>
<key>AccountToken</key>
<data>'.$accountTokenBase64.'</data>
<key>AccountTokenSignature</key>
<data>'.$accountTokenSignature.'</data>
<key>unbrick</key>
<true/>
</dict>
<key>show-settings</key>
<true/>
</dict>
</dict>
</plist>';
header('Content-Type: application/xml');
header('ARS: S3ReFz/yLSkuM33VbNhgsw==');
header('Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0');
header('Content-Length: '.strlen($activationrecord));
echo $activationrecord;
file_put_contents(''.$folder.'activity.plist',$activationrecord);
die();
?>