Change method of fetching updates to more foolproof
Fixes fetching of Release Preview for Fall Creators Update
This commit is contained in:
		
							
								
								
									
										47
									
								
								fetchupd.php
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								fetchupd.php
									
									
									
									
									
								
							| @@ -19,7 +19,7 @@ require_once dirname(__FILE__).'/shared/main.php'; | ||||
| require_once dirname(__FILE__).'/shared/requests.php'; | ||||
| require_once dirname(__FILE__).'/listid.php'; | ||||
|  | ||||
| function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build = '16251') { | ||||
| function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build = '16251', $minor = '0') { | ||||
|     uupApiPrintBrand(); | ||||
|  | ||||
|     $arch = strtolower($arch); | ||||
| @@ -47,9 +47,13 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build | ||||
|         return array('error' => 'ILLEGAL_BUILD'); | ||||
|     } | ||||
|  | ||||
|     if($minor < 0 || $minor > 65536) { | ||||
|         return array('error' => 'ILLEGAL_MINOR'); | ||||
|     } | ||||
|  | ||||
|     if($flight == 'Active' && $ring == 'RP') $flight = 'Current'; | ||||
|  | ||||
|     $build = '10.0.'.$build.'.0'; | ||||
|     $build = '10.0.'.$build.'.'.$minor; | ||||
|  | ||||
|     consoleLogger('Fetching information from the server...'); | ||||
|     $postData = composeFetchUpdRequest(uupDevice(), uupEncryptedData(), $arch, $flight, $ring, $build); | ||||
| @@ -59,7 +63,30 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build | ||||
|     consoleLogger('Information was successfully fetched.'); | ||||
|  | ||||
|     consoleLogger('Checking build information...'); | ||||
|     preg_match('/<Files>.*<\/Files>/', $out, $fileList); | ||||
|     preg_match_all('/<UpdateInfo>.*?<\/UpdateInfo>/', $out, $updateInfos); | ||||
|     $updateInfo = preg_grep('/<Action>Install<\/Action>/', $updateInfos[0]); | ||||
|     sort($updateInfo); | ||||
|  | ||||
|     if(empty($updateInfo[0])) { | ||||
|         consoleLogger('An error has occurred'); | ||||
|         return array('error' => 'NO_UPDATE_FOUND'); | ||||
|     } | ||||
|  | ||||
|     $updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo[0]); | ||||
|  | ||||
|     $updates = preg_replace('/<Update>/', "\n<Update>", $out); | ||||
|     preg_match_all('/<Update>.*<\/Update>/', $updates, $updates); | ||||
|  | ||||
|     $updateMeta = preg_grep('/<ID>'.$updateNumId.'<\/ID>/', $updates[0]); | ||||
|     sort($updateMeta); | ||||
|  | ||||
|     $updateFiles = preg_grep('/<Files>.*<\/Files>/', $updateMeta); | ||||
|     sort($updateFiles); | ||||
|  | ||||
|     $updateTitle = preg_grep('/<Title>.*<\/Title>/', $updateMeta); | ||||
|     sort($updateTitle); | ||||
|  | ||||
|     preg_match('/<Files>.*<\/Files>/', $updateFiles[0], $fileList); | ||||
|     if(empty($fileList[0])) { | ||||
|         consoleLogger('An error has occurred'); | ||||
|         return array('error' => 'EMPTY_FILELIST'); | ||||
| @@ -67,11 +94,11 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build | ||||
|  | ||||
|     preg_match('/<FlightMetadata>.*?<Relationships>/', $out, $out2); | ||||
|  | ||||
|     preg_match('/"BuildFlightVersion":".*"}/', $out2[0], $foundBuild); | ||||
|     $foundBuild = preg_replace('/"BuildFlightVersion":"10\.0\.|"}/', '', $foundBuild[0]); | ||||
|     preg_match_all('/<Title>.*?<\/Title>/i', $out, $updateTitle); | ||||
|     $updateTitle = preg_replace('/<Title>|<\/Title>/i', '', $updateTitle[0]); | ||||
|     $updateTitle = preg_grep('/'.$foundBuild.'/', $updateTitle); | ||||
|     preg_match('/Version\=".*?"/', $updateInfo[0], $foundBuild); | ||||
|     $foundBuild = preg_replace('/Version="10\.0\.|"/', '', $foundBuild[0]); | ||||
|  | ||||
|     preg_match('/<Title>.*?<\/Title>/i', $updateTitle[0], $updateTitle); | ||||
|     $updateTitle = preg_replace('/<Title>|<\/Title>/i', '', $updateTitle); | ||||
|     sort($updateTitle); | ||||
|  | ||||
|     if(isset($updateTitle[0])) { | ||||
| @@ -80,9 +107,7 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build | ||||
|         $updateTitle = 'Windows 10 build '.$foundBuild; | ||||
|     } | ||||
|  | ||||
|     $out = preg_replace('/>/', ">\n", $out2[0]); | ||||
|  | ||||
|     preg_match('/UpdateID=".*?"/', $out, $updateId); | ||||
|     preg_match('/UpdateID=".*?"/', $updateInfo[0], $updateId); | ||||
|     $updateId = preg_replace('/UpdateID="|"$/', '', $updateId[0]); | ||||
|     consoleLogger('Successfully checked build information.'); | ||||
|     consoleLogger('BUILD: '.$updateTitle.' '.$arch); | ||||
|   | ||||
| @@ -2,7 +2,7 @@ UUP dump API | ||||
| ------------ | ||||
|  | ||||
| ### Functions | ||||
| #### fetchupd.php: `uupFetchUpd($arch, $ring, $flight, $build);` | ||||
| #### fetchupd.php: `uupFetchUpd($arch, $ring, $flight, $build, $minor);` | ||||
| Fetches latest update information from Windows Update servers. | ||||
|  | ||||
| Parameters: | ||||
| @@ -17,7 +17,10 @@ Parameters: | ||||
|    - **NOTE:** `Skip` is for `WIF` ring only. `Current` is for `RP` ring only. | ||||
|  | ||||
|  - `build` - Build number to use when fetching information | ||||
|    - **Supported values:** > 15063 and < 65536 | ||||
|    - **Supported values:** >= 15063 and <= 65536 | ||||
|  | ||||
|  - `minor` - Build minor to use when fetching information | ||||
|    - **Supported values:** >= 0 and <= 65536 | ||||
|  | ||||
| #### get.php: `uupGetFiles($updateId, $usePack, $desiredEdition);` | ||||
| Fetches files from `updateId` update and parses to array. | ||||
| @@ -75,6 +78,8 @@ Parameters: | ||||
|  - UNKNOWN_FLIGHT | ||||
|  - UNKNOWN_COMBINATION | ||||
|  - ILLEGAL_BUILD | ||||
|  - ILLEGAL_MINOR | ||||
|  - NO_UPDATE_FOUND | ||||
|  - EMPTY_FILELIST | ||||
|  | ||||
| **get.php** | ||||
|   | ||||
| @@ -16,7 +16,7 @@ limitations under the License. | ||||
| */ | ||||
|  | ||||
| function uupApiVersion() { | ||||
|     return '1.1.2'; | ||||
|     return '1.2.0'; | ||||
| } | ||||
|  | ||||
| function uupApiPrintBrand() { | ||||
|   | ||||
| @@ -24,6 +24,6 @@ function composeFileGetRequest($updateId, $device, $info) { | ||||
| // 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 '<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>2017-01-01T01:00:00.000Z</Created><Expires>2020-01-01T02:00:00.000Z</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>2045-04-07T12:38:34Z</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><string>pl</string></Locales></ExtendedUpdateInfoParameters><ClientPreferredLanguages><string>pl</string></ClientPreferredLanguages><ProductsParameters><SyncCurrentVersionOnly>false</SyncCurrentVersionOnly><DeviceAttributes>App=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;</DeviceAttributes><CallerAttributes>Interactive=1;IsSeeker=0;</CallerAttributes><Products>PN=Client.OS.rs2.'.$arch.'&Branch=rs_prerelease&PrimaryOSProduct=1&V='.$build.';</Products></ProductsParameters></parameters></SyncUpdates></s:Body></s:Envelope>'; | ||||
|     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>2017-01-01T01:00:00.000Z</Created><Expires>2020-01-01T02:00:00.000Z</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>2045-04-07T12:38:34Z</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>App=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;</DeviceAttributes><CallerAttributes>Interactive=1;IsSeeker=0;</CallerAttributes><Products>PN=Client.OS.rs2.'.$arch.'&Branch=rs_prerelease&PrimaryOSProduct=1&V='.$build.';</Products></ProductsParameters></parameters></SyncUpdates></s:Body></s:Envelope>'; | ||||
| } | ||||
| ?> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user