smh new files were ignored

This commit is contained in:
Asval 2019-05-25 21:34:20 +02:00
parent 697be07c6a
commit 5ba2a9ea0a
5 changed files with 378 additions and 0 deletions

View File

@ -0,0 +1,103 @@
using FModel.Methods.BackupPAKs.Parser.AccessTokenParser;
using FModel.Methods.BackupPAKs.Parser.AccessCodeParser;
using FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser;
using RestSharp;
using System;
using Newtonsoft.Json.Linq;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
namespace FModel
{
class DynamicPAKs
{
public static string GetEndpoint(string url, bool auth)
{
string content = string.Empty;
try
{
RestClient EndpointClient = new RestClient(url);
RestRequest EndpointRequest = new RestRequest(Method.GET);
if (auth)
{
EndpointRequest.AddHeader("Authorization", "bearer " + getExchangeToken(getAccessCode(getAccessToken(Properties.Settings.Default.eEmail, Properties.Settings.Default.ePassword))));
}
var response = EndpointClient.Execute(EndpointRequest);
content = JToken.Parse(response.Content).ToString(Newtonsoft.Json.Formatting.Indented);
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("[ERROR] ");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(ex.Message);
}
return content;
}
private static string getAccessToken(string email, string password)
{
RestClient getAccessTokenClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token");
RestRequest getAccessTokenRequest = new RestRequest(Method.POST);
getAccessTokenRequest.AddParameter("grant_type", "password");
getAccessTokenRequest.AddParameter("username", email);
getAccessTokenRequest.AddParameter("password", password);
getAccessTokenRequest.AddParameter("includePerms", "true");
getAccessTokenRequest.AddHeader("Authorization", "basic MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE=");
getAccessTokenRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
return AccessTokenParser.FromJson(getAccessTokenClient.Execute(getAccessTokenRequest).Content).AccessToken;
}
private static string getAccessCode(string accessToken)
{
RestClient getAccessCodeClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/exchange");
RestRequest getAccessCodeRequest = new RestRequest(Method.GET);
getAccessCodeRequest.AddHeader("Authorization", "bearer " + accessToken);
return AccessCodeParser.FromJson(getAccessCodeClient.Execute(getAccessCodeRequest).Content).Code;
}
private static string getExchangeToken(string accessCode)
{
RestClient getExchangeTokenClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token");
RestRequest getExchangeTokenRequest = new RestRequest(Method.POST);
getExchangeTokenRequest.AddHeader("Authorization", "basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ=");
getExchangeTokenRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
getExchangeTokenRequest.AddParameter("grant_type", "exchange_code");
getExchangeTokenRequest.AddParameter("exchange_code", accessCode);
getExchangeTokenRequest.AddParameter("includePerms", true);
getExchangeTokenRequest.AddParameter("token_type", "eg1");
return ExchangeTokenParser.FromJson(getExchangeTokenClient.Execute(getExchangeTokenRequest).Content).AccessToken;
}
private static IEnumerable<string> SplitGuid(string str, int chunkSize)
{
return Enumerable.Range(0, str.Length / chunkSize)
.Select(i => str.Substring(i * chunkSize, chunkSize));
}
public static string getPakGuidFromKeychain(string[] KeychainPart)
{
IEnumerable<string> guid = SplitGuid(KeychainPart[0], 8);
int count = 0;
string pakguid = string.Empty;
foreach (string p in guid)
{
count += 1;
if (count != guid.Count())
pakguid += (uint)int.Parse(p, NumberStyles.HexNumber) + "-";
else
pakguid += (uint)int.Parse(p, NumberStyles.HexNumber);
}
return pakguid;
}
}
}

View File

@ -0,0 +1,37 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using FModel.Methods.BackupPAKs.Parser.AESKeyParser;
//
// var aesKeyParser = AesKeyParser.FromJson(jsonString);
namespace FModel.Methods.BackupPAKs.Parser.AESKeyParser
{
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public class AesKeyParser
{
public static string[] FromJson(string json) => JsonConvert.DeserializeObject<string[]>(json, FModel.Methods.BackupPAKs.Parser.AESKeyParser.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this string[] self) => JsonConvert.SerializeObject(self, FModel.Methods.BackupPAKs.Parser.AESKeyParser.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}

View File

@ -0,0 +1,49 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using FModel.Methods.BackupPAKs.Parser.AccessCodeParser;
//
// var accessCodeParser = AccessCodeParser.FromJson(jsonString);
namespace FModel.Methods.BackupPAKs.Parser.AccessCodeParser
{
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class AccessCodeParser
{
[JsonProperty("expiresInSeconds")]
public long ExpiresInSeconds { get; set; }
[JsonProperty("code")]
public string Code { get; set; }
[JsonProperty("creatingClientId")]
public string CreatingClientId { get; set; }
}
public partial class AccessCodeParser
{
public static AccessCodeParser FromJson(string json) => JsonConvert.DeserializeObject<AccessCodeParser>(json, FModel.Methods.BackupPAKs.Parser.AccessCodeParser.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this AccessCodeParser self) => JsonConvert.SerializeObject(self, FModel.Methods.BackupPAKs.Parser.AccessCodeParser.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}

View File

@ -0,0 +1,96 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using FModel.Methods.BackupPAKs.Parser.AccessTokenParser;
//
// var accessTokenParser = AccessTokenParser.FromJson(jsonString);
namespace FModel.Methods.BackupPAKs.Parser.AccessTokenParser
{
using System;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class AccessTokenParser
{
[JsonProperty("access_token")]
public string AccessToken { get; set; }
[JsonProperty("expires_in")]
public long ExpiresIn { get; set; }
[JsonProperty("expires_at")]
public DateTimeOffset ExpiresAt { get; set; }
[JsonProperty("token_type")]
public string TokenType { get; set; }
[JsonProperty("refresh_token")]
public string RefreshToken { get; set; }
[JsonProperty("refresh_expires")]
public long RefreshExpires { get; set; }
[JsonProperty("refresh_expires_at")]
public DateTimeOffset RefreshExpiresAt { get; set; }
[JsonProperty("account_id")]
public string AccountId { get; set; }
[JsonProperty("client_id")]
public string ClientId { get; set; }
[JsonProperty("internal_client")]
public bool InternalClient { get; set; }
[JsonProperty("client_service")]
public string ClientService { get; set; }
[JsonProperty("lastPasswordValidation")]
public DateTimeOffset LastPasswordValidation { get; set; }
[JsonProperty("perms")]
public Perm[] Perms { get; set; }
[JsonProperty("app")]
public string App { get; set; }
[JsonProperty("in_app_id")]
public string InAppId { get; set; }
}
public partial class Perm
{
[JsonProperty("resource")]
public string Resource { get; set; }
[JsonProperty("action")]
public long Action { get; set; }
}
public partial class AccessTokenParser
{
public static AccessTokenParser FromJson(string json) => JsonConvert.DeserializeObject<AccessTokenParser>(json, FModel.Methods.BackupPAKs.Parser.AccessTokenParser.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this AccessTokenParser self) => JsonConvert.SerializeObject(self, FModel.Methods.BackupPAKs.Parser.AccessTokenParser.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}

View File

@ -0,0 +1,93 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser;
//
// var exchangeTokenParser = ExchangeTokenParser.FromJson(jsonString);
namespace FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser
{
using System;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class ExchangeTokenParser
{
[JsonProperty("access_token")]
public string AccessToken { get; set; }
[JsonProperty("expires_in")]
public long ExpiresIn { get; set; }
[JsonProperty("expires_at")]
public DateTimeOffset ExpiresAt { get; set; }
[JsonProperty("token_type")]
public string TokenType { get; set; }
[JsonProperty("refresh_token")]
public string RefreshToken { get; set; }
[JsonProperty("refresh_expires")]
public long RefreshExpires { get; set; }
[JsonProperty("refresh_expires_at")]
public DateTimeOffset RefreshExpiresAt { get; set; }
[JsonProperty("account_id")]
public string AccountId { get; set; }
[JsonProperty("client_id")]
public string ClientId { get; set; }
[JsonProperty("internal_client")]
public bool InternalClient { get; set; }
[JsonProperty("client_service")]
public string ClientService { get; set; }
[JsonProperty("perms")]
public Perm[] Perms { get; set; }
[JsonProperty("app")]
public string App { get; set; }
[JsonProperty("in_app_id")]
public string InAppId { get; set; }
}
public partial class Perm
{
[JsonProperty("resource")]
public string Resource { get; set; }
[JsonProperty("action")]
public long Action { get; set; }
}
public partial class ExchangeTokenParser
{
public static ExchangeTokenParser FromJson(string json) => JsonConvert.DeserializeObject<ExchangeTokenParser>(json, FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this ExchangeTokenParser self) => JsonConvert.SerializeObject(self, FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}