Skip to content

Instantly share code, notes, and snippets.

@daCyuubi
Last active June 14, 2021 17:49
Show Gist options
  • Save daCyuubi/fa59cabe76a338793680384a7db62e48 to your computer and use it in GitHub Desktop.
Save daCyuubi/fa59cabe76a338793680384a7db62e48 to your computer and use it in GitHub Desktop.
Fortnite "1.8" custom rules for Fiddler (V2), now in C#
// Hi there, before you can install this FiddlerScript please follow this guide:
// 1.) Go into "Tools -> Options" select the "Scripting" tab and then set the "Language" to "C#", this is required.
// 2.) Select the "HTTPS" tab and then tick the "Decrypt HTTPS traffic" checkbox, Fiddler will bring up a few prompts which you'll want to hit "OK" to.
// 3.) Restart Fiddler, select the "FiddlerScript" tab and remove the code inside it. (CTRL+A, Backspace)
// 4.) Copy and paste my FiddlerScript into the "FiddlerScript" tab, hit "Save Script" and you're done!
//
// Unfortunately, there is some downsides to this new approach:
// 1.) If you sign into Fortnite, you'll get kicked out of EGL and you'll need to sign back in. (I can fix this issue, but I'm just lazy.)
// 2.) You must have EGL installed and be signed into it, otherwise you'll be unable to sign into Fortnite.
//
// Notes:
// 1.) Please do not reupload/redistribute this FiddlerScript, instead link directly to this GitHub gist.
// 2.) Please credit me if you use this FiddlerScript in a video, it's not a requirement but it'd be appreciated.
// 3.) If you paid for this FiddlerScript, you have been scammed. Please, immediately refund your money.
using System;
using Fiddler;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;
namespace Fiddler
{
public static class Handlers
{
private const string LAUNCHER_CLIENT = "34a02cf8f4414e29b15921876da36f9a";
private const string LAUNCHER_SECRET = "daafbccc737745039dffe53d94fc76cf";
private const string FORTNITE_CLIENT = "ec684b8c687f479fadea3cb2ad83f5c6";
private const string FORTNITE_SECRET = "e1f31c211f28413186262d37a13fc84d";
public static void OnBeforeRequest(Session oSession)
{
oSession.utilDecodeRequest();
// Account service (OAuth)
if (oSession.hostname.Contains("account") && oSession.hostname.Contains(".epicgames.com"))
{
if (oSession.PathAndQuery.Contains("/account/api/oauth/token"))
{
if (oSession.GetRequestBodyAsString().Contains("grant_type=password"))
{
var rememberMeData = GetRememberMeData();
if (string.IsNullOrEmpty(rememberMeData))
MessageBox.Show("Epic Games Launcher is required to sign-in to Fortnite, please install Epic Games Launcher (if you haven't already) and sign-in to it.");
else
{
// To keep this Linq-free, we'll have to hack this together.
var rememberMeToken = rememberMeData.Split(new string[] { "Token\":\"" }, StringSplitOptions.None)[1].Split('"')[0];
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
client.Headers[HttpRequestHeader.Authorization] = "basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(LAUNCHER_CLIENT + ":" + LAUNCHER_SECRET));
var oauthResponse = client.UploadString("https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token", "grant_type=refresh_token&refresh_token=" + Uri.EscapeUriString(rememberMeToken));
var oauthAccessToken = oauthResponse.Split(new string[] { "access_token\":\"" }, StringSplitOptions.None)[1].Split('"')[0];
client.Headers.Remove(HttpRequestHeader.ContentType);
client.Headers[HttpRequestHeader.Authorization] = "bearer " + oauthAccessToken;
var exchangeResponse = client.DownloadString("https://account-public-service-prod.ol.epicgames.com/account/api/oauth/exchange");
var exchangeCode = exchangeResponse.Split(new string[] { "code\":\"" }, StringSplitOptions.None)[1].Split('"')[0];
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
client.Headers[HttpRequestHeader.Authorization] = "basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(FORTNITE_CLIENT + ":" + FORTNITE_SECRET));
var oauthFortniteResponse = client.UploadString("https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token", "grant_type=exchange_code&exchange_code=" + exchangeCode + "&includePerms=true&token_type=eg1");
oSession.utilCreateResponseAndBypassServer();
oSession.utilSetResponseBody(oauthFortniteResponse);
oSession.oResponse.headers.Add("Content-Type", "application/json");
}
}
}
}
}
// Fortnite service
if (oSession.hostname.Contains("fortnite") && oSession.hostname.Contains(".epicgames.com"))
{
// This is a hack, but oh well...
if (oSession.PathAndQuery.Contains("profileId=profile0"))
oSession.url = oSession.url.Replace("profileId=profile0","profileId=campaign");
}
}
public static void OnBeforeResponse(Session oSession)
{
oSession.utilDecodeResponse();
if (oSession.hostname.Contains("fortnite") && oSession.hostname.Contains(".epicgames.com"))
{
// Required to stub these responses out, unfortunately.
if (oSession.PathAndQuery.Contains("profileId=collection_book_people0") ||
oSession.PathAndQuery.Contains("/fortnite/api/game/v2/world/info"))
oSession.utilSetResponseBody("{}");
}
}
private static string GetRememberMeData()
{
var eglSettingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "EpicGamesLauncher\\Saved\\Config\\Windows\\GameUserSettings.ini");
if (!File.Exists(eglSettingsPath))
return string.Empty;
var isInRememberMe = false;
var eglSettingsLines = File.ReadAllLines(eglSettingsPath);
foreach (var eglSettingsLine in eglSettingsLines)
{
if (eglSettingsLine.Contains("[RememberMe]"))
isInRememberMe = true; // This is incredibly scuffed, but whatever.
if (eglSettingsLine.Contains("Data=") && isInRememberMe)
{
var eglSettingsDataBytes = Convert.FromBase64String(eglSettingsLine.Replace("Data=", string.Empty));
return Encoding.UTF8.GetString(eglSettingsDataBytes);
}
}
return string.Empty;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment