From f9997dee4b6de9f876db9c61582b0207fa6a630a Mon Sep 17 00:00:00 2001 From: mkuba50 Date: Mon, 23 Oct 2017 22:53:33 +0200 Subject: [PATCH] Retail ring support --- fetchupd.php | 25 ++++++++++++++++++++----- get.php | 8 +++++++- shared/main.php | 2 +- shared/requests.php | 36 +++++++++++++++++++++++++++++++++--- 4 files changed, 61 insertions(+), 10 deletions(-) diff --git a/fetchupd.php b/fetchupd.php index 524c5cf..8a9ab57 100644 --- a/fetchupd.php +++ b/fetchupd.php @@ -31,7 +31,7 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build return array('error' => 'UNKNOWN_ARCH'); } - if(!($ring == 'WIF' || $ring == 'WIS' || $ring == 'RP')) { + if(!($ring == 'WIF' || $ring == 'WIS' || $ring == 'RP' || $ring == 'RETAIL')) { return array('error' => 'UNKNOWN_RING'); } @@ -105,13 +105,28 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build $updateTitle = 'Windows 10 build '.$foundBuild; } + $updateTitle = preg_replace('/ for .{3,5}-based systems/i', '', $updateTitle); + + if(preg_match('/Feature update/i', $updateTitle)) { + $updateTitle = $updateTitle.' ('.$foundBuild.')'; + } + preg_match('/UpdateID=".*?"/', $updateInfo[0], $updateId); + preg_match('/RevisionNumber=".*?"/', $updateInfo[0], $updateRev); + $updateId = preg_replace('/UpdateID="|"$/', '', $updateId[0]); + $updateRev = preg_replace('/RevisionNumber="|"$/', '', $updateRev[0]); + consoleLogger('Successfully checked build information.'); consoleLogger('BUILD: '.$updateTitle.' '.$arch); + $updateString = $updateId; + if($updateRev != 1) { + $updateString = $updateId.'_rev.'.$updateRev; + } + $fileWrite = 'NO_SAVE'; - if(!file_exists('fileinfo/'.$updateId.'.json')) { + if(!file_exists('fileinfo/'.$updateString.'.json')) { consoleLogger('WARNING: This build is NOT in the database. It will be saved now.'); consoleLogger('Parsing information to write...'); if(!file_exists('fileinfo')) mkdir('fileinfo'); @@ -161,7 +176,7 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build consoleLogger('Successfully parsed the information.'); consoleLogger('Writing new build information to the disk...'); - $success = file_put_contents('fileinfo/'.$updateId.'.json', json_encode($temp)."\n"); + $success = file_put_contents('fileinfo/'.$updateString.'.json', json_encode($temp)."\n"); if($success) { consoleLogger('Successfully written build information to the disk.'); $fileWrite = 'INFO_WRITTEN'; @@ -179,7 +194,7 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build foreach($ids as $val) { $testName = $val['build'].' '.$val['title'].' '.$val['arch']; - if($buildName == $testName && $val['uuid'] != $updateId) { + if($buildName == $testName && $val['uuid'] != $updateString) { unlink(realpath('fileinfo/'.$val['uuid'].'.json')); consoleLogger('Removed superseded update: '.$val['uuid']); } @@ -188,7 +203,7 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build return array( 'apiVersion' => uupApiVersion(), - 'updateId' => $updateId, + 'updateId' => $updateString, 'updateTitle' => $updateTitle, 'foundBuild' => $foundBuild, 'arch' => $arch, diff --git a/get.php b/get.php index a27f0ae..af807ae 100644 --- a/get.php +++ b/get.php @@ -89,8 +89,14 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac if($info['needsFix'] == true) $uupFix = 1; } + $rev = 1; + if(preg_match('/_rev\./', $updateId)) { + $rev = preg_replace('/.*_rev\./', '', $updateId); + $updateId = preg_replace('/_rev\..*/', '', $updateId); + } + consoleLogger('Fetching information from the server...'); - $postData = composeFileGetRequest($updateId, uupDevice(), $info); + $postData = composeFileGetRequest($updateId, uupDevice(), $info, $rev); $out = sendWuPostRequest('https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured', $postData); consoleLogger('Information was successfully fetched.'); diff --git a/shared/main.php b/shared/main.php index 84ca855..6e8e0f2 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.3.0'; + return '1.4.0'; } function uupApiPrintBrand() { diff --git a/shared/requests.php b/shared/requests.php index bd79a33..138d6f0 100644 --- a/shared/requests.php +++ b/shared/requests.php @@ -16,14 +16,44 @@ limitations under the License. */ // Composes POST data for gathering list of urls for download -function composeFileGetRequest($updateId, $device, $info) { +function composeFileGetRequest($updateId, $device, $info, $rev = 1) { $uuid = randStr(8).'-'.randStr(4).'-'.randStr(4).'-'.randStr(4).'-'.randStr(12); - return 'http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetExtendedUpdateInfo2urn:uuid:'.$uuid.'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured2017-01-01T01:00:00.000Z2020-01-01T02:00:00.000Z'.$device.''.$updateId.'1FileUrlFileDecryptionApp=WU;AppVer=10.0.16251.1000;AttrDataVer=22;BranchReadinessLevel=CB;CurrentBranch=rs_prerelease;DeviceFamily=Windows.Desktop;FirmwareVersion=6.00;FlightContent='.$info['flight'].';FlightingBranchName=external;FlightRing='.$info['ring'].';InstallationType=Client;InstallLanguage=en-US;IsDeviceRetailDemo=0;IsFlightingEnabled=1;OSSkuId=48;OSUILocale=en-US;OSVersion='.$info['checkBuild'].';TelemetryLevel=3;UpdateManagementGroup=2;'; + + $createdTime = time(); + $expiresTime = $createdTime + 120; + + $created = gmdate(DATE_W3C, $createdTime); + $expires = gmdate(DATE_W3C, $expiresTime); + + $flightEnabled = 1; + $branch = 'rs_prerelease'; + + if($info['ring'] == 'Retail') { + $flightEnabled = 0; + $branch = 'rs2_release'; + } + + return 'http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetExtendedUpdateInfo2urn:uuid:'.$uuid.'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured'.$created.''.$expires.''.$device.''.$updateId.''.$rev.'FileUrlFileDecryptionBranchReadinessLevel=CB;GStatus_RS3=2;CurrentBranch='.$branch.';FlightContent='.$info['flight'].';FlightingBranchName=external;FlightRing='.$info['ring'].';AttrDataVer=25;InstallLanguage=en-US;OSUILocale=en-US;InstallationType=Client;FirmwareVersion=6.00;OSSkuId=48;App=WU;AppVer='.$info['checkBuild'].';UpgEx_RS3=Green;OSArchitecture=AMD64;UpdateManagementGroup=2;IsFlightingEnabled='.$flightEnabled.';IsDeviceRetailDemo=0;TelemetryLevel=1;WuClientVer='.$info['checkBuild'].';Free=32to64;OSVersion='.$info['checkBuild'].';DeviceFamily=Windows.Desktop;'; } // Composes POST data for fetching the latest update information from Windows Update function composeFetchUpdRequest($device, $encData, $arch, $flight, $ring, $build) { $uuid = randStr(8).'-'.randStr(4).'-'.randStr(4).'-'.randStr(4).'-'.randStr(12); - return 'http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/SyncUpdatesurn:uuid:'.$uuid.'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx2017-01-01T01:00:00.000Z2020-01-01T02:00:00.000Z'.$device.'2045-04-07T12:38:34Z'.$encData.'falsefalsetruetrueExtendedLocalizedPropertiesEulaen-USfalseApp=WU;AppVer='.$build.';AttrDataVer=22;BranchReadinessLevel=CB;CurrentBranch=rs_prerelease;DeviceFamily=Windows.Desktop;FirmwareVersion=6.00;FlightContent='.$flight.';FlightingBranchName=external;FlightRing='.$ring.';InstallationType=Client;InstallLanguage=en-US;IsDeviceRetailDemo=0;IsFlightingEnabled=1;OSSkuId=48;OSUILocale=en-US;OSVersion='.$build.';TelemetryLevel=3;UpdateManagementGroup=2;Interactive=1;IsSeeker=0;PN=Client.OS.rs2.'.$arch.'&Branch=rs_prerelease&PrimaryOSProduct=1&V='.$build.';'; + + $createdTime = time(); + $expiresTime = $createdTime + 120; + + $created = gmdate(DATE_W3C, $createdTime); + $expires = gmdate(DATE_W3C, $expiresTime); + + $flightEnabled = 1; + $branch = 'rs_prerelease'; + + if($ring == 'Retail') { + $flightEnabled = 0; + $branch = 'rs2_release'; + } + + return 'http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/SyncUpdatesurn:uuid:'.$uuid.'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx'.$created.''.$expires.''.$device.'2045-04-07T12:38:34Z'.$encData.'falsefalsetruetrueExtendedLocalizedPropertiesEulaen-USfalseBranchReadinessLevel=CB;GStatus_RS3=2;CurrentBranch='.$branch.';FlightContent='.$flight.';FlightingBranchName=external;FlightRing='.$ring.';AttrDataVer=25;InstallLanguage=en-US;OSUILocale=en-US;InstallationType=Client;FirmwareVersion=6.00;OSSkuId=48;App=WU;AppVer='.$build.';UpgEx_RS3=Green;OSArchitecture=AMD64;UpdateManagementGroup=2;IsFlightingEnabled='.$flightEnabled.';IsDeviceRetailDemo=0;TelemetryLevel=1;WuClientVer='.$build.';Free=32to64;OSVersion='.$build.';DeviceFamily=Windows.Desktop;Interactive=1;IsSeeker=1;PN=Client.OS.rs2.'.$arch.'&Branch='.$branch.'&PrimaryOSProduct=1&V='.$build.';'; } ?>