-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_3auth_state.ps1
38 lines (28 loc) · 1020 Bytes
/
fetch_3auth_state.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
param(
[Parameter(Mandatory)]
[ValidateSet("xbl", "battle", "steam", "psn")]
[string]
$Platform,
[switch]
$NotCompileUmbrellaState
)
$links = @{
thirdPartyAuth = "https://profile.callofduty.com/cod/thirdPartyAuth/init"
}
$stateResponse = Invoke-WebRequest "$($links.thirdPartyAuth)/$Platform" -MaximumRedirection 0 -SkipHttpErrorCheck 2> $null
$umbrellaLocation = $stateResponse.Headers.Location
if ($null -eq $umbrellaLocation) {
Write-Host "Can't fetch Umbrella location: $($stateResponse.StatusCode)"
return $null
}
$umbrellaData = [System.Web.HttpUtility]::ParseQueryString([uri]::new($umbrellaLocation).Query)
$UmbrellaState = @{
client = $umbrellaData.Get("client")
client_state = $umbrellaData.Get("state")
return_url = $umbrellaData.Get("returnURL")
}
if ($NotCompileUmbrellaState) {
return $UmbrellaState
}
$jsonState = ConvertTo-Json $UmbrellaState
return [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($jsonState))