From 8ca718ed8d45d1c5b9924a6fea50e4d4eab7ffb9 Mon Sep 17 00:00:00 2001 From: luzeadev <62355456+luzeadev@users.noreply.github.com> Date: Sun, 19 Sep 2021 15:59:21 +0200 Subject: [PATCH] use sha256 for generated packs --- shared/genpack.php | 31 +++++++++++-------------------- shared/main.php | 2 +- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/shared/genpack.php b/shared/genpack.php index 70592ba..e6bde16 100644 --- a/shared/genpack.php +++ b/shared/genpack.php @@ -36,10 +36,17 @@ function generatePack($updateId) { $isku = $files['sku']; $files = $files['files']; + + if(!$files[key($files)]['sha256']) { + consoleLogger('Update is not SHA-256 capable!'); + return 0; + } + $filesKeys = array_keys($files); $filesToRead = array(); $aggregatedMetadata = preg_grep('/AggregatedMetadata/i', $filesKeys); + if(!empty($aggregatedMetadata)) { sort($aggregatedMetadata); $checkFile = $aggregatedMetadata[0]; @@ -128,12 +135,6 @@ function generatePack($updateId) { unset($loc, $checkEd, $dataFiles); } - $keepPath = 0; - foreach($filesKeys as $val) { - if(preg_match('/^appx\/(.*?)\//i', $val)) $keepPath = 1; - if(preg_match('/^(retail)\/(.{3,5})\/fre\//i', $val)) $keepPath = 1; - } - $langsEditions = array(); $packages = array(); foreach($filesToRead as $val) { @@ -157,25 +158,15 @@ function generatePack($updateId) { foreach($xml->Packages->Package as $val) { foreach($val->Payload->PayloadItem as $PayloadItem) { - $name = $PayloadItem['Path']; - if($keepPath) { - $name = str_replace('\\', '_', $name); - } else { - $name = preg_replace('/.*\\\/', '', $name); - } - $packages[$lang][$edition][] = $name; + $sha256 = bin2hex(base64_decode($PayloadItem['PayloadHash'])); + $packages[$lang][$edition][] = $sha256; } } if(@count($xml->AppX)) foreach($xml->AppX->AppXPackages->Package as $val) { foreach($val->Payload->PayloadItem as $PayloadItem) { - $name = $PayloadItem['Path']; - if($keepPath) { - $name = str_replace('\\', '_', $name); - } else { - $name = preg_replace('/.*\\\/', '', $name); - } - $packages[$lang][$edition][] = $name; + $sha256 = bin2hex(base64_decode($PayloadItem['PayloadHash'])); + $packages[$lang][$edition][] = $sha256; } } diff --git a/shared/main.php b/shared/main.php index c4ec023..004d66d 100644 --- a/shared/main.php +++ b/shared/main.php @@ -2,7 +2,7 @@ require_once dirname(__FILE__).'/../api/shared/main.php'; function brand($script = null) { - $projVersion = '1.0.3'; + $projVersion = '1.1.0'; return 'UUP dump standalone v'.$projVersion; }