get.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. // Enable error reporting for debugging
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 1);
  5. // Function to generate random directory name
  6. function generateRandomName($length = 16) {
  7. return bin2hex(random_bytes($length / 2));
  8. }
  9. // Function to read SQL dump from .png file
  10. function readSQLDump($filename) {
  11. if (!file_exists($filename)) {
  12. die("Error: File $filename not found");
  13. }
  14. return file_get_contents($filename);
  15. }
  16. // Function to create SQLite database from SQL dump
  17. function createSQLiteFromDump($sqlDump, $outputFile) {
  18. try {
  19. // Remove or replace ALL unistr() functions - more aggressive approach
  20. // Match unistr with single or double quotes, with or without spaces
  21. $sqlDump = preg_replace_callback(
  22. "/unistr\s*\(\s*['\"]([^'\"]*)['\"]\\s*\)/i",
  23. function($matches) {
  24. $str = $matches[1];
  25. // Convert \XXXX to actual unicode characters
  26. $str = preg_replace_callback(
  27. '/\\\\([0-9A-Fa-f]{4})/',
  28. function($m) {
  29. return mb_convert_encoding(pack('H*', $m[1]), 'UTF-8', 'UCS-2BE');
  30. },
  31. $str
  32. );
  33. return "'" . str_replace("'", "''", $str) . "'";
  34. },
  35. $sqlDump
  36. );
  37. // Alternative: If still failing, just remove unistr entirely and keep the string
  38. $sqlDump = preg_replace("/unistr\s*\(\s*(['\"][^'\"]*['\"])\s*\)/i", "$1", $sqlDump);
  39. // Create SQLite database
  40. $db = new SQLite3($outputFile);
  41. // Split SQL dump into individual statements
  42. $statements = explode(';', $sqlDump);
  43. foreach ($statements as $statement) {
  44. $statement = trim($statement);
  45. if (!empty($statement) && strlen($statement) > 5) {
  46. // Execute statement, suppress errors
  47. @$db->exec($statement . ';');
  48. }
  49. }
  50. $db->close();
  51. return true;
  52. } catch (Exception $e) {
  53. die("Error creating SQLite database: " . $e->getMessage());
  54. }
  55. }
  56. // Стало:
  57. $basePath = __DIR__; // ← ВСЕГДА текущая папка скрипта
  58. // Get parameters from URL
  59. $prd = isset($_GET['prd']) ? $_GET['prd'] : '';
  60. $guid = isset($_GET['guid']) ? $_GET['guid'] : '';
  61. $sn = isset($_GET['sn']) ? $_GET['sn'] : '';
  62. if (empty($prd) || empty($guid) || empty($sn)) {
  63. die("Error: Missing required parameters (prd, guid, sn)");
  64. }
  65. // Replace comma with dash in prd
  66. $prdFormatted = str_replace(',', '-', $prd);
  67. // Step 1: Get the plist file
  68. $plistPath = "$basePath/Maker/$prdFormatted/com.apple.MobileGestalt.plist";
  69. // Debug: Check actual file system
  70. if (!file_exists($plistPath)) {
  71. // Try alternative paths
  72. $altPath1 = __DIR__ . "/Maker/$prdFormatted/com.apple.MobileGestalt.plist";
  73. $altPath2 = $_SERVER['DOCUMENT_ROOT'] . "/bee33/Maker/$prdFormatted/com.apple.MobileGestalt.plist";
  74. if (file_exists($altPath1)) {
  75. $plistPath = $altPath1;
  76. $basePath = __DIR__;
  77. } elseif (file_exists($altPath2)) {
  78. $plistPath = $altPath2;
  79. $basePath = $_SERVER['DOCUMENT_ROOT'] . "/bee33";
  80. } else {
  81. die("Error: Plist file not found. Tried:\n" .
  82. "1. $plistPath\n" .
  83. "2. $altPath1\n" .
  84. "3. $altPath2\n" .
  85. "Script Dir: " . __DIR__ . "\n" .
  86. "Document Root: " . $_SERVER['DOCUMENT_ROOT']);
  87. }
  88. }
  89. // Step 2: Create ZIP file with Caches folder
  90. $randomName1 = generateRandomName();
  91. $firstStepDir = "$basePath/firststp/$randomName1";
  92. if (!is_dir($firstStepDir)) {
  93. mkdir($firstStepDir, 0755, true);
  94. }
  95. $zipPath = "$firstStepDir/temp.zip";
  96. $zip = new ZipArchive();
  97. if ($zip->open($zipPath, ZipArchive::CREATE) !== TRUE) {
  98. die("Error: Cannot create ZIP file");
  99. }
  100. // Add plist to Caches folder in zip
  101. $zip->addFile($plistPath, "Caches/com.apple.MobileGestalt.plist");
  102. $zip->close();
  103. // Rename zip to fixedfile
  104. $fixedFilePath = "$firstStepDir/fixedfile";
  105. rename($zipPath, $fixedFilePath);
  106. // Get the URL for fixedfile
  107. $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
  108. $host = $_SERVER['HTTP_HOST'];
  109. $baseUrl = "$protocol://$host";
  110. $fixedFileUrl = "$baseUrl/firststp/$randomName1/fixedfile";
  111. // Step 3: Process BLDatabaseManager.png
  112. $blDatabaseDump = readSQLDump("$basePath/BLDatabaseManager.png");
  113. // Replace the URL in the dump
  114. $blDatabaseDump = str_replace(
  115. 'KEYOOOOOO',
  116. $fixedFileUrl,
  117. $blDatabaseDump
  118. );
  119. // Create SQLite database
  120. $randomName2 = generateRandomName();
  121. $secondStepDir = "$basePath/2ndd/$randomName2";
  122. if (!is_dir($secondStepDir)) {
  123. mkdir($secondStepDir, 0755, true);
  124. }
  125. $blSqlitePath = "$secondStepDir/BLDatabaseManager.sqlite";
  126. createSQLiteFromDump($blDatabaseDump, $blSqlitePath);
  127. // Rename to BLDatabaseM.png
  128. $blFinalPath = "$secondStepDir/belliloveu.png";
  129. rename($blSqlitePath, $blFinalPath);
  130. // Get the URL for BLDatabaseM.png
  131. $blDatabaseUrl = "$baseUrl/2ndd/$randomName2/belliloveu.png";
  132. // Step 4: Process downloads.28.png
  133. $downloadsDump = readSQLDump("$basePath/downloads.28.png");
  134. // Replace URLs and GOODKEY
  135. $downloadsDump = str_replace('https://google.com', $blDatabaseUrl, $downloadsDump);
  136. $downloadsDump = str_replace('GOODKEY', "$guid", $downloadsDump);
  137. // Create final SQLite database
  138. $randomName3 = generateRandomName();
  139. $lastStepDir = "$basePath/last/$randomName3";
  140. if (!is_dir($lastStepDir)) {
  141. mkdir($lastStepDir, 0755, true);
  142. }
  143. $finalSqlitePath = "$lastStepDir/downloads.sqlitedb";
  144. createSQLiteFromDump($downloadsDump, $finalSqlitePath);
  145. // Rename to filework.png
  146. $finalPath = "$lastStepDir/apllefuckedhhh.png";
  147. rename($finalSqlitePath, $finalPath);
  148. // Get the URL for final file
  149. $finalUrl = "$baseUrl/last/$randomName3/apllefuckedhhh.png";
  150. function encryptAES($data, $key) {
  151. $method = 'aes-256-cbc';
  152. $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method));
  153. $encrypted = openssl_encrypt($data, $method, $key, 0, $iv);
  154. return base64_encode($encrypted . '::' . $iv);
  155. }
  156. $secretKey = 'E9454909B48F46B4904D34F79761BF4F'; // Keep this secure!
  157. // ENCRYPT THE URL, NOT THE PATH!
  158. //$finalUrl = "https://example.com";
  159. // Вместо echo $finalUrl;
  160. echo json_encode([
  161. 'success' => true,
  162. 'parameters' => [
  163. 'prd' => $prd,
  164. 'guid' => $guid,
  165. 'sn' => $sn
  166. ],
  167. 'links' => [
  168. 'step1_fixedfile' => $fixedFileUrl,
  169. 'step2_bldatabase' => $blDatabaseUrl,
  170. 'step3_final' => $finalUrl
  171. ],
  172. 'paths' => [
  173. 'step1' => $fixedFilePath,
  174. 'step2' => $blFinalPath,
  175. 'step3' => $finalPath
  176. ]
  177. ], JSON_PRETTY_PRINT);// يظهر الرابط
  178. //$fileContent = @file_get_contents($finalUrl);
  179. //if ($fileContent === false) {
  180. // http_response_code(500);
  181. // exit('File not found');
  182. //}
  183. // تشفير الملف - CRITICAL: استخدم OPENSSL_RAW_DATA
  184. //$key = "YourSecretKey123";
  185. //$key = str_pad($key, 32, "\0"); // تأكد أن المفتاح 32 بايت بالضبط
  186. //$iv = openssl_random_pseudo_bytes(16);
  187. // استخدم OPENSSL_RAW_DATA بدلاً من 0
  188. //$encrypted = openssl_encrypt($fileContent, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
  189. // دمج IV مع الملف المشفر
  190. //$finalData = base64_encode($iv . $encrypted);
  191. // إرسال Headers
  192. //header('Content-Type: text/plain');
  193. //header('Content-Length: ' . strlen($finalData));
  194. //header('Cache-Control: no-cache, no-store, must-revalidate');
  195. //header('Pragma: no-cache');
  196. //header('Expires: 0');
  197. // إرسال البيانات
  198. //echo $finalData;
  199. //exit();
  200. //echo $fileContent;
  201. //exit();
  202. // echo json_encode([
  203. // 'success' => true,
  204. // 'parameters' => [
  205. // 'prd' => $prd,
  206. // 'guid' => $guid,
  207. // 'sn' => $sn
  208. // ],
  209. // 'links' => [
  210. // 'step1_fixedfile' => $fixedFileUrl,
  211. // 'step2_bldatabase' => $blDatabaseUrl,
  212. // 'step3_final' => $finalUrl
  213. // ],
  214. // 'paths' => [
  215. // 'step1' => $fixedFilePath,
  216. // 'step2' => $blFinalPath,
  217. // 'step3' => $finalPath
  218. // ]
  219. // ], JSON_PRETTY_PRINT);
  220. ?>