thank the game to be boring, no more outdated hotfixed strings

This commit is contained in:
iAmAsval 2020-01-16 20:40:42 +01:00
parent ce9911e7fc
commit 830e45d58f
9 changed files with 115 additions and 14 deletions

View File

@ -182,6 +182,12 @@
}
}</value>
</setting>
<setting name="ELauncherToken" serializeAs="String">
<value />
</setting>
<setting name="ELauncherExpiration" serializeAs="String">
<value>0</value>
</setting>
</FModel.Properties.Settings>
</userSettings>
<runtime>

View File

@ -242,6 +242,8 @@
<Compile Include="Methods\Assets\IconCreator\Rarity.cs" />
<Compile Include="Methods\Assets\IconCreator\WeaponID\IconAmmoData.cs" />
<Compile Include="Methods\Assets\IconCreator\WeaponID\WeaponStats.cs" />
<Compile Include="Methods\Auth\AuthFlow.cs" />
<Compile Include="Methods\Auth\Requests.cs" />
<Compile Include="Methods\BackupsManager\RegisterDownloadedBackups.cs" />
<Compile Include="Methods\FindReplace\FindReplace.cs" />
<Compile Include="Methods\FindReplace\FindReplaceDialog.xaml.cs">

View File

@ -30,7 +30,7 @@ namespace FModel.Methods.AESManager
if (PAKEntries.PAKEntriesList != null && PAKEntries.PAKEntriesList.Any())
{
string KeysFromBen = EndpointsUtility.GetKeysFromBen();
string KeysFromBen = EndpointsUtility.GetKeysFromBen(reload);
if (!string.IsNullOrEmpty(KeysFromBen))
{
Dictionary<string, string> KeysDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(KeysFromBen);

View File

@ -1,3 +1,4 @@
using FModel.Methods.Auth;
using FModel.Methods.Utilities;
using PakReader;
using System;
@ -144,16 +145,20 @@ namespace FModel.Methods.Assets
public static void SetHotfixedLocResDict()
{
string pdd = Path.GetFullPath(Path.Combine(FProp.Default.FPak_Path, @"..\..\PersistentDownloadDir\EMS\"));
if (File.Exists(pdd + "a22d837b6a2b46349421259c0a5411bf"))
if (!FProp.Default.ELauncherToken.StartsWith("eg1~") || AuthFlow.IsLauncherTokenExpired())
AuthFlow.SetOAuthLauncherToken();
if (!AuthFlow.IsLauncherTokenExpired() && FProp.Default.ELauncherToken.StartsWith("eg1~"))
{
DebugHelper.WriteLine(".PAKs: Populating hotfixed string dictionary at " + pdd + "a22d837b6a2b46349421259c0a5411bf");
HotfixLocResDict = new Dictionary<string, Dictionary<string, Dictionary<string, Dictionary<string, string>>>>();
using (StreamReader sr = new StreamReader(File.Open(pdd + "a22d837b6a2b46349421259c0a5411bf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
string response = Requests.GetLauncherEndpoint("https://fortnite-public-service-prod11.ol.epicgames.com/fortnite/api/cloudstorage/system/a22d837b6a2b46349421259c0a5411bf");
if (!string.IsNullOrEmpty(response))
{
while (!sr.EndOfStream)
string[] lines = response.Split('\n');
DebugHelper.WriteLine(".PAKs: Populating hotfixed string dictionary");
HotfixLocResDict = new Dictionary<string, Dictionary<string, Dictionary<string, Dictionary<string, string>>>>();
foreach (string line in lines)
{
string line = sr.ReadLine();
if (line.StartsWith("+TextReplacements=(Category=Game,"))
{
string txtNamespace = GetValueFromParam(line, "Namespace=\"", "\",");
@ -188,11 +193,9 @@ namespace FModel.Methods.Assets
}
}
}
DebugHelper.WriteLine(".PAKs: Populated hotfixed string dictionary");
}
DebugHelper.WriteLine(".PAKs: Populated hotfixed string dictionary");
}
else
DebugHelper.WriteLine(".PAKs: No such file or directory " + pdd + "a22d837b6a2b46349421259c0a5411bf");
}
private static string GetValueFromParam(string fullLine, string startWith, string endWith)

View File

@ -0,0 +1,40 @@
using Newtonsoft.Json;
using RestSharp;
using System;
namespace FModel.Methods.Auth
{
static class AuthFlow
{
private const string _EPIC_OAUTH_URL = "https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token";
public static void SetOAuthLauncherToken()
{
var oauthClient = new RestClient(_EPIC_OAUTH_URL);
var oauthRes = oauthClient.Execute(
new RestRequest(Method.POST)
.AddHeader("Content-Type", "application/x-www-form-urlencoded")
.AddHeader("Authorization", "basic MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE=")
.AddParameter("grant_type", "client_credentials")
.AddParameter("token_type", "eg1"));
var response = JsonConvert.DeserializeObject<dynamic>(oauthRes.Content);
var launcher_access_token = response["access_token"];
var launcher_expires_in = response["expires_in"];
Properties.Settings.Default.ELauncherToken = launcher_access_token;
Properties.Settings.Default.ELauncherExpiration = DateTimeOffset.Now.AddSeconds(Convert.ToDouble(launcher_expires_in)).ToUnixTimeMilliseconds();
Properties.Settings.Default.Save();
}
public static bool IsLauncherTokenExpired()
{
long currentTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
if ((currentTime - 60000) >= Properties.Settings.Default.ELauncherExpiration)
{
return true;
}
return false;
}
}
}

View File

@ -0,0 +1,20 @@
using RestSharp;
namespace FModel.Methods.Auth
{
static class Requests
{
public static string GetLauncherEndpoint(string url)
{
var client = new RestClient(url);
var request = new RestRequest(Method.GET)
.AddHeader("Authorization", "bearer " + Properties.Settings.Default.ELauncherToken);
IRestResponse reqRes = client.Execute(request);
if (reqRes.StatusCode == System.Net.HttpStatusCode.OK)
return reqRes.Content;
return string.Empty;
}
}
}

View File

@ -76,14 +76,14 @@ namespace FModel.Methods.Utilities
}
}
public static string GetKeysFromBen()
public static string GetKeysFromBen(bool reload)
{
if (DLLImport.IsInternetAvailable())
{
string EndpointContent = GetEndpoint(BENBOT_AES);
if (!string.IsNullOrEmpty(EndpointContent))
{
if (string.IsNullOrEmpty(FProp.Default.FPak_MainAES))
if (string.IsNullOrEmpty(FProp.Default.FPak_MainAES) || reload)
{
JToken mainKeyToken = JObject.Parse(EndpointContent).SelectToken("mainKey");
if (mainKeyToken != null)

View File

@ -12,7 +12,7 @@ namespace FModel.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -400,5 +400,29 @@ namespace FModel.Properties {
this["FUM_AssetsType"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ELauncherToken {
get {
return ((string)(this["ELauncherToken"]));
}
set {
this["ELauncherToken"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public long ELauncherExpiration {
get {
return ((long)(this["ELauncherExpiration"]));
}
set {
this["ELauncherExpiration"] = value;
}
}
}
}

View File

@ -174,5 +174,11 @@
}
}</Value>
</Setting>
<Setting Name="ELauncherToken" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ELauncherExpiration" Type="System.Int64" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>