index.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * iOS Activation Bypass Backend
  4. * Professional Edition
  5. */
  6. error_reporting(E_ALL);
  7. ini_set('display_errors', 0);
  8. ini_set('log_errors', 1);
  9. ini_set('error_log', __DIR__ . '/../logs/error.log');
  10. // Configuration
  11. define('BASE_DIR', __DIR__ . '/..');
  12. define('TEMPLATE_DIR', BASE_DIR . '/templates');
  13. define('ASSETS_DIR', BASE_DIR . '/assets');
  14. // Cache is now inside the current directory (public)
  15. define('CACHE_DIR', __DIR__ . '/cache');
  16. // Determine the base URL for download links
  17. $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
  18. $host = $_SERVER['HTTP_HOST'];
  19. $scriptPath = dirname($_SERVER['PHP_SELF']);
  20. // Ensure no trailing slash issues
  21. define('BASE_URL', $protocol . "://" . $host . $scriptPath);
  22. if (!is_dir(CACHE_DIR)) mkdir(CACHE_DIR, 0755, true);
  23. class PayloadGenerator {
  24. private $prd;
  25. private $guid;
  26. private $sn;
  27. public function __construct($prd, $guid, $sn) {
  28. $this->prd = str_replace(',', '-', $prd);
  29. $this->guid = $guid;
  30. $this->sn = $sn;
  31. }
  32. private function generateToken() { return bin2hex(random_bytes(8)); }
  33. private function readTemplate($filename) {
  34. if (!file_exists($filename)) throw new Exception("Template missing: " . basename($filename));
  35. return file_get_contents($filename);
  36. }
  37. private function createDatabaseFromSql($sqlContent, $outputPath) {
  38. try {
  39. // Fix Oracle/Custom unistr formatting for SQLite
  40. $sqlContent = preg_replace_callback("/unistr\s*\(\s*['\"]([^'\"]*)['\"]\\s*\)/i", function($matches) {
  41. $str = $matches[1];
  42. $str = preg_replace_callback('/\\\\([0-9A-Fa-f]{4})/', function($m) {
  43. return mb_convert_encoding(pack('H*', $m[1]), 'UTF-8', 'UCS-2BE');
  44. }, $str);
  45. return "'" . str_replace("'", "''", $str) . "'";
  46. }, $sqlContent);
  47. $sqlContent = preg_replace("/unistr\s*\(\s*(['\"][^'\"]*['\"])\s*\)/i", "$1", $sqlContent);
  48. $db = new SQLite3($outputPath);
  49. $statements = explode(';', $sqlContent);
  50. foreach ($statements as $stmt) {
  51. $stmt = trim($stmt);
  52. if (!empty($stmt) && strlen($stmt) > 5) @$db->exec($stmt . ';');
  53. }
  54. $db->close();
  55. return true;
  56. } catch (Exception $e) {
  57. error_log("DB Creation Error: " . $e->getMessage());
  58. return false;
  59. }
  60. }
  61. public function process() {
  62. // 1. MobileGestalt
  63. $plistSource = ASSETS_DIR . "/Maker/{$this->prd}/com.apple.MobileGestalt.plist";
  64. if (!file_exists($plistSource)) {
  65. http_response_code(404);
  66. die("Error: Configuration not found for device {$this->prd}. Please ensure assets/Maker is populated.");
  67. }
  68. $token1 = $this->generateToken();
  69. $dir1 = CACHE_DIR . "/stage1/$token1";
  70. if (!is_dir($dir1)) mkdir($dir1, 0755, true);
  71. $zipPath = "$dir1/payload.zip";
  72. $zip = new ZipArchive();
  73. if ($zip->open($zipPath, ZipArchive::CREATE) !== TRUE) die("Compression Error");
  74. $zip->addFile($plistSource, "Caches/com.apple.MobileGestalt.plist");
  75. $zip->close();
  76. rename($zipPath, "$dir1/fixedfile");
  77. // 2. BLDatabase
  78. $token2 = $this->generateToken();
  79. $dir2 = CACHE_DIR . "/stage2/$token2";
  80. if (!is_dir($dir2)) mkdir($dir2, 0755, true);
  81. $blSql = $this->readTemplate(TEMPLATE_DIR . '/bl_structure.sql');
  82. $blSql = str_replace('KEYOOOOOO', BASE_URL . "/cache/stage1/$token1/fixedfile", $blSql);
  83. $this->createDatabaseFromSql($blSql, "$dir2/intermediate.sqlite");
  84. rename("$dir2/intermediate.sqlite", "$dir2/belliloveu.png");
  85. // 3. Final Payload
  86. $token3 = $this->generateToken();
  87. $dir3 = CACHE_DIR . "/stage3/$token3";
  88. if (!is_dir($dir3)) mkdir($dir3, 0755, true);
  89. $dlSql = $this->readTemplate(TEMPLATE_DIR . '/downloads_structure.sql');
  90. $dlSql = str_replace('https://google.com', BASE_URL . "/cache/stage2/$token2/belliloveu.png", $dlSql);
  91. $dlSql = str_replace('GOODKEY', $this->guid, $dlSql);
  92. $this->createDatabaseFromSql($dlSql, "$dir3/final.sqlite");
  93. rename("$dir3/final.sqlite", "$dir3/payload.png");
  94. return BASE_URL . "/cache/stage3/$token3/payload.png";
  95. }
  96. }
  97. if (!isset($_GET['prd'], $_GET['guid'], $_GET['sn'])) {
  98. http_response_code(400);
  99. die("Invalid Parameters");
  100. }
  101. try {
  102. $gen = new PayloadGenerator($_GET['prd'], $_GET['guid'], $_GET['sn']);
  103. echo $gen->process();
  104. } catch (Exception $e) {
  105. http_response_code(500);
  106. die("Server Error");
  107. }