From f411e2ea6e87f3a61302c6d86fb2fabc13f9031b Mon Sep 17 00:00:00 2001 From: mkuba50 Date: Sat, 13 Jan 2018 19:59:05 +0100 Subject: [PATCH] Reworked requests The way how request data is generated has been changed to make it easier to update when new parameters will appear. This change also adds better branch predictor from build number, so now requests use correct branch for specified build number. --- shared/main.php | 2 +- shared/requests.php | 113 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 100 insertions(+), 15 deletions(-) diff --git a/shared/main.php b/shared/main.php index d640f0e..d4619d2 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.8.2'; + return '1.9.0'; } function uupApiPrintBrand() { diff --git a/shared/requests.php b/shared/requests.php index 15e6da6..2d7dd41 100644 --- a/shared/requests.php +++ b/shared/requests.php @@ -15,6 +15,73 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Composes DeviceAttributes parameter needed to fetch data +function composeDeviceAttributes($flight, $ring, $build, $arch) { + $branch = branchFromBuild($build); + + if($ring == 'RETAIL') { + $flightEnabled = 0; + } else { + $flightEnabled = 1; + } + + $attrib = array( + 'App=WU', + 'AppVer='.$build, + 'AttrDataVer=30', + 'BranchReadinessLevel=CB', + 'CurrentBranch='.$branch, + 'DeviceFamily=Windows.Desktop', + 'FirmwareVersion=6.00', + 'FlightContent='.$flight, + 'FlightingBranchName=external', + 'FlightRing='.$ring, + 'Free=32to64', + 'GStatus_RS3=2', + 'InstallationType=Client', + 'InstallLanguage=en-US', + 'IsDeviceRetailDemo=0', + 'IsFlightingEnabled='.$flightEnabled, + 'OEMModel=Microsoft', + 'OEMName_Uncleaned=Microsoft', + 'OSArchitecture='.$arch, + 'OSSkuId=48', + 'OSUILocale=en-US', + 'OSVersion='.$build, + 'PonchAllow=1', + 'ProcessorIdentifier=Intel64 Family 6 Model 142 Stepping 9', + 'ProcessorManufacturer=GenuineIntel', + 'TelemetryLevel=1', + 'UpdateManagementGroup=2', + 'UpgEx_RS3=Green', + 'WuClientVer='.$build, + ); + + return 'E:'.implode('&', $attrib); +} + +// Returns the most possible branch for selected build +function branchFromBuild($build) { + $build = explode('.', $build); + $build = $build[2]; + + switch($build) { + case 15063: + $branch = 'rs2_release'; + break; + + case 16299: + $branch = 'rs3_release'; + break; + + default: + $branch = 'rs_prerelease'; + break; + } + + return $branch; +} + // Composes POST data for gathering list of urls for download function composeFileGetRequest($updateId, $device, $info, $rev = 1) { $uuid = randStr(8).'-'.randStr(4).'-'.randStr(4).'-'.randStr(4).'-'.randStr(12); @@ -25,15 +92,16 @@ function composeFileGetRequest($updateId, $device, $info, $rev = 1) { $created = gmdate(DATE_W3C, $createdTime); $expires = gmdate(DATE_W3C, $expiresTime); - $flightEnabled = 1; - $branch = 'rs_prerelease'; + $branch = branchFromBuild($info['checkBuild']); - if($info['ring'] == 'RETAIL') { - $flightEnabled = 0; - $branch = 'rs2_release'; - } + $deviceAttributes = composeDeviceAttributes( + $info['flight'], + $info['ring'], + $info['checkBuild'], + $info['arch'] + ); - 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.'FileUrlFileDecryptionE:BranchReadinessLevel=CB&GStatus_RS3=2&PonchAllow=1&CurrentBranch='.$branch.'&FlightContent='.$info['flight'].'&FlightingBranchName=external&FlightRing='.$info['ring'].'&AttrDataVer=29&InstallLanguage=en-US&OSUILocale=en-US&InstallationType=Client&FirmwareVersion=6.00&OSSkuId=48&App=WU&ProcessorManufacturer=GenuineIntel&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&'; + 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.'FileUrlFileDecryption'.$deviceAttributes.''; } // Composes POST data for fetching the latest update information from Windows Update @@ -46,14 +114,31 @@ function composeFetchUpdRequest($device, $encData, $arch, $flight, $ring, $build $created = gmdate(DATE_W3C, $createdTime); $expires = gmdate(DATE_W3C, $expiresTime); - $flightEnabled = 1; - $branch = 'rs_prerelease'; + $branch = branchFromBuild($build); - if($ring == 'RETAIL') { - $flightEnabled = 0; - $branch = 'rs2_release'; - } + $products = array( + 'Branch='.$branch, + 'PN=Client.OS.rs2.'.$arch, + 'PrimaryOSProduct=1', + 'V='.$build, + ); - 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-USfalseE:BranchReadinessLevel=CB&GStatus_RS3=2&PonchAllow=1&CurrentBranch='.$branch.'&FlightContent='.$flight.'&FlightingBranchName=external&FlightRing='.$ring.'&AttrDataVer=29&InstallLanguage=en-US&OSUILocale=en-US&InstallationType=Client&FirmwareVersion=6.00&OSSkuId=48&App=WU&ProcessorManufacturer=GenuineIntel&AppVer='.$build.'&UpgEx_RS3=Green&OSArchitecture=AMD64&UpdateManagementGroup=2&IsFlightingEnabled='.$flightEnabled.'&IsDeviceRetailDemo=0&TelemetryLevel=1&WuClientVer='.$build.'&Free=32to64&OSVersion='.$build.'&DeviceFamily=Windows.DesktopE:Interactive=1&IsSeeker=1&Id=UpdateOrchestrator&PN=Client.OS.rs2.'.$arch.'&Branch='.$branch.'&PrimaryOSProduct=1&V='.$build.';'; + $callerAttrib = array( + 'Id=UpdateOrchestrator', + 'Interactive=1', + 'IsSeeker=1', + ); + + $products = implode('&', $products); + $callerAttrib = 'E:'.implode('&', $callerAttrib); + + $deviceAttributes = composeDeviceAttributes( + $flight, + $ring, + $build, + $arch + ); + + 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-USfalse'.$deviceAttributes.''.$callerAttrib.''.$products.''; } ?>