2017-09-22 21:24:31 +02:00
|
|
|
<?php
|
|
|
|
/*
|
2018-03-15 22:33:17 +01:00
|
|
|
Copyright 2018 UUP dump API authors
|
2017-09-22 21:24:31 +02:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2018-01-13 19:59:05 +01:00
|
|
|
// Composes DeviceAttributes parameter needed to fetch data
|
2018-04-29 21:33:19 +02:00
|
|
|
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku) {
|
2018-01-13 19:59:05 +01:00
|
|
|
$branch = branchFromBuild($build);
|
|
|
|
|
|
|
|
if($ring == 'RETAIL') {
|
|
|
|
$flightEnabled = 0;
|
2018-08-10 23:55:45 +02:00
|
|
|
$isRetail = 1;
|
2018-01-13 19:59:05 +01:00
|
|
|
} else {
|
|
|
|
$flightEnabled = 1;
|
2018-08-10 23:55:45 +02:00
|
|
|
$isRetail = 0;
|
2018-01-13 19:59:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$attrib = array(
|
2018-12-13 21:19:51 +01:00
|
|
|
'App=WU_OS',
|
2018-01-13 19:59:05 +01:00
|
|
|
'AppVer='.$build,
|
2018-12-15 20:22:36 +01:00
|
|
|
'AttrDataVer=54',
|
2018-01-13 19:59:05 +01:00
|
|
|
'BranchReadinessLevel=CB',
|
|
|
|
'CurrentBranch='.$branch,
|
2018-12-15 20:22:36 +01:00
|
|
|
'DataVer_RS5='.PHP_INT_MAX,
|
2018-01-13 19:59:05 +01:00
|
|
|
'DeviceFamily=Windows.Desktop',
|
|
|
|
'FirmwareVersion=6.00',
|
|
|
|
'FlightContent='.$flight,
|
|
|
|
'FlightRing='.$ring,
|
2018-08-10 23:55:45 +02:00
|
|
|
'FlightingBranchName=external',
|
2018-01-13 19:59:05 +01:00
|
|
|
'Free=32to64',
|
2018-08-10 23:55:45 +02:00
|
|
|
'GStatus_RS5=2',
|
|
|
|
'InstallDate=1438196400',
|
2018-01-13 19:59:05 +01:00
|
|
|
'InstallLanguage=en-US',
|
2018-08-10 23:55:45 +02:00
|
|
|
'InstallationType=Client',
|
2018-01-13 19:59:05 +01:00
|
|
|
'IsDeviceRetailDemo=0',
|
|
|
|
'IsFlightingEnabled='.$flightEnabled,
|
2018-08-10 23:55:45 +02:00
|
|
|
'IsRetailOS='.$isRetail,
|
|
|
|
'OEMModel=Largehard Device Model 42069',
|
|
|
|
'OEMModelBaseBoard=Largehard Base Board',
|
2018-12-15 20:22:36 +01:00
|
|
|
'OEMName_Uncleaned=Largehard Corporation',
|
2018-01-13 19:59:05 +01:00
|
|
|
'OSArchitecture='.$arch,
|
2018-04-29 21:33:19 +02:00
|
|
|
'OSSkuId='.$sku,
|
2018-01-13 19:59:05 +01:00
|
|
|
'OSUILocale=en-US',
|
|
|
|
'OSVersion='.$build,
|
|
|
|
'ProcessorIdentifier=Intel64 Family 6 Model 142 Stepping 9',
|
|
|
|
'ProcessorManufacturer=GenuineIntel',
|
|
|
|
'TelemetryLevel=1',
|
|
|
|
'UpdateManagementGroup=2',
|
2018-08-10 23:55:45 +02:00
|
|
|
'UpgEx_RS5=Green',
|
2018-12-15 20:22:36 +01:00
|
|
|
'Version_RS5='.PHP_INT_MAX,
|
2018-01-13 19:59:05 +01:00
|
|
|
'WuClientVer='.$build,
|
|
|
|
);
|
|
|
|
|
2018-09-21 18:01:12 +02:00
|
|
|
return htmlentities('E:'.implode('&', $attrib));
|
2018-01-13 19:59:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2018-08-10 23:55:45 +02:00
|
|
|
case 17134:
|
|
|
|
$branch = 'rs4_release';
|
|
|
|
break;
|
|
|
|
|
2018-01-13 19:59:05 +01:00
|
|
|
default:
|
|
|
|
$branch = 'rs_prerelease';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $branch;
|
|
|
|
}
|
|
|
|
|
2017-09-22 21:24:31 +02:00
|
|
|
// Composes POST data for gathering list of urls for download
|
2017-10-23 22:53:33 +02:00
|
|
|
function composeFileGetRequest($updateId, $device, $info, $rev = 1) {
|
2018-12-13 21:19:51 +01:00
|
|
|
$uuid = genUUID();
|
2017-10-23 22:53:33 +02:00
|
|
|
|
|
|
|
$createdTime = time();
|
|
|
|
$expiresTime = $createdTime + 120;
|
|
|
|
|
|
|
|
$created = gmdate(DATE_W3C, $createdTime);
|
|
|
|
$expires = gmdate(DATE_W3C, $expiresTime);
|
|
|
|
|
2018-01-13 19:59:05 +01:00
|
|
|
$branch = branchFromBuild($info['checkBuild']);
|
2017-10-23 22:53:33 +02:00
|
|
|
|
2018-01-13 19:59:05 +01:00
|
|
|
$deviceAttributes = composeDeviceAttributes(
|
|
|
|
$info['flight'],
|
|
|
|
$info['ring'],
|
|
|
|
$info['checkBuild'],
|
2018-04-29 21:33:19 +02:00
|
|
|
$info['arch'],
|
|
|
|
$info['sku']
|
2018-01-13 19:59:05 +01:00
|
|
|
);
|
2017-10-23 22:53:33 +02:00
|
|
|
|
2018-01-13 19:59:05 +01:00
|
|
|
return '<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><a:Action s:mustUnderstand="1">http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetExtendedUpdateInfo2</a:Action><a:MessageID>urn:uuid:'.$uuid.'</a:MessageID><a:To s:mustUnderstand="1">https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured</a:To><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><Created>'.$created.'</Created><Expires>'.$expires.'</Expires></Timestamp><wuws:WindowsUpdateTicketsToken wsu:id="ClientMSA" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wuws="http://schemas.microsoft.com/msus/2014/10/WindowsUpdateAuthorization"><TicketType Name="MSA" Version="1.0" Policy="MBI_SSL"><Device>'.$device.'</Device></TicketType></wuws:WindowsUpdateTicketsToken></o:Security></s:Header><s:Body><GetExtendedUpdateInfo2 xmlns="http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService"><updateIDs><UpdateIdentity><UpdateID>'.$updateId.'</UpdateID><RevisionNumber>'.$rev.'</RevisionNumber></UpdateIdentity></updateIDs><infoTypes><XmlUpdateFragmentType>FileUrl</XmlUpdateFragmentType><XmlUpdateFragmentType>FileDecryption</XmlUpdateFragmentType></infoTypes><deviceAttributes>'.$deviceAttributes.'</deviceAttributes></GetExtendedUpdateInfo2></s:Body></s:Envelope>';
|
2017-09-22 21:24:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Composes POST data for fetching the latest update information from Windows Update
|
2018-04-29 21:33:19 +02:00
|
|
|
function composeFetchUpdRequest($device, $encData, $arch, $flight, $ring, $build, $sku = 48) {
|
2018-12-13 21:19:51 +01:00
|
|
|
$uuid = genUUID();
|
2017-10-23 22:53:33 +02:00
|
|
|
|
|
|
|
$createdTime = time();
|
|
|
|
$expiresTime = $createdTime + 120;
|
2018-12-13 23:18:34 +01:00
|
|
|
$cookieExpiresTime = $createdTime + 604800;
|
2017-10-23 22:53:33 +02:00
|
|
|
|
|
|
|
$created = gmdate(DATE_W3C, $createdTime);
|
|
|
|
$expires = gmdate(DATE_W3C, $expiresTime);
|
2018-12-13 23:18:34 +01:00
|
|
|
$cookieExpires = gmdate(DATE_W3C, $cookieExpiresTime);
|
2017-10-23 22:53:33 +02:00
|
|
|
|
2018-01-13 19:59:05 +01:00
|
|
|
$branch = branchFromBuild($build);
|
2017-10-23 22:53:33 +02:00
|
|
|
|
2018-01-13 19:59:05 +01:00
|
|
|
$products = array(
|
2018-12-13 21:19:51 +01:00
|
|
|
'PN=Client.OS.rs2.'.$arch.'&Branch='.$branch.'&PrimaryOSProduct=1&Repairable=1&V='.$build,
|
|
|
|
'PN=Windows.Appraiser.'.$arch.'&Repairable=1&V='.$build,
|
|
|
|
'PN=Windows.AppraiserData.'.$arch.'&Repairable=1&V='.$build,
|
|
|
|
'PN=Windows.EmergencyUpdate.'.$arch.'&Repairable=1&V='.$build,
|
|
|
|
'PN=Windows.OOBE.'.$arch.'&IsWindowsOOBE=1&Repairable=1&V='.$build,
|
|
|
|
'PN=Windows.UpdateStackPackage.'.$arch.'&Name=Update Stack Package&Repairable=1&V='.$build,
|
|
|
|
'PN=Hammer.'.$arch.'&Source=UpdateOrchestrator&V=0.0.0.0',
|
|
|
|
'PN=MSRT.'.$arch.'&Source=UpdateOrchestrator&V=0.0.0.0',
|
|
|
|
'PN=SedimentPack.'.$arch.'&Source=UpdateOrchestrator&V=0.0.0.0',
|
2018-01-13 19:59:05 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$callerAttrib = array(
|
|
|
|
'Id=UpdateOrchestrator',
|
2018-08-10 23:55:45 +02:00
|
|
|
'SheddingAware=1',
|
2018-01-13 19:59:05 +01:00
|
|
|
'Interactive=1',
|
|
|
|
'IsSeeker=1',
|
|
|
|
);
|
|
|
|
|
2018-09-21 18:01:12 +02:00
|
|
|
$products = htmlentities(implode(';', $products));
|
|
|
|
$callerAttrib = htmlentities('E:'.implode('&', $callerAttrib));
|
2018-01-13 19:59:05 +01:00
|
|
|
|
|
|
|
$deviceAttributes = composeDeviceAttributes(
|
|
|
|
$flight,
|
|
|
|
$ring,
|
|
|
|
$build,
|
2018-04-29 21:33:19 +02:00
|
|
|
$arch,
|
|
|
|
$sku
|
2018-01-13 19:59:05 +01:00
|
|
|
);
|
2017-10-23 22:53:33 +02:00
|
|
|
|
2018-12-13 23:18:34 +01:00
|
|
|
return '<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><a:Action s:mustUnderstand="1">http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/SyncUpdates</a:Action><a:MessageID>urn:uuid:'.$uuid.'</a:MessageID><a:To s:mustUnderstand="1">https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx</a:To><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><Created>'.$created.'</Created><Expires>'.$expires.'</Expires></Timestamp><wuws:WindowsUpdateTicketsToken wsu:id="ClientMSA" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wuws="http://schemas.microsoft.com/msus/2014/10/WindowsUpdateAuthorization"><TicketType Name="MSA" Version="1.0" Policy="MBI_SSL"><Device>'.$device.'</Device></TicketType></wuws:WindowsUpdateTicketsToken></o:Security></s:Header><s:Body><SyncUpdates xmlns="http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService"><cookie><Expiration>'.$cookieExpires.'</Expiration><EncryptedData>'.$encData.'</EncryptedData></cookie><parameters><ExpressQuery>false</ExpressQuery><InstalledNonLeafUpdateIDs></InstalledNonLeafUpdateIDs><OtherCachedUpdateIDs></OtherCachedUpdateIDs><SkipSoftwareSync>false</SkipSoftwareSync><NeedTwoGroupOutOfScopeUpdates>true</NeedTwoGroupOutOfScopeUpdates><AlsoPerformRegularSync>true</AlsoPerformRegularSync><ComputerSpec/><ExtendedUpdateInfoParameters><XmlUpdateFragmentTypes><XmlUpdateFragmentType>Extended</XmlUpdateFragmentType><XmlUpdateFragmentType>LocalizedProperties</XmlUpdateFragmentType><XmlUpdateFragmentType>Eula</XmlUpdateFragmentType></XmlUpdateFragmentTypes><Locales><string>en-US</string></Locales></ExtendedUpdateInfoParameters><ClientPreferredLanguages></ClientPreferredLanguages><ProductsParameters><SyncCurrentVersionOnly>false</SyncCurrentVersionOnly><DeviceAttributes>'.$deviceAttributes.'</DeviceAttributes><CallerAttributes>'.$callerAttrib.'</CallerAttributes><Products>'.$products.'</Products></ProductsParameters></parameters></SyncUpdates></s:Body></s:Envelope>';
|
2017-09-22 21:24:31 +02:00
|
|
|
}
|
2018-12-13 21:19:51 +01:00
|
|
|
|
|
|
|
// Composes POST data for Get Cookie request
|
|
|
|
function composeGetCookieRequest($device) {
|
|
|
|
$uuid = genUUID();
|
|
|
|
|
|
|
|
$createdTime = time();
|
|
|
|
$expiresTime = $createdTime + 120;
|
|
|
|
|
|
|
|
$created = gmdate(DATE_W3C, $createdTime);
|
|
|
|
$expires = gmdate(DATE_W3C, $expiresTime);
|
|
|
|
|
|
|
|
return '<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><a:Action s:mustUnderstand="1">http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetCookie</a:Action><a:MessageID>urn:uuid:'.$uuid.'</a:MessageID><a:To s:mustUnderstand="1">https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx</a:To><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><Created>'.$created.'</Created><Expires>'.$expires.'</Expires></Timestamp><wuws:WindowsUpdateTicketsToken wsu:id="ClientMSA" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wuws="http://schemas.microsoft.com/msus/2014/10/WindowsUpdateAuthorization"><TicketType Name="MSA" Version="1.0" Policy="MBI_SSL"><Device>'.$device.'</Device></TicketType></wuws:WindowsUpdateTicketsToken></o:Security></s:Header><s:Body><GetCookie xmlns="http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService"><oldCookie><Expiration>'.$created.'</Expiration></oldCookie><lastChange>'.$created.'</lastChange><currentTime>'.$created.'</currentTime><protocolVersion>2.0</protocolVersion></GetCookie></s:Body></s:Envelope>';
|
|
|
|
}
|
2017-09-22 21:24:31 +02:00
|
|
|
?>
|