Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5bd481eb1e | |||
| 4559b9d4ec | |||
| de418a6568 | |||
| 2bf8407640 | |||
| a8b5e0148f | |||
| 50413eb420 | |||
| ea49c39e53 | |||
| f599a9a648 | |||
| b8b24a5c30 | |||
| 4a71bc6f1b | |||
| cfd52b8e05 | |||
| b2ca193aa4 | |||
| 491daebf06 | |||
| 9799c2babe | |||
| 27b8a0e497 | |||
| 3f9409b8c6 | |||
| 1fdc7450cd | |||
| 75338b10ff | |||
| 5e8f059c49 | |||
| 11a9447e05 | |||
| 911c4d199a | |||
| 167e5ee696 | |||
| 7e6797b6c7 | |||
| c8b3104b4b | |||
| 785d4a3ff2 | |||
| c09ce8b02a | |||
| 0af818fc0f | |||
| 6e62bcb1dc | |||
| 1a05ef2742 | |||
| 642c1c80fa | |||
| 32525c1566 | |||
| 75171b4557 | |||
| fe71decd38 | |||
| acfdf7b3ef | |||
| e8d387e520 | |||
| 03a1841b8e | |||
| e61c20bb5a | |||
| 105f8b6df0 | |||
| 0300ced79c | |||
| 83ac8615ba | |||
| 697bff9752 |
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"Campers": [
|
"Campers": [
|
||||||
"Father_Key_Card",
|
|
||||||
"FireflyLantern",
|
"FireflyLantern",
|
||||||
"Item_Camper_AlexsToolbox",
|
"Item_Camper_AlexsToolbox",
|
||||||
"Item_Camper_AnniversaryToolbox",
|
"Item_Camper_AnniversaryToolbox",
|
||||||
@@ -25,7 +24,6 @@
|
|||||||
"Item_Camper_JerryCan_Spring2025",
|
"Item_Camper_JerryCan_Spring2025",
|
||||||
"Item_Camper_K29InfectionRemover",
|
"Item_Camper_K29InfectionRemover",
|
||||||
"Item_Camper_K32Emp",
|
"Item_Camper_K32Emp",
|
||||||
"Item_Camper_K33Turret",
|
|
||||||
"Item_Camper_K36MagicItem_Boots",
|
"Item_Camper_K36MagicItem_Boots",
|
||||||
"Item_Camper_K36MagicItem_Bracers",
|
"Item_Camper_K36MagicItem_Bracers",
|
||||||
"Item_Camper_K36MagicItem_VecnaEye",
|
"Item_Camper_K36MagicItem_VecnaEye",
|
||||||
@@ -44,7 +42,6 @@
|
|||||||
"Item_Camper_MedKit03",
|
"Item_Camper_MedKit03",
|
||||||
"Item_Camper_MedKit04",
|
"Item_Camper_MedKit04",
|
||||||
"Item_Camper_Medkit05",
|
"Item_Camper_Medkit05",
|
||||||
"Item_Camper_OnryoTape",
|
|
||||||
"Item_Camper_RainbowMap",
|
"Item_Camper_RainbowMap",
|
||||||
"Item_Camper_Toolbox",
|
"Item_Camper_Toolbox",
|
||||||
"Item_Camper_Toolbox_Anniversary2022",
|
"Item_Camper_Toolbox_Anniversary2022",
|
||||||
@@ -52,56 +49,10 @@
|
|||||||
"Item_Camper_VoidBomb_Halloween2024",
|
"Item_Camper_VoidBomb_Halloween2024",
|
||||||
"Item_Camper_WornoutToolbox",
|
"Item_Camper_WornoutToolbox",
|
||||||
"Item_FragileObject",
|
"Item_FragileObject",
|
||||||
"Item_LamentConfiguration",
|
|
||||||
"Item_Survivor_CalamariContaminationAntidote",
|
"Item_Survivor_CalamariContaminationAntidote",
|
||||||
"Item_Survivor_K41Mushroom",
|
"Item_Survivor_K41Mushroom",
|
||||||
"Item_Survivor_MakeshiftFogVial",
|
"Item_Survivor_MakeshiftFogVial",
|
||||||
"Item_Survivor_PrototypeFogVial",
|
"Item_Survivor_PrototypeFogVial",
|
||||||
"Item_Survivor_VigosFogVial"
|
"Item_Survivor_VigosFogVial"
|
||||||
],
|
|
||||||
"Slashers": [
|
|
||||||
"Item_Blighted_Serum",
|
|
||||||
"Item_Slasher_Beartrap",
|
|
||||||
"Item_Slasher_Blinker",
|
|
||||||
"Item_Slasher_Chainsaw",
|
|
||||||
"Item_Slasher_CloakBell",
|
|
||||||
"Item_Slasher_DreamInducer",
|
|
||||||
"Item_Slasher_Frenzy",
|
|
||||||
"Item_Slasher_GasBomb",
|
|
||||||
"Item_Slasher_GhostPower",
|
|
||||||
"Item_Slasher_HarpoonRifle",
|
|
||||||
"Item_Slasher_Hatchet",
|
|
||||||
"Item_Slasher_K21Power",
|
|
||||||
"Item_Slasher_K22Power",
|
|
||||||
"Item_Slasher_K24Power",
|
|
||||||
"Item_Slasher_K25Power",
|
|
||||||
"Item_Slasher_K26Power",
|
|
||||||
"Item_Slasher_K27Power",
|
|
||||||
"Item_Slasher_K28Power",
|
|
||||||
"Item_Slasher_K29Power",
|
|
||||||
"Item_Slasher_K30Power",
|
|
||||||
"Item_Slasher_K31Power",
|
|
||||||
"Item_Slasher_K32Power",
|
|
||||||
"Item_Slasher_K33Power",
|
|
||||||
"Item_Slasher_K34Power",
|
|
||||||
"Item_Slasher_K35Power",
|
|
||||||
"Item_Slasher_K36Power",
|
|
||||||
"Item_Slasher_K37Power",
|
|
||||||
"Item_Slasher_K38Power",
|
|
||||||
"Item_Slasher_K39Power",
|
|
||||||
"Item_Slasher_K40Power",
|
|
||||||
"Item_Slasher_K41Power",
|
|
||||||
"Item_Slasher_K42Power",
|
|
||||||
"Item_Slasher_Kanobo",
|
|
||||||
"Item_Slasher_Killer07Item",
|
|
||||||
"Item_Slasher_LFChainsaw",
|
|
||||||
"Item_Slasher_PhantomTrap",
|
|
||||||
"Item_Slasher_PhaseWalker",
|
|
||||||
"Item_Slasher_PlaguePower",
|
|
||||||
"Item_Slasher_QatarKillerPower",
|
|
||||||
"Item_Slasher_ReverseBearTrap",
|
|
||||||
"Item_Slasher_Stalker",
|
|
||||||
"Item_Slasher_ThrowingKnives",
|
|
||||||
"Item_Slasher_TormentMode"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+30
-28
@@ -32,6 +32,36 @@
|
|||||||
"TanagerWreath"
|
"TanagerWreath"
|
||||||
],
|
],
|
||||||
"Campers": [
|
"Campers": [
|
||||||
|
"BlackSaltStatuette",
|
||||||
|
"BogLaurelSachet",
|
||||||
|
"BoundEnvelope",
|
||||||
|
"ChalkPouch",
|
||||||
|
"CreamChalkPouch",
|
||||||
|
"CrispleafAmaranthSachet",
|
||||||
|
"EscapeCake",
|
||||||
|
"FragrantBogLaurel",
|
||||||
|
"FragrantCrispleafAmaranth",
|
||||||
|
"FragrantPrimroseBlossom",
|
||||||
|
"FragrantSweetWilliam",
|
||||||
|
"FreshBogLaurel",
|
||||||
|
"FreshCrispleafAmaranth",
|
||||||
|
"FreshPrimroseBlossom",
|
||||||
|
"FreshSweetWilliam",
|
||||||
|
"IvoryChalkPouch",
|
||||||
|
"PetrifiedOak",
|
||||||
|
"PrimroseBlossomSachet",
|
||||||
|
"SaltPouch",
|
||||||
|
"SealedEnvelope",
|
||||||
|
"ShinyCoin",
|
||||||
|
"ShroudofBinding",
|
||||||
|
"ShroudofUnion",
|
||||||
|
"SweetWilliamSachet",
|
||||||
|
"TarnishedCoin",
|
||||||
|
"VigosJarOfSaltyLips",
|
||||||
|
"VigosShroud",
|
||||||
|
"WhiteWard"
|
||||||
|
],
|
||||||
|
"All": [
|
||||||
"Anniversary2019Offering",
|
"Anniversary2019Offering",
|
||||||
"Anniversary2020Offering",
|
"Anniversary2020Offering",
|
||||||
"Anniversary2021Offering",
|
"Anniversary2021Offering",
|
||||||
@@ -41,33 +71,18 @@
|
|||||||
"Anniversary2025Offering",
|
"Anniversary2025Offering",
|
||||||
"AnnotatedBlueprint",
|
"AnnotatedBlueprint",
|
||||||
"AzarovKey",
|
"AzarovKey",
|
||||||
"BlackSaltStatuette",
|
|
||||||
"BloodiedBlueprint",
|
"BloodiedBlueprint",
|
||||||
"BloodyPartyStreamers",
|
"BloodyPartyStreamers",
|
||||||
"BogLaurelSachet",
|
|
||||||
"BoundEnvelope",
|
|
||||||
"CattleTag28",
|
"CattleTag28",
|
||||||
"ChalkPouch",
|
|
||||||
"CharredWeddingPhotograph",
|
"CharredWeddingPhotograph",
|
||||||
"ChildrensBook",
|
"ChildrensBook",
|
||||||
"ClearReagent",
|
"ClearReagent",
|
||||||
"ColdwindCattleTag81",
|
"ColdwindCattleTag81",
|
||||||
"CreamChalkPouch",
|
|
||||||
"CrescentMoonBouquet",
|
"CrescentMoonBouquet",
|
||||||
"CrispleafAmaranthSachet",
|
|
||||||
"DecrepitClapboard",
|
"DecrepitClapboard",
|
||||||
"EclipseThemeOffering",
|
"EclipseThemeOffering",
|
||||||
"EmergencyCertificate",
|
"EmergencyCertificate",
|
||||||
"EscapeCake",
|
|
||||||
"FaintReagent",
|
"FaintReagent",
|
||||||
"FragrantBogLaurel",
|
|
||||||
"FragrantCrispleafAmaranth",
|
|
||||||
"FragrantPrimroseBlossom",
|
|
||||||
"FragrantSweetWilliam",
|
|
||||||
"FreshBogLaurel",
|
|
||||||
"FreshCrispleafAmaranth",
|
|
||||||
"FreshPrimroseBlossom",
|
|
||||||
"FreshSweetWilliam",
|
|
||||||
"FullMoonBouquet",
|
"FullMoonBouquet",
|
||||||
"FumingCordage",
|
"FumingCordage",
|
||||||
"FumingWelcomeSign",
|
"FumingWelcomeSign",
|
||||||
@@ -79,7 +94,6 @@
|
|||||||
"HazyReagent",
|
"HazyReagent",
|
||||||
"HeartLocket",
|
"HeartLocket",
|
||||||
"IonThemeOffering",
|
"IonThemeOffering",
|
||||||
"IvoryChalkPouch",
|
|
||||||
"JapaneseCountrySide",
|
"JapaneseCountrySide",
|
||||||
"Jigsawpiece",
|
"Jigsawpiece",
|
||||||
"KenyaThemeOffering",
|
"KenyaThemeOffering",
|
||||||
@@ -91,8 +105,6 @@
|
|||||||
"NewMoonBouquet",
|
"NewMoonBouquet",
|
||||||
"PaintedRiverRock",
|
"PaintedRiverRock",
|
||||||
"PElliotLunacyTicket",
|
"PElliotLunacyTicket",
|
||||||
"PetrifiedOak",
|
|
||||||
"PrimroseBlossomSachet",
|
|
||||||
"PsychiatricAssessmentReport",
|
"PsychiatricAssessmentReport",
|
||||||
"QatarThemeOffering",
|
"QatarThemeOffering",
|
||||||
"QuantumThemeOffering",
|
"QuantumThemeOffering",
|
||||||
@@ -100,30 +112,20 @@
|
|||||||
"QuicheThemeOffering",
|
"QuicheThemeOffering",
|
||||||
"RedMoney",
|
"RedMoney",
|
||||||
"SacrificalWard",
|
"SacrificalWard",
|
||||||
"SaltPouch",
|
|
||||||
"SealedEnvelope",
|
|
||||||
"ShatteredGlasses",
|
"ShatteredGlasses",
|
||||||
"ShinyCoin",
|
|
||||||
"ShreddedPlate",
|
"ShreddedPlate",
|
||||||
"ShroudofBinding",
|
|
||||||
"ShroudofUnion",
|
|
||||||
"SignedLedgerPage",
|
"SignedLedgerPage",
|
||||||
"Spring2024Offering",
|
"Spring2024Offering",
|
||||||
"StrodeRealtyKey",
|
"StrodeRealtyKey",
|
||||||
"SummerOffering",
|
"SummerOffering",
|
||||||
"SweetWilliamSachet",
|
|
||||||
"TarnishedCoin",
|
|
||||||
"TheLastMask",
|
"TheLastMask",
|
||||||
"ThePiedPiper",
|
"ThePiedPiper",
|
||||||
"TornBlueprint",
|
"TornBlueprint",
|
||||||
"UkraineThemeOffering",
|
"UkraineThemeOffering",
|
||||||
"UmbraThemeOffering",
|
"UmbraThemeOffering",
|
||||||
"VigosBlueprint",
|
"VigosBlueprint",
|
||||||
"VigosJarOfSaltyLips",
|
|
||||||
"VigosShroud",
|
|
||||||
"VirginiaPlate",
|
"VirginiaPlate",
|
||||||
"WalesThemeOffering",
|
"WalesThemeOffering",
|
||||||
"WhiteWard",
|
|
||||||
"Winter2024Offering",
|
"Winter2024Offering",
|
||||||
"WormholeThemeOffering"
|
"WormholeThemeOffering"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
public static class Constants
|
||||||
|
{
|
||||||
|
public static readonly string MappingURL = "https://git.neru.rip/neru/UnlockedByDaylight/raw/branch/main/res/mappings/latest-xbox.usmap";
|
||||||
|
|
||||||
|
public static readonly string PackageName = "BehaviourInteractive.DeadbyDaylightWindows";
|
||||||
|
|
||||||
|
public static readonly string AESKey = "0x22B1639B548124925CF7B9CBAA09F9AC295FCF0324586D6B37EE1D42670B39B3";
|
||||||
|
|
||||||
|
public static readonly string[] BlacklistedCustomizationItems = ["NK_Torso01_Crew01Kraken"];
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
public enum EItemAvailability : byte
|
||||||
|
{
|
||||||
|
Available,
|
||||||
|
Disabled,
|
||||||
|
Retired
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ECustomizationCategory : byte
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
SurvivorHead,
|
||||||
|
SurvivorTorso,
|
||||||
|
SurvivorLegs,
|
||||||
|
KillerHead,
|
||||||
|
KillerBody,
|
||||||
|
KillerWeapon,
|
||||||
|
Outfits,
|
||||||
|
Charm,
|
||||||
|
Badge,
|
||||||
|
Banner,
|
||||||
|
PortraitBackground
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum EPlayerRole : byte
|
||||||
|
{
|
||||||
|
VE_None,
|
||||||
|
VE_Slasher,
|
||||||
|
VE_Camper,
|
||||||
|
VE_Observer
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct AvailabilityStruct
|
||||||
|
{
|
||||||
|
public EItemAvailability itemAvailability;
|
||||||
|
public string DLCId;
|
||||||
|
public string[] AdditionalDlcIds;
|
||||||
|
public Int32 CloudInventoryId;
|
||||||
|
public string CommunityId;
|
||||||
|
public bool _isLicensed;
|
||||||
|
}
|
||||||
@@ -0,0 +1,404 @@
|
|||||||
|
using CUE4Parse.Compression;
|
||||||
|
using CUE4Parse.Encryption.Aes;
|
||||||
|
using CUE4Parse.FileProvider;
|
||||||
|
using CUE4Parse.MappingsProvider;
|
||||||
|
using CUE4Parse.UE4.Assets.Exports;
|
||||||
|
using CUE4Parse.UE4.Assets.Exports.Actor;
|
||||||
|
using CUE4Parse.UE4.Assets.Exports.Engine;
|
||||||
|
using CUE4Parse.UE4.Assets.Exports.Texture;
|
||||||
|
using CUE4Parse.UE4.Assets.Objects;
|
||||||
|
using CUE4Parse.UE4.Assets.Objects.Properties;
|
||||||
|
using CUE4Parse.UE4.Objects.Core.Misc;
|
||||||
|
using CUE4Parse.UE4.Versions;
|
||||||
|
using CUE4Parse.UE4.VirtualFileSystem;
|
||||||
|
using CUE4Parse.UE4.Wwise.Plugins.MasteringSuite;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
class Dumper
|
||||||
|
{
|
||||||
|
private DefaultFileProvider? _provider = null;
|
||||||
|
private IAesVfsReader? _dataPak = null;
|
||||||
|
|
||||||
|
public async Task<bool> InitAsync()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* ensure mapping
|
||||||
|
*/
|
||||||
|
string mappingPath = Path.Combine(Path.GetTempPath(), "DeadByDaylight.usmap");
|
||||||
|
bool hasDownloadedMapping = await DownloadMappingFileAsync(Constants.MappingURL, mappingPath);
|
||||||
|
if (!hasDownloadedMapping)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* compression setup
|
||||||
|
*/
|
||||||
|
ZlibHelper.Initialize();
|
||||||
|
|
||||||
|
var oodlePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, OodleHelper.OodleFileName);
|
||||||
|
OodleHelper.Initialize(oodlePath);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* game localization
|
||||||
|
*/
|
||||||
|
var gamePath = getGamePath();
|
||||||
|
if (gamePath == null) return false;
|
||||||
|
|
||||||
|
var pakDir = gamePath + "\\DeadByDaylight\\Content\\Paks";
|
||||||
|
if (!Directory.Exists(pakDir))
|
||||||
|
{
|
||||||
|
Console.WriteLine("PAK dir does not exist. (Invalid install?)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* provider setup
|
||||||
|
*/
|
||||||
|
var version = new VersionContainer(EGame.GAME_DeadByDaylight, ETexturePlatform.DesktopMobile);
|
||||||
|
_provider = new DefaultFileProvider(pakDir, SearchOption.TopDirectoryOnly, version);
|
||||||
|
_provider.MappingsContainer = new FileUsmapTypeMappingsProvider(mappingPath);
|
||||||
|
|
||||||
|
_provider.Initialize();
|
||||||
|
_provider.SubmitKey(new FGuid(), new FAesKey(Constants.AESKey));
|
||||||
|
_provider.Mount();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* load db pak
|
||||||
|
*/
|
||||||
|
bool hasDataPak = _provider.TryGetArchive("pakchunk4-WinGDK.utoc", out _dataPak);
|
||||||
|
if (!hasDataPak)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to load pakchunk4-WinGDK.utoc");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? DumpCustomizationItems()
|
||||||
|
{
|
||||||
|
if (_dataPak == null || _provider == null) return null;
|
||||||
|
|
||||||
|
var searchPaths = _dataPak.Files.Keys.Where(x => x.Contains($"/CustomizationItemDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
|
||||||
|
var characterItems = new List<string>();
|
||||||
|
var outfits = new List<string>();
|
||||||
|
|
||||||
|
foreach (var path in searchPaths)
|
||||||
|
{
|
||||||
|
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
||||||
|
if (_provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
||||||
|
{
|
||||||
|
foreach (var row in dataTable.RowMap)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* props
|
||||||
|
*/
|
||||||
|
var props = row.Value.Properties;
|
||||||
|
|
||||||
|
FPropertyTag? categoryProp = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Category");
|
||||||
|
if (categoryProp == null || categoryProp.Tag == null) continue;
|
||||||
|
|
||||||
|
FPropertyTag? availabilityProp = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Availability");
|
||||||
|
if (availabilityProp == null || availabilityProp.Tag == null) continue;
|
||||||
|
|
||||||
|
FStructFallback? availabilityFallback = availabilityProp.Tag.GetValue<FStructFallback>();
|
||||||
|
if (availabilityFallback == null) continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* real data
|
||||||
|
*/
|
||||||
|
string itemName = row.Key.Text;
|
||||||
|
AvailabilityStruct availability = availabilityFallback.MapToStruct<AvailabilityStruct>();
|
||||||
|
ECustomizationCategory category = categoryProp.Tag.GetValue<ECustomizationCategory>();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sketchy item filtering
|
||||||
|
*/
|
||||||
|
if (availability.DLCId == "development") continue;
|
||||||
|
if (category < ECustomizationCategory.SurvivorHead || category > ECustomizationCategory.KillerWeapon) continue;
|
||||||
|
if (Constants.BlacklistedCustomizationItems.Contains(itemName)) continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* storing
|
||||||
|
*/
|
||||||
|
characterItems.Add(itemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
searchPaths = _dataPak.Files.Keys.Where(x => x.Contains($"/OutfitDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
|
||||||
|
foreach (var path in searchPaths)
|
||||||
|
{
|
||||||
|
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
||||||
|
if (_provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
||||||
|
{
|
||||||
|
foreach (var row in dataTable.RowMap)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* props
|
||||||
|
*/
|
||||||
|
var props = row.Value.Properties;
|
||||||
|
|
||||||
|
FPropertyTag? availabilityProp = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Availability");
|
||||||
|
if (availabilityProp == null || availabilityProp.Tag == null) continue;
|
||||||
|
|
||||||
|
FStructFallback? availabilityFallback = availabilityProp.Tag.GetValue<FStructFallback>();
|
||||||
|
if (availabilityFallback == null) continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* real data
|
||||||
|
*/
|
||||||
|
string outfitName = row.Key.Text;
|
||||||
|
AvailabilityStruct availability = availabilityFallback.MapToStruct<AvailabilityStruct>();
|
||||||
|
|
||||||
|
if (availability.DLCId == "development")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
outfits.Add(outfitName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var customizationsSerialized = new
|
||||||
|
{
|
||||||
|
Items = characterItems.OrderBy(x => x).ToList(),
|
||||||
|
Outfits = outfits.OrderBy(x => x).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(customizationsSerialized, Formatting.Indented);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? DumpItems()
|
||||||
|
{
|
||||||
|
if (_dataPak == null || _provider == null) return null;
|
||||||
|
|
||||||
|
var searchPaths = _dataPak.Files.Keys.Where(x => x.Contains($"/ItemDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
|
||||||
|
var camperItems = new List<string>();
|
||||||
|
//var slasherPowers = new List<string>();
|
||||||
|
|
||||||
|
foreach (var path in searchPaths)
|
||||||
|
{
|
||||||
|
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
||||||
|
if (_provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
||||||
|
{
|
||||||
|
foreach (var row in dataTable.RowMap)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* props
|
||||||
|
*/
|
||||||
|
var props = row.Value.Properties;
|
||||||
|
|
||||||
|
FPropertyTag? roleProp = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Role");
|
||||||
|
if (roleProp == null || roleProp.Tag == null) continue;
|
||||||
|
|
||||||
|
//FPropertyTag? typeProp = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Type");
|
||||||
|
//if (typeProp == null || typeProp.Tag == null) continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* real data
|
||||||
|
*/
|
||||||
|
string itemName = row.Key.Text;
|
||||||
|
EPlayerRole role = roleProp.Tag.GetValue<EPlayerRole>();
|
||||||
|
|
||||||
|
if (role == EPlayerRole.VE_Camper)
|
||||||
|
camperItems.Add(itemName);
|
||||||
|
//else
|
||||||
|
// slasherPowers.Add(itemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var itemsSerialized = new
|
||||||
|
{
|
||||||
|
Campers = camperItems.OrderBy(x => x).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(itemsSerialized, Formatting.Indented);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? DumpAddons()
|
||||||
|
{
|
||||||
|
if (_dataPak == null || _provider == null) return null;
|
||||||
|
|
||||||
|
var searchPaths = _dataPak.Files.Keys.Where(x => x.Contains($"/ItemAddonDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
|
||||||
|
var camperAddons = new List<string>();
|
||||||
|
var slasherAddons = new List<string>();
|
||||||
|
|
||||||
|
foreach (var path in searchPaths)
|
||||||
|
{
|
||||||
|
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
||||||
|
if (_provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
||||||
|
{
|
||||||
|
foreach (var row in dataTable.RowMap)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* props
|
||||||
|
*/
|
||||||
|
var props = row.Value.Properties;
|
||||||
|
|
||||||
|
FPropertyTag? roleProp = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Role");
|
||||||
|
if (roleProp == null || roleProp.Tag == null) continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* real data
|
||||||
|
*/
|
||||||
|
string itemName = row.Key.Text;
|
||||||
|
EPlayerRole role = roleProp.Tag.GetValue<EPlayerRole>();
|
||||||
|
|
||||||
|
if (role == EPlayerRole.VE_Camper)
|
||||||
|
camperAddons.Add(itemName);
|
||||||
|
else
|
||||||
|
slasherAddons.Add(itemName);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var addonsSerialized = new
|
||||||
|
{
|
||||||
|
Slashers = slasherAddons.OrderBy(x => x).ToList(),
|
||||||
|
Campers = camperAddons.OrderBy(x => x).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(addonsSerialized, Formatting.Indented);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? DumpOfferings()
|
||||||
|
{
|
||||||
|
if (_dataPak == null || _provider == null) return null;
|
||||||
|
|
||||||
|
var searchPaths = _dataPak.Files.Keys.Where(x => x.Contains($"/OfferingDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
|
||||||
|
var globalOfferings = new List<string>();
|
||||||
|
var camperOfferings = new List<string>();
|
||||||
|
var slasherOfferings = new List<string>();
|
||||||
|
|
||||||
|
foreach (var path in searchPaths)
|
||||||
|
{
|
||||||
|
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
||||||
|
if (_provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
||||||
|
{
|
||||||
|
foreach (var row in dataTable.RowMap)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* props
|
||||||
|
*/
|
||||||
|
var props = row.Value.Properties;
|
||||||
|
|
||||||
|
FPropertyTag? roleProp = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Role");
|
||||||
|
if (roleProp == null || roleProp.Tag == null) continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* real data
|
||||||
|
*/
|
||||||
|
string itemName = row.Key.Text;
|
||||||
|
EPlayerRole role = roleProp.Tag.GetValue<EPlayerRole>();
|
||||||
|
|
||||||
|
if (role == EPlayerRole.VE_Camper)
|
||||||
|
camperOfferings.Add(itemName);
|
||||||
|
else if (role == EPlayerRole.VE_Slasher)
|
||||||
|
slasherOfferings.Add(itemName);
|
||||||
|
else
|
||||||
|
globalOfferings.Add(itemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var offeringsSerialized = new
|
||||||
|
{
|
||||||
|
Slashers = slasherOfferings.OrderBy(x => x).ToList(),
|
||||||
|
Campers = camperOfferings.OrderBy(x => x).ToList(),
|
||||||
|
All = globalOfferings.OrderBy(x => x).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(offeringsSerialized, Formatting.Indented);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? DumpPerks()
|
||||||
|
{
|
||||||
|
if (_dataPak == null || _provider == null) return null;
|
||||||
|
|
||||||
|
var searchPaths = _dataPak.Files.Keys.Where(x => x.Contains($"/PerkDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
|
||||||
|
var camperPerks = new List<string>();
|
||||||
|
var slasherPerks = new List<string>();
|
||||||
|
|
||||||
|
foreach (var path in searchPaths)
|
||||||
|
{
|
||||||
|
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
||||||
|
if (_provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
||||||
|
{
|
||||||
|
foreach (var row in dataTable.RowMap)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* props
|
||||||
|
*/
|
||||||
|
var props = row.Value.Properties;
|
||||||
|
|
||||||
|
FPropertyTag? roleProp = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Role");
|
||||||
|
if (roleProp == null || roleProp.Tag == null) continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* real data
|
||||||
|
*/
|
||||||
|
string itemName = row.Key.Text;
|
||||||
|
EPlayerRole role = roleProp.Tag.GetValue<EPlayerRole>();
|
||||||
|
|
||||||
|
if (role == EPlayerRole.VE_Camper)
|
||||||
|
camperPerks.Add(itemName);
|
||||||
|
else
|
||||||
|
slasherPerks.Add(itemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var perksSerialized = new
|
||||||
|
{
|
||||||
|
Slashers = slasherPerks.OrderBy(x => x).ToList(),
|
||||||
|
Campers = camperPerks.OrderBy(x => x).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(perksSerialized, Formatting.Indented);
|
||||||
|
}
|
||||||
|
private string? getGamePath()
|
||||||
|
{
|
||||||
|
const string packagesPath = @"Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages";
|
||||||
|
|
||||||
|
using var key = Registry.CurrentUser.OpenSubKey(packagesPath);
|
||||||
|
|
||||||
|
if (key == null) return null;
|
||||||
|
string? matchingKeyName = key.GetSubKeyNames()
|
||||||
|
.FirstOrDefault(name => name.StartsWith(Constants.PackageName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (matchingKeyName != null)
|
||||||
|
{
|
||||||
|
using (RegistryKey? subKey = key.OpenSubKey(matchingKeyName))
|
||||||
|
return subKey?.GetValue("PackageRootFolder")?.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Failed to find game install dir");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private async Task<bool> DownloadMappingFileAsync(string url, string outPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var httpClient = new HttpClient())
|
||||||
|
{
|
||||||
|
var bytes = await httpClient.GetByteArrayAsync(url);
|
||||||
|
Console.WriteLine("Downloading mapping file...");
|
||||||
|
await File.WriteAllBytesAsync(outPath, bytes);
|
||||||
|
Console.WriteLine($"Mapping file downloaded to: {outPath}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error occured while downloading mapping: {ex.Message}");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
-224
@@ -1,228 +1,72 @@
|
|||||||
using CUE4Parse.Compression;
|
using CUE4Parse.UE4.Assets.Exports.CustomizableObject;
|
||||||
using CUE4Parse.Encryption.Aes;
|
|
||||||
using CUE4Parse.FileProvider;
|
|
||||||
using CUE4Parse.MappingsProvider;
|
|
||||||
using CUE4Parse.UE4.Assets.Exports.Actor;
|
|
||||||
using CUE4Parse.UE4.Assets.Exports.Engine;
|
|
||||||
using CUE4Parse.UE4.Assets.Exports.Texture;
|
|
||||||
using CUE4Parse.UE4.Assets.Objects.Properties;
|
|
||||||
using CUE4Parse.UE4.Objects.Core.Misc;
|
|
||||||
using CUE4Parse.UE4.Objects.UObject;
|
|
||||||
using CUE4Parse.UE4.Versions;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
class DumpByDaylight
|
int displayError(string err)
|
||||||
{
|
{
|
||||||
private const string _pakDir = "D:\\XboxGames\\Dead By Daylight\\Content\\DeadByDaylight\\Content\\Paks";
|
Console.WriteLine($"Dumper error: {err}");
|
||||||
private const string _aesKey = "0x22B1639B548124925CF7B9CBAA09F9AC295FCF0324586D6B37EE1D42670B39B3";
|
Console.WriteLine("Press any key to exit");
|
||||||
private const string _mappingURL = "https://git.neru.rip/neru/UnlockedByDaylight/raw/branch/main/res/mappings/latest-xbox.usmap";
|
|
||||||
|
|
||||||
public static async Task<string?> DownloadMappingFileAsync(string url, string savePath)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (var httpClient = new HttpClient())
|
|
||||||
{
|
|
||||||
Console.WriteLine("downloading mapping file...");
|
|
||||||
var bytes = await httpClient.GetByteArrayAsync(url);
|
|
||||||
await File.WriteAllBytesAsync(savePath, bytes);
|
|
||||||
Console.WriteLine($"mapping file downloaded to: {savePath}");
|
|
||||||
return savePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"failed to download mapping: {ex.Message}");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static async Task Main(string[] args)
|
|
||||||
{
|
|
||||||
// mapping
|
|
||||||
string mappingPath = Path.Combine(Path.GetTempPath(), "DeadByDaylight.usmap");
|
|
||||||
string? downloadedMapping = await DownloadMappingFileAsync(_mappingURL, mappingPath);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(downloadedMapping))
|
|
||||||
{
|
|
||||||
Console.WriteLine("failed to download mapping file, press any key to exit");
|
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
return;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
ZlibHelper.Initialize();
|
|
||||||
|
|
||||||
var oodlePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, OodleHelper.OodleFileName);
|
|
||||||
OodleHelper.Initialize(oodlePath);
|
|
||||||
|
|
||||||
|
|
||||||
// parsing setup
|
|
||||||
var version = new VersionContainer(EGame.GAME_DeadByDaylight, ETexturePlatform.DesktopMobile);
|
|
||||||
var provider = new DefaultFileProvider(_pakDir, SearchOption.TopDirectoryOnly, version);
|
|
||||||
provider.MappingsContainer = new FileUsmapTypeMappingsProvider(downloadedMapping);
|
|
||||||
|
|
||||||
provider.Initialize();
|
|
||||||
provider.SubmitKey(new FGuid(), new FAesKey(_aesKey));
|
|
||||||
provider.Mount();
|
|
||||||
|
|
||||||
Console.WriteLine("\nProvider Initialized. Extracting Databases...");
|
|
||||||
|
|
||||||
var dataPak = provider.GetArchive("pakchunk4-WinGDK.utoc");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* itemdb dump
|
|
||||||
*/
|
|
||||||
var searchPaths = dataPak.Files.Keys.Where(x => x.Contains($"/ItemDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
|
||||||
var camperItems = new List<string>();
|
|
||||||
|
|
||||||
var slasherPowers = new List<string>();
|
|
||||||
|
|
||||||
foreach (var path in searchPaths)
|
|
||||||
{
|
|
||||||
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
|
||||||
if (provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"getting items / powers from {Path.GetFullPath(path)}");
|
|
||||||
|
|
||||||
foreach (var row in dataTable.RowMap)
|
|
||||||
{
|
|
||||||
var roleProperty = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Role");
|
|
||||||
var typeProperty = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Type");
|
|
||||||
if (typeProperty?.Tag is EnumProperty typeProp && roleProperty?.Tag is EnumProperty roleProp)
|
|
||||||
{
|
|
||||||
string typeName = typeProp.Value.ToString() ?? "null";
|
|
||||||
string roleName = roleProp.Value.ToString() ?? "null";
|
|
||||||
|
|
||||||
if (roleName == "EPlayerRole::VE_Slasher")
|
|
||||||
slasherPowers.Add(row.Key.Text);
|
|
||||||
else
|
|
||||||
camperItems.Add(row.Key.Text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var itemsSerialized = new
|
|
||||||
{
|
|
||||||
Campers = camperItems.OrderBy(x => x).ToList(),
|
|
||||||
Slashers = slasherPowers.OrderBy(x => x).ToList()
|
|
||||||
};
|
|
||||||
File.WriteAllText("items.json", JsonConvert.SerializeObject(itemsSerialized, Formatting.Indented));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* addon dump
|
|
||||||
*/
|
|
||||||
searchPaths = dataPak.Files.Keys.Where(x => x.Contains($"/ItemAddonDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
|
||||||
var camperAddons = new List<string>();
|
|
||||||
var slasherAddons = new List<string>();
|
|
||||||
|
|
||||||
foreach (var path in searchPaths)
|
|
||||||
{
|
|
||||||
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
|
||||||
if (provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"getting item / power addons from {Path.GetFullPath(path)}");
|
|
||||||
|
|
||||||
foreach (var row in dataTable.RowMap)
|
|
||||||
{
|
|
||||||
bool isSlasherAddon = false;
|
|
||||||
var roleProperty = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Role");
|
|
||||||
if (roleProperty?.Tag is EnumProperty roleEnumProp)
|
|
||||||
{
|
|
||||||
string roleName = roleEnumProp.Value.ToString() ?? "null";
|
|
||||||
if (roleName == "EPlayerRole::VE_Slasher")
|
|
||||||
isSlasherAddon = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSlasherAddon)
|
|
||||||
slasherAddons.Add(row.Key.Text);
|
|
||||||
else
|
|
||||||
camperAddons.Add(row.Key.Text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var addonsSerialized = new
|
|
||||||
{
|
|
||||||
Slashers = slasherAddons.OrderBy(x => x).ToList(),
|
|
||||||
Campers = camperAddons.OrderBy(x => x).ToList()
|
|
||||||
};
|
|
||||||
File.WriteAllText("addons.json", JsonConvert.SerializeObject(addonsSerialized, Formatting.Indented));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* offerings
|
|
||||||
*/
|
|
||||||
searchPaths = dataPak.Files.Keys.Where(x => x.Contains($"/OfferingDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
|
||||||
|
|
||||||
var camperOfferings = new List<string>();
|
|
||||||
var slasherOfferings = new List<string>();
|
|
||||||
|
|
||||||
foreach (var path in searchPaths)
|
|
||||||
{
|
|
||||||
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
|
||||||
if (provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"getting offerings from {Path.GetFullPath(path)}");
|
|
||||||
|
|
||||||
foreach (var row in dataTable.RowMap)
|
|
||||||
{
|
|
||||||
var roleProperty = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Role");
|
|
||||||
if (roleProperty?.Tag is EnumProperty roleEnumProp)
|
|
||||||
{
|
|
||||||
string roleName = roleEnumProp.Value.ToString() ?? "null";
|
|
||||||
if (roleName == "EPlayerRole::VE_Slasher")
|
|
||||||
slasherOfferings.Add(row.Key.Text);
|
|
||||||
else
|
|
||||||
camperOfferings.Add(row.Key.Text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var offeringsSerialized = new
|
|
||||||
{
|
|
||||||
Slashers = slasherOfferings.OrderBy(x => x).ToList(),
|
|
||||||
Campers = camperOfferings.OrderBy(x => x).ToList()
|
|
||||||
};
|
|
||||||
File.WriteAllText("offerings.json", JsonConvert.SerializeObject(offeringsSerialized, Formatting.Indented));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* perks
|
|
||||||
*/
|
|
||||||
searchPaths = dataPak.Files.Keys.Where(x => x.Contains($"/PerkDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
|
||||||
|
|
||||||
var slasherPerks = new List<string>();
|
|
||||||
var camperPerks = new List<string>();
|
|
||||||
|
|
||||||
foreach (var path in searchPaths)
|
|
||||||
{
|
|
||||||
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
|
||||||
if (provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"getting perks from {Path.GetFullPath(path)}");
|
|
||||||
|
|
||||||
foreach (var row in dataTable.RowMap)
|
|
||||||
{
|
|
||||||
var roleProperty = row.Value.Properties.FirstOrDefault(p => p.Name.Text == "Role");
|
|
||||||
if (roleProperty?.Tag is EnumProperty roleEnumProp)
|
|
||||||
{
|
|
||||||
string roleName = roleEnumProp.Value.ToString() ?? "null";
|
|
||||||
if (roleName == "EPlayerRole::VE_Slasher")
|
|
||||||
slasherPerks.Add(row.Key.Text);
|
|
||||||
else
|
|
||||||
camperPerks.Add(row.Key.Text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var perksSerialized = new
|
|
||||||
{
|
|
||||||
Slashers = slasherPerks.OrderBy(x => x).ToList(),
|
|
||||||
Campers = camperPerks.OrderBy(x => x).ToList()
|
|
||||||
};
|
|
||||||
File.WriteAllText("perks.json", JsonConvert.SerializeObject(perksSerialized, Formatting.Indented));
|
|
||||||
|
|
||||||
Console.WriteLine("\nAll dumper operations finished. Press any key to Close.");
|
|
||||||
Console.ReadKey();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Dumper start");
|
||||||
|
var dumper = new Dumper();
|
||||||
|
|
||||||
|
bool hasInitialized = await dumper.InitAsync();
|
||||||
|
if (!hasInitialized) return displayError("Dumper.InitAsync failed");
|
||||||
|
|
||||||
|
Console.WriteLine("Dumper initialized");
|
||||||
|
|
||||||
|
string? customizationItemsJSON = dumper.DumpCustomizationItems();
|
||||||
|
if (customizationItemsJSON != null)
|
||||||
|
{
|
||||||
|
File.WriteAllText("customizations.json", customizationItemsJSON);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to dump customizations");
|
||||||
|
}
|
||||||
|
|
||||||
|
string? itemsJSON = dumper.DumpItems();
|
||||||
|
if (itemsJSON != null)
|
||||||
|
{
|
||||||
|
File.WriteAllText("items.json", itemsJSON);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to dump items");
|
||||||
|
}
|
||||||
|
|
||||||
|
string? addonsJSON = dumper.DumpAddons();
|
||||||
|
if (addonsJSON != null)
|
||||||
|
{
|
||||||
|
File.WriteAllText("addons.json", addonsJSON);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to dump addons");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string? offeringsJSON = dumper.DumpOfferings();
|
||||||
|
if (offeringsJSON != null)
|
||||||
|
{
|
||||||
|
File.WriteAllText("offerings.json", offeringsJSON);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to dump offerings");
|
||||||
|
}
|
||||||
|
|
||||||
|
string? perksJSON = dumper.DumpPerks();
|
||||||
|
if (perksJSON != null)
|
||||||
|
{
|
||||||
|
File.WriteAllText("perks.json", perksJSON);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to dump perks");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Dumper finished");
|
||||||
|
|
||||||
|
return 0;
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using CUE4Parse.UE4.Assets.Objects;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
public static class StructMapper
|
||||||
|
{
|
||||||
|
public static T MapToStruct<T>(this FStructFallback fallback) where T : struct
|
||||||
|
{
|
||||||
|
object result = new T();
|
||||||
|
var fields = typeof(T).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
|
||||||
|
foreach (var field in fields)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var method = typeof(CUE4Parse.UE4.Assets.Exports.AbstractPropertyHolder)
|
||||||
|
.GetMethods()
|
||||||
|
.FirstOrDefault(m => m.Name == "GetOrDefault" && m.GetGenericArguments().Length == 1);
|
||||||
|
|
||||||
|
if (method != null)
|
||||||
|
{
|
||||||
|
var genericMethod = method.MakeGenericMethod(field.FieldType);
|
||||||
|
|
||||||
|
var value = genericMethod.Invoke(fallback, new object[] { field.Name, null!, StringComparison.Ordinal });
|
||||||
|
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
field.SetValue(result, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Mapping failed for {field.Name}: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T)result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
#include "cert_manager.h"
|
|
||||||
#include <nerutils/log.h>
|
|
||||||
#include <openssl/bio.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/pem.h>
|
|
||||||
#include <openssl/x509v3.h>
|
|
||||||
#include <openssl/bn.h>
|
|
||||||
#include <openssl/rsa.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
#include <processthreadsapi.h>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
std::string randomizeString(size_t length)
|
|
||||||
{
|
|
||||||
const char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
||||||
std::string result;
|
|
||||||
result.resize(length);
|
|
||||||
for (size_t i = 0; i < length; ++i)
|
|
||||||
result[i] = charset[rand() % (sizeof(charset) - 1)];
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
CertManager::CertManager() : _sessionPkey(nullptr) {}
|
|
||||||
|
|
||||||
CertManager::~CertManager()
|
|
||||||
{
|
|
||||||
if (_caPkey) EVP_PKEY_free(_caPkey);
|
|
||||||
if (_caCert) X509_free(_caCert);
|
|
||||||
if (_sessionPkey) EVP_PKEY_free(_sessionPkey);
|
|
||||||
|
|
||||||
for (auto& pair : _hostContexts)
|
|
||||||
SSL_CTX_free(pair.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CertManager::Init()
|
|
||||||
{
|
|
||||||
EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
|
|
||||||
if (pctx)
|
|
||||||
{
|
|
||||||
EVP_PKEY_keygen_init(pctx);
|
|
||||||
EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048);
|
|
||||||
EVP_PKEY_keygen(pctx, &_sessionPkey);
|
|
||||||
EVP_PKEY_CTX_free(pctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LoadCA())
|
|
||||||
{
|
|
||||||
Log::verbose("Loaded existing CA certificate.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::verbose("No CA found. Generating new CA certificate.");
|
|
||||||
return GenerateCA();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CertManager::LoadCA()
|
|
||||||
{
|
|
||||||
BIO* keyBio = BIO_new_file("ca_key.pem", "r");
|
|
||||||
if (!keyBio) return false;
|
|
||||||
|
|
||||||
_caPkey = PEM_read_bio_PrivateKey(keyBio, nullptr, nullptr, nullptr);
|
|
||||||
BIO_free(keyBio);
|
|
||||||
|
|
||||||
if (!_caPkey) return false;
|
|
||||||
|
|
||||||
BIO* certBio = BIO_new_file("ca_cert.pem", "r");
|
|
||||||
if (!certBio) return false;
|
|
||||||
|
|
||||||
_caCert = PEM_read_bio_X509(certBio, nullptr, nullptr, nullptr);
|
|
||||||
BIO_free(certBio);
|
|
||||||
|
|
||||||
if (!_caCert) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CertManager::GenerateCA()
|
|
||||||
{
|
|
||||||
srand(static_cast<unsigned int>(time(nullptr)));
|
|
||||||
|
|
||||||
EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
|
|
||||||
if (!pctx) return false;
|
|
||||||
EVP_PKEY_keygen_init(pctx);
|
|
||||||
EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048);
|
|
||||||
EVP_PKEY_keygen(pctx, &_caPkey);
|
|
||||||
EVP_PKEY_CTX_free(pctx);
|
|
||||||
|
|
||||||
_caCert = X509_new();
|
|
||||||
X509_set_version(_caCert, 2);
|
|
||||||
ASN1_INTEGER_set(X509_get_serialNumber(_caCert), 1);
|
|
||||||
X509_gmtime_adj(X509_get_notBefore(_caCert), 0);
|
|
||||||
X509_gmtime_adj(X509_get_notAfter(_caCert), 31536000L); // 1 year
|
|
||||||
|
|
||||||
std::string org = randomizeString(16);
|
|
||||||
std::string cn = randomizeString(16);
|
|
||||||
|
|
||||||
X509_NAME* name = X509_get_subject_name(_caCert);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char*)"US", -1, -1, 0);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, (unsigned char*)org.c_str(), -1, -1, 0);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char*)cn.c_str(), -1, -1, 0);
|
|
||||||
X509_set_issuer_name(_caCert, name);
|
|
||||||
X509_set_pubkey(_caCert, _caPkey);
|
|
||||||
|
|
||||||
X509V3_CTX ctxV3;
|
|
||||||
X509V3_set_ctx_nodb(&ctxV3);
|
|
||||||
X509V3_set_ctx(&ctxV3, _caCert, _caCert, nullptr, nullptr, 0);
|
|
||||||
X509_EXTENSION* extCA = X509V3_EXT_conf_nid(nullptr, &ctxV3, NID_basic_constraints, "critical,CA:TRUE");
|
|
||||||
if (extCA)
|
|
||||||
{
|
|
||||||
X509_add_ext(_caCert, extCA, -1);
|
|
||||||
X509_EXTENSION_free(extCA);
|
|
||||||
}
|
|
||||||
|
|
||||||
X509_sign(_caCert, _caPkey, EVP_sha256());
|
|
||||||
|
|
||||||
BIO* keyBioOut = BIO_new_file("ca_key.pem", "w");
|
|
||||||
if (keyBioOut)
|
|
||||||
{
|
|
||||||
PEM_write_bio_PrivateKey(keyBioOut, _caPkey, nullptr, nullptr, 0, nullptr, nullptr);
|
|
||||||
BIO_free(keyBioOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
BIO* certBioOut = BIO_new_file("ca_cert.pem", "w");
|
|
||||||
if (certBioOut)
|
|
||||||
{
|
|
||||||
PEM_write_bio_X509(certBioOut, _caCert);
|
|
||||||
BIO_free(certBioOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info("Generated new CA key and certificate files. Installing to Windows Root CA store automatically...");
|
|
||||||
|
|
||||||
STARTUPINFOA si;
|
|
||||||
memset(&si, 0, sizeof(si));
|
|
||||||
si.cb = sizeof(si);
|
|
||||||
PROCESS_INFORMATION pi;
|
|
||||||
memset(&pi, 0, sizeof(pi));
|
|
||||||
char cmd[] = "certutil.exe -user -addstore root ca_cert.pem";
|
|
||||||
if (CreateProcessA(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
|
|
||||||
{
|
|
||||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
||||||
CloseHandle(pi.hProcess);
|
|
||||||
CloseHandle(pi.hThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSL_CTX* CertManager::CreateHostContext(const std::string& host)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
|
||||||
|
|
||||||
auto it = _hostContexts.find(host);
|
|
||||||
if (it != _hostContexts.end())
|
|
||||||
{
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
EVP_PKEY* pkey = _sessionPkey;
|
|
||||||
if (!pkey) return nullptr;
|
|
||||||
|
|
||||||
X509* cert = X509_new();
|
|
||||||
X509_set_version(cert, 2);
|
|
||||||
ASN1_INTEGER_set(X509_get_serialNumber(cert), static_cast<long>(std::hash<std::string>{}(host) & 0x7FFFFFFF));
|
|
||||||
X509_gmtime_adj(X509_get_notBefore(cert), 0);
|
|
||||||
X509_gmtime_adj(X509_get_notAfter(cert), 31536000L);
|
|
||||||
|
|
||||||
std::string dynamicOrg = randomizeString(16);
|
|
||||||
|
|
||||||
X509_NAME* name = X509_get_subject_name(cert);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char*)"US", -1, -1, 0);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, (unsigned char*)dynamicOrg.c_str(), -1, -1, 0);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char*)(host.c_str()), -1, -1, 0);
|
|
||||||
X509_set_issuer_name(cert, X509_get_subject_name(_caCert));
|
|
||||||
X509_set_pubkey(cert, pkey);
|
|
||||||
|
|
||||||
X509V3_CTX ctxV3;
|
|
||||||
X509V3_set_ctx_nodb(&ctxV3);
|
|
||||||
X509V3_set_ctx(&ctxV3, _caCert, cert, nullptr, nullptr, 0);
|
|
||||||
std::string san = "DNS:" + host;
|
|
||||||
X509_EXTENSION* extSAN = X509V3_EXT_conf_nid(nullptr, &ctxV3, NID_subject_alt_name, san.c_str());
|
|
||||||
if (extSAN)
|
|
||||||
{
|
|
||||||
X509_add_ext(cert, extSAN, -1);
|
|
||||||
X509_EXTENSION_free(extSAN);
|
|
||||||
}
|
|
||||||
|
|
||||||
X509_sign(cert, _caPkey, EVP_sha256());
|
|
||||||
|
|
||||||
SSL_CTX* ctx = SSL_CTX_new(TLS_server_method());
|
|
||||||
|
|
||||||
SSL_CTX_set_alpn_select_cb(
|
|
||||||
ctx,
|
|
||||||
[](SSL* /*ssl*/, const unsigned char** out, unsigned char* outlen, const unsigned char* in, unsigned int inlen,
|
|
||||||
void* /*arg*/) -> int {
|
|
||||||
for (unsigned int i = 0; i < inlen;)
|
|
||||||
{
|
|
||||||
unsigned int len = in[i];
|
|
||||||
if (len == 8 && memcmp(&in[i + 1], "http/1.1", 8) == 0)
|
|
||||||
{
|
|
||||||
*out = &in[i + 1];
|
|
||||||
*outlen = (unsigned char)len;
|
|
||||||
return SSL_TLSEXT_ERR_OK;
|
|
||||||
}
|
|
||||||
i += len + 1;
|
|
||||||
}
|
|
||||||
return SSL_TLSEXT_ERR_NOACK;
|
|
||||||
},
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
SSL_CTX_use_certificate(ctx, cert);
|
|
||||||
SSL_CTX_use_PrivateKey(ctx, pkey);
|
|
||||||
|
|
||||||
X509_free(cert);
|
|
||||||
|
|
||||||
_hostContexts[host] = ctx;
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <mutex>
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
|
|
||||||
class CertManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CertManager();
|
|
||||||
~CertManager();
|
|
||||||
|
|
||||||
bool Init();
|
|
||||||
SSL_CTX* CreateHostContext(const std::string& host);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool GenerateCA();
|
|
||||||
bool LoadCA();
|
|
||||||
|
|
||||||
EVP_PKEY* _caPkey = nullptr;
|
|
||||||
X509* _caCert = nullptr;
|
|
||||||
EVP_PKEY* _sessionPkey = nullptr;
|
|
||||||
|
|
||||||
std::mutex _mutex;
|
|
||||||
std::unordered_map<std::string, SSL_CTX*> _hostContexts;
|
|
||||||
};
|
|
||||||
+33
-19
@@ -5,34 +5,45 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wininet.h>
|
#include <wininet.h>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
bool setProxy(bool enable, const std::string& proxyAddr)
|
bool setProxyAddress(bool enable, const std::string& proxyAddr)
|
||||||
{
|
{
|
||||||
INTERNET_PER_CONN_OPTION_LIST list;
|
INTERNET_PER_CONN_OPTION_LIST list;
|
||||||
INTERNET_PER_CONN_OPTION options[3];
|
INTERNET_PER_CONN_OPTION options[3];
|
||||||
unsigned long listSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
|
|
||||||
|
ZeroMemory(&list, sizeof(list));
|
||||||
|
ZeroMemory(options, sizeof(options));
|
||||||
|
|
||||||
options[0].dwOption = INTERNET_PER_CONN_FLAGS;
|
options[0].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
|
{
|
||||||
|
if (proxyAddr.empty()) return false;
|
||||||
|
|
||||||
options[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
|
options[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
|
||||||
else
|
|
||||||
options[0].Value.dwValue = PROXY_TYPE_DIRECT;
|
|
||||||
|
|
||||||
options[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
options[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
||||||
options[1].Value.pszValue = const_cast<char*>(proxyAddr.c_str());
|
options[1].Value.pszValue = const_cast<char*>(proxyAddr.c_str());
|
||||||
|
|
||||||
options[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
|
options[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
|
||||||
options[2].Value.pszValue = const_cast<char*>("<local>");
|
options[2].Value.pszValue = (char*)"<local>";
|
||||||
|
|
||||||
|
list.dwOptionCount = 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options[0].Value.dwValue = PROXY_TYPE_DIRECT;
|
||||||
|
list.dwOptionCount = 1;
|
||||||
|
}
|
||||||
|
|
||||||
list.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
|
list.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
|
||||||
list.pszConnection = NULL;
|
list.pszConnection = NULL;
|
||||||
list.dwOptionCount = 3;
|
|
||||||
list.dwOptionError = 0;
|
|
||||||
list.pOptions = options;
|
list.pOptions = options;
|
||||||
|
|
||||||
if (!InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, listSize))
|
if (!InternetSetOption(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, sizeof(list)))
|
||||||
{
|
{
|
||||||
Log::error("Failed to set proxy options, Err: {}", GetLastError());
|
Log::error("Failed to set proxy options - error: {}", GetLastError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +54,7 @@ bool setProxy(bool enable, const std::string& proxyAddr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
Proxy* g_Proxy = nullptr;
|
Proxy* proxy = nullptr;
|
||||||
|
|
||||||
void cleanup()
|
void cleanup()
|
||||||
{
|
{
|
||||||
@@ -53,14 +64,14 @@ void cleanup()
|
|||||||
if (cleaned) return;
|
if (cleaned) return;
|
||||||
cleaned = true;
|
cleaned = true;
|
||||||
|
|
||||||
if (g_Proxy)
|
Log::info("Restoring system proxy settings");
|
||||||
|
setProxyAddress(false, "");
|
||||||
|
|
||||||
|
if (proxy)
|
||||||
{
|
{
|
||||||
Log::info("Shutting down proxy");
|
Log::info("Shutting down proxy");
|
||||||
g_Proxy->Shutdown();
|
proxy->shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info("Restoring system proxy settings");
|
|
||||||
setProxy(false, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI consoleHandler(DWORD dwType)
|
BOOL WINAPI consoleHandler(DWORD dwType)
|
||||||
@@ -77,6 +88,8 @@ BOOL WINAPI consoleHandler(DWORD dwType)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
srand(static_cast<unsigned int>(time(NULL)));
|
||||||
|
|
||||||
Log::createConsole();
|
Log::createConsole();
|
||||||
SetConsoleCtrlHandler(consoleHandler, TRUE);
|
SetConsoleCtrlHandler(consoleHandler, TRUE);
|
||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
@@ -87,13 +100,14 @@ int main()
|
|||||||
proxy setup
|
proxy setup
|
||||||
*/
|
*/
|
||||||
Log::info("Starting proxy");
|
Log::info("Starting proxy");
|
||||||
g_Proxy = new Proxy();
|
proxy = new Proxy();
|
||||||
if (!g_Proxy->Init())
|
if (!proxy->init())
|
||||||
{
|
{
|
||||||
Log::error("Proxy failed to start");
|
Log::error("Proxy failed to start");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
setProxy(true, std::format("127.0.0.1:{}", PROXY_PORT));
|
proxy->addWhitelistDomain("bhvrdbd.com");
|
||||||
|
setProxyAddress(true, std::format("127.0.0.1:{}", PROXY_PORT));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Spoofer setup
|
Spoofer setup
|
||||||
@@ -101,7 +115,7 @@ int main()
|
|||||||
Log::info("Spoofer init");
|
Log::info("Spoofer init");
|
||||||
Spoofer* spoofer = new Spoofer();
|
Spoofer* spoofer = new Spoofer();
|
||||||
|
|
||||||
spoofer->init(g_Proxy);
|
spoofer->init(proxy);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
pause
|
pause
|
||||||
|
|||||||
+637
-480
File diff suppressed because it is too large
Load Diff
+17
-3
@@ -3,9 +3,13 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <queue>
|
||||||
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include "cert_manager.h"
|
#include "ssl.h"
|
||||||
#include <nerutils/callback.h>
|
#include <nerutils/callback.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -13,6 +17,7 @@
|
|||||||
use random port, test availability
|
use random port, test availability
|
||||||
*/
|
*/
|
||||||
#define PROXY_PORT 58421
|
#define PROXY_PORT 58421
|
||||||
|
#define PROXY_THREAD_COUNT 256
|
||||||
|
|
||||||
typedef unsigned __int64 SOCKET;
|
typedef unsigned __int64 SOCKET;
|
||||||
|
|
||||||
@@ -22,12 +27,14 @@ class Proxy
|
|||||||
Proxy();
|
Proxy();
|
||||||
~Proxy();
|
~Proxy();
|
||||||
|
|
||||||
bool Init();
|
bool init();
|
||||||
void Shutdown();
|
void shutdown();
|
||||||
|
|
||||||
CallbackEvent<std::string&, const std::string&, std::string&> OnClientRequest;
|
CallbackEvent<std::string&, const std::string&, std::string&> OnClientRequest;
|
||||||
CallbackEvent<const std::string&, std::string&, std::string&> OnServerResponse;
|
CallbackEvent<const std::string&, std::string&, std::string&> OnServerResponse;
|
||||||
|
|
||||||
|
void addWhitelistDomain(const std::string& domain);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loop();
|
void loop();
|
||||||
void handleClient(SOCKET clientSocket);
|
void handleClient(SOCKET clientSocket);
|
||||||
@@ -39,6 +46,13 @@ class Proxy
|
|||||||
std::thread _workerThread;
|
std::thread _workerThread;
|
||||||
std::atomic<bool> _running = false;
|
std::atomic<bool> _running = false;
|
||||||
|
|
||||||
|
std::vector<std::thread> _poolThreads;
|
||||||
|
std::queue<SOCKET> _clientQueue;
|
||||||
|
std::mutex _queueMutex;
|
||||||
|
std::condition_variable _queueCond;
|
||||||
|
|
||||||
CertManager _certManager;
|
CertManager _certManager;
|
||||||
SSL_CTX* _clientCtx = nullptr;
|
SSL_CTX* _clientCtx = nullptr;
|
||||||
|
|
||||||
|
std::vector<std::string> _whitelistDomains;
|
||||||
};
|
};
|
||||||
|
|||||||
+185
-126
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
#define PLACEHOLDER_ITEMID "Anniversary2025Offering"
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
static std::random_device rd;
|
static std::random_device rd;
|
||||||
@@ -39,6 +41,7 @@ void Spoofer::init(Proxy* proxy)
|
|||||||
{
|
{
|
||||||
registerListeners(proxy);
|
registerListeners(proxy);
|
||||||
loadData();
|
loadData();
|
||||||
|
loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spoofer::registerListeners(Proxy* proxy)
|
void Spoofer::registerListeners(Proxy* proxy)
|
||||||
@@ -53,86 +56,101 @@ void Spoofer::registerListeners(Proxy* proxy)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOADDATA(fileName, type, camperSet, slasherSet, errorMsg) \
|
|
||||||
std::string path##type = utils::getExePath() + fileName; \
|
|
||||||
std::ifstream file##type(path##type); \
|
|
||||||
if (file##type.is_open()) \
|
|
||||||
{ \
|
|
||||||
std::stringstream buff; \
|
|
||||||
buff << file##type.rdbuf(); \
|
|
||||||
if (!parseStackable(buff.str(), camperSet, slasherSet)) \
|
|
||||||
Log::error("Failed to parse {} - {}", fileName, errorMsg); \
|
|
||||||
else \
|
|
||||||
Log::verbose("Loaded {} camper ids and {} slasher ids from {}", camperSet.size(), slasherSet.size(), \
|
|
||||||
fileName); \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
Log::warning("Missing {} - {}", fileName, errorMsg);
|
|
||||||
|
|
||||||
void Spoofer::loadData()
|
void Spoofer::loadData()
|
||||||
{
|
{
|
||||||
Log::info("Loading data");
|
Log::info("Loading data");
|
||||||
|
|
||||||
std::string catalogPath = utils::getExePath() + "catalog.json";
|
/*
|
||||||
std::ifstream catalogFile(catalogPath);
|
stackables
|
||||||
if (catalogFile.is_open())
|
*/
|
||||||
|
static auto loadData = [this](const char* fileName, std::unordered_set<std::string>* camperSet,
|
||||||
|
std::unordered_set<std::string>* slasherSet,
|
||||||
|
std::unordered_set<std::string>* globalSet, const char* errorMsg) {
|
||||||
|
std::ifstream file(utils::getExePath() + fileName);
|
||||||
|
|
||||||
|
if (file.is_open())
|
||||||
{
|
{
|
||||||
std::stringstream buff;
|
std::stringstream buff;
|
||||||
buff << catalogFile.rdbuf();
|
buff << file.rdbuf();
|
||||||
if (!parseCatalog(buff.str())) Log::warning("Failed to parse catalog.json - Customizations won't be unlocked");
|
if (!parseStackable(buff.str(), camperSet, slasherSet, globalSet))
|
||||||
|
return Log::error("Failed to parse {} - {}", fileName, errorMsg);
|
||||||
|
else
|
||||||
|
Log::verbose("Loaded {}", fileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log::warning("Missing catalog.json - Customizations won't be unlocked");
|
Log::warning("Missing file: {} - {}", fileName, errorMsg);
|
||||||
|
};
|
||||||
|
|
||||||
LOADDATA("items.json", Items, _camperItemIds, _slasherPowerIds, "Items won't be added");
|
loadData("items.json", &_camperItemIds, 0, 0, "Items wont be added");
|
||||||
LOADDATA("offerings.json", Offerings, _camperOfferingIds, _slasherOfferingIds, "Offerings won't be added");
|
loadData("offerings.json", &_camperOfferingIds, &_slasherOfferingIds, &_globalOfferingIds,
|
||||||
LOADDATA("addons.json", Addons, _camperAddonIds, _slasherAddonIds, "Addons won't be added");
|
"Offerings won't be added");
|
||||||
LOADDATA("perks.json", Perks, _camperPerkIds, _slasherPerkIds, "Perks won't be added");
|
loadData("addons.json", &_camperAddonIds, &_slasherAddonIds, 0, "Offerings won't be added");
|
||||||
|
loadData("perks.json", &_camperPerkIds, &_slasherPerkIds, 0, "Offerings won't be added");
|
||||||
|
|
||||||
|
/*
|
||||||
|
catalog items
|
||||||
|
*/
|
||||||
|
std::ifstream customizationsFile(utils::getExePath() + "customizations.json");
|
||||||
|
if (customizationsFile.is_open())
|
||||||
|
{
|
||||||
|
std::stringstream buff;
|
||||||
|
buff << customizationsFile.rdbuf();
|
||||||
|
if (!parseCustomizations(buff.str()))
|
||||||
|
Log::warning("Failed to parse customizations.json - Outfits and character items won't be added");
|
||||||
|
else
|
||||||
|
Log::verbose("Loaded customizations.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::verbose("Finished loading data");
|
||||||
|
|
||||||
|
Log::verbose("Items - {} camper", _camperItemIds.size());
|
||||||
|
Log::verbose("Offerings - {} camper | {} slasher | {} global", _camperOfferingIds.size(),
|
||||||
|
_slasherOfferingIds.size(), _globalOfferingIds.size());
|
||||||
|
Log::verbose("Addons - {} camper | {} slasher ", _camperAddonIds.size(), _slasherAddonIds.size());
|
||||||
|
Log::verbose("Perks - {} camper | {} slasher ", _camperPerkIds.size(), _slasherPerkIds.size());
|
||||||
|
|
||||||
|
Log::verbose("Catalog - {} outfits | {} items", _catalogOutfitIds.size(), _catalogItemIds.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spoofer::loadConfig()
|
||||||
|
{
|
||||||
|
std::string configPath = utils::getExePath() + "config.json";
|
||||||
|
std::ifstream configFile(configPath);
|
||||||
|
|
||||||
|
if (configFile.is_open())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json configJson = json::parse(configFile);
|
||||||
|
_config.spoofCharacterOwnership =
|
||||||
|
configJson.value("spoofCharacterOwnership", _config.spoofCharacterOwnership);
|
||||||
|
_config.spoofInventory = configJson.value("spoofInventory", _config.spoofInventory);
|
||||||
|
_config.spoofCustomization = configJson.value("spoofCustomization", _config.spoofCustomization);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
Log::error("Failed to parse config.json, using defaults");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log::info("config.json not found, using default settings");
|
||||||
|
json defaultConfig = {{"spoofCharacterOwnership", _config.spoofCharacterOwnership},
|
||||||
|
{"spoofInventory", _config.spoofInventory},
|
||||||
|
{"spoofCustomization", _config.spoofCustomization}};
|
||||||
|
std::ofstream out(configPath);
|
||||||
|
out << defaultConfig.dump(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info("Loaded config: Ownership={}, Inventory={}, Customization={}", _config.spoofCharacterOwnership,
|
||||||
|
_config.spoofInventory, _config.spoofCustomization);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
data parsing
|
data parsing
|
||||||
*/
|
*/
|
||||||
bool Spoofer::parseCatalog(std::string data)
|
bool Spoofer::parseStackable(std::string data, std::unordered_set<std::string>* camperSet,
|
||||||
{
|
std::unordered_set<std::string>* slasherSet, std::unordered_set<std::string>* globalSet)
|
||||||
json doc = json::parse(data, nullptr, false);
|
|
||||||
|
|
||||||
if (doc.is_discarded())
|
|
||||||
{
|
|
||||||
Log::error("Failed to parse catalog");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const auto& catalogData = doc.at("data");
|
|
||||||
|
|
||||||
auto extractIds = [&](const std::string& key, std::unordered_set<std::string>& targetSet) {
|
|
||||||
if (catalogData.contains(key) && catalogData[key].contains("items"))
|
|
||||||
for (const auto& id : catalogData[key]["items"])
|
|
||||||
{
|
|
||||||
if (id.is_string()) targetSet.insert(id.get<std::string>());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Log::warning("Catalog missing or invalid category: {}", key);
|
|
||||||
};
|
|
||||||
|
|
||||||
extractIds("item", _catalogItemIds);
|
|
||||||
extractIds("outfit", _catalogOutfitIds);
|
|
||||||
}
|
|
||||||
catch (const json::exception& e)
|
|
||||||
{
|
|
||||||
Log::error("Invalid catalog format: {}", e.what());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info("Parsed {} items and {} outfits from catalog", _catalogItemIds.size(), _catalogOutfitIds.size());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Spoofer::parseStackable(std::string data, std::unordered_set<std::string>& camperSet,
|
|
||||||
std::unordered_set<std::string>& slasherSet)
|
|
||||||
{
|
{
|
||||||
json doc = json::parse(data, nullptr, false);
|
json doc = json::parse(data, nullptr, false);
|
||||||
if (doc.is_discarded())
|
if (doc.is_discarded())
|
||||||
@@ -141,18 +159,47 @@ bool Spoofer::parseStackable(std::string data, std::unordered_set<std::string>&
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto populate = [&](const std::string& key, std::unordered_set<std::string>& targetSet) {
|
auto populate = [&](const std::string& key, std::unordered_set<std::string>* targetSet) {
|
||||||
if (doc.contains(key) && doc[key].is_array())
|
if (doc.contains(key) && doc[key].is_array())
|
||||||
for (const auto& item : doc[key])
|
for (const auto& item : doc[key])
|
||||||
{
|
{
|
||||||
if (item.is_string()) targetSet.insert(item.get<std::string>());
|
if (item.is_string()) targetSet->insert(item.get<std::string>());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log::warning("Missing stackables array ({})", key);
|
Log::warning("Missing stackables array ({})", key);
|
||||||
};
|
};
|
||||||
|
|
||||||
populate("Slashers", slasherSet);
|
if (camperSet) populate("Campers", camperSet);
|
||||||
populate("Campers", camperSet);
|
if (slasherSet) populate("Slashers", slasherSet);
|
||||||
|
if (globalSet) populate("All", globalSet);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Spoofer::parseCustomizations(std::string data)
|
||||||
|
{
|
||||||
|
json doc = json::parse(data, nullptr, false);
|
||||||
|
if (doc.is_discarded())
|
||||||
|
{
|
||||||
|
Log::error("JSON parse error @ parseCustomizations");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.contains("Items"))
|
||||||
|
{
|
||||||
|
for (const auto& item : doc["Items"])
|
||||||
|
{
|
||||||
|
if (item.is_string()) _catalogItemIds.insert(item.get<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.contains("Outfits"))
|
||||||
|
{
|
||||||
|
for (const auto& outfit : doc["Outfits"])
|
||||||
|
{
|
||||||
|
if (outfit.is_string()) _catalogOutfitIds.insert(outfit.get<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -163,14 +210,14 @@ bool Spoofer::parseStackable(std::string data, std::unordered_set<std::string>&
|
|||||||
std::string Spoofer::getRandomItem()
|
std::string Spoofer::getRandomItem()
|
||||||
{
|
{
|
||||||
std::vector<const std::unordered_set<std::string>*> allSets = {
|
std::vector<const std::unordered_set<std::string>*> allSets = {
|
||||||
&_camperItemIds, &_slasherPowerIds, &_camperOfferingIds, &_slasherOfferingIds,
|
&_camperItemIds, &_camperOfferingIds, &_slasherOfferingIds, &_camperAddonIds,
|
||||||
&_camperAddonIds, &_slasherAddonIds, &_camperPerkIds, &_slasherPerkIds};
|
&_slasherAddonIds, &_camperPerkIds, &_slasherPerkIds};
|
||||||
|
|
||||||
std::vector<const std::unordered_set<std::string>*> validSets;
|
std::vector<const std::unordered_set<std::string>*> validSets;
|
||||||
for (auto* s : allSets)
|
for (auto* s : allSets)
|
||||||
if (!s->empty()) validSets.push_back(s);
|
if (!s->empty()) validSets.push_back(s);
|
||||||
|
|
||||||
if (validSets.empty()) return "Spring2024Offering";
|
if (validSets.empty()) return PLACEHOLDER_ITEMID;
|
||||||
|
|
||||||
std::uniform_int_distribution<> setDist(0, static_cast<int>(validSets.size()) - 1);
|
std::uniform_int_distribution<> setDist(0, static_cast<int>(validSets.size()) - 1);
|
||||||
const auto& selectedSet = *validSets[setDist(gen)];
|
const auto& selectedSet = *validSets[setDist(gen)];
|
||||||
@@ -241,10 +288,12 @@ void Spoofer::modifyCharacterData(json& js)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string name = js["characterName"];
|
std::string name = js["characterName"];
|
||||||
bool slasher = isSlasher(js["characterName"]);
|
|
||||||
|
|
||||||
|
if (_config.spoofCharacterOwnership)
|
||||||
|
{
|
||||||
bool needsSpoofing = false;
|
bool needsSpoofing = false;
|
||||||
if (js.value("isEntitled", true) == false)
|
|
||||||
|
if (js.value("isEntitled", false) == false)
|
||||||
{
|
{
|
||||||
_unownedCharacters.insert(name);
|
_unownedCharacters.insert(name);
|
||||||
js["isEntitled"] = true;
|
js["isEntitled"] = true;
|
||||||
@@ -269,39 +318,15 @@ void Spoofer::modifyCharacterData(json& js)
|
|||||||
|
|
||||||
if (js.contains("bloodWebData")) generateBloodweb(js["bloodWebData"]);
|
if (js.contains("bloodWebData")) generateBloodweb(js["bloodWebData"]);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
ghost node hotfix (untested)
|
|
||||||
*/
|
|
||||||
/* if (js.contains("bloodWebData") && js["bloodWebData"].contains("ringData"))
|
|
||||||
{
|
|
||||||
auto& ringData = js["bloodWebData"]["ringData"];
|
|
||||||
|
|
||||||
for (auto& ring : ringData)
|
|
||||||
{
|
|
||||||
if (ring.contains("nodeData") && ring["nodeData"].is_array())
|
|
||||||
{
|
|
||||||
for (auto& node : ring["nodeData"])
|
|
||||||
{
|
|
||||||
if (node.contains("nodeId") && node["nodeId"] != "0")
|
|
||||||
{
|
|
||||||
if (!node.contains("contentId") || node["contentId"].get<std::string>().empty())
|
|
||||||
{
|
|
||||||
node["contentId"] = "Spring2024Offering";
|
|
||||||
if (!node.contains("state"))
|
|
||||||
node["state"] = "Available";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
item spoofing
|
item spoofing
|
||||||
*/
|
*/
|
||||||
|
if (_config.spoofInventory)
|
||||||
|
{
|
||||||
|
bool slasher = isSlasher(js["characterName"]);
|
||||||
|
|
||||||
if (js.contains("characterItems") && js["characterItems"].is_array())
|
if (js.contains("characterItems") && js["characterItems"].is_array())
|
||||||
{
|
{
|
||||||
std::unordered_set<std::string> existingItemIds;
|
std::unordered_set<std::string> existingItemIds;
|
||||||
@@ -309,6 +334,7 @@ void Spoofer::modifyCharacterData(json& js)
|
|||||||
std::unordered_set<std::string> stackableIds;
|
std::unordered_set<std::string> stackableIds;
|
||||||
stackableIds.insert(_camperItemIds.begin(), _camperItemIds.end());
|
stackableIds.insert(_camperItemIds.begin(), _camperItemIds.end());
|
||||||
stackableIds.insert(_camperOfferingIds.begin(), _camperOfferingIds.end());
|
stackableIds.insert(_camperOfferingIds.begin(), _camperOfferingIds.end());
|
||||||
|
stackableIds.insert(_globalOfferingIds.begin(), _globalOfferingIds.end());
|
||||||
stackableIds.insert(_camperAddonIds.begin(), _camperAddonIds.end());
|
stackableIds.insert(_camperAddonIds.begin(), _camperAddonIds.end());
|
||||||
stackableIds.insert(_slasherAddonIds.begin(), _slasherAddonIds.end());
|
stackableIds.insert(_slasherAddonIds.begin(), _slasherAddonIds.end());
|
||||||
stackableIds.insert(_slasherOfferingIds.begin(), _slasherOfferingIds.end());
|
stackableIds.insert(_slasherOfferingIds.begin(), _slasherOfferingIds.end());
|
||||||
@@ -346,34 +372,19 @@ void Spoofer::modifyCharacterData(json& js)
|
|||||||
appendItems(_slasherOfferingIds, false);
|
appendItems(_slasherOfferingIds, false);
|
||||||
appendItems(_slasherPerkIds, true);
|
appendItems(_slasherPerkIds, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appendItems(_globalOfferingIds, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
Log::verbose("Spoofed data for character {}", name);
|
Log::verbose("Spoofed data for character {}", name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
endpoint handlers
|
endpoint handlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Spoofer::onGetCatalogItems(std::string& body)
|
|
||||||
{
|
|
||||||
std::thread t([body]() {
|
|
||||||
std::string outPath = utils::getExePath() + "catalog.json";
|
|
||||||
std::ofstream file(outPath);
|
|
||||||
if (file.is_open())
|
|
||||||
{
|
|
||||||
file << body;
|
|
||||||
file.close();
|
|
||||||
Log::verbose("Raw catalog saved to {}", outPath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Log::error("Unable to write to catalog.json");
|
|
||||||
});
|
|
||||||
t.detach();
|
|
||||||
|
|
||||||
parseCatalog(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Spoofer::onGetAll(std::string& body)
|
void Spoofer::onGetAll(std::string& body)
|
||||||
{
|
{
|
||||||
json doc = json::parse(body, nullptr, false);
|
json doc = json::parse(body, nullptr, false);
|
||||||
@@ -407,8 +418,24 @@ void Spoofer::onInventoryAll(std::string& body)
|
|||||||
int quantity;
|
int quantity;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Category> categories = {{_camperPerkIds, 3}, {_slasherPerkIds, 3}, {_camperOfferingIds, -1},
|
std::vector<Category> categories;
|
||||||
{_slasherOfferingIds, -1}, {_catalogOutfitIds, 1}, {_catalogItemIds, 1}};
|
if (_config.spoofInventory)
|
||||||
|
{
|
||||||
|
categories.push_back({_camperPerkIds, 3});
|
||||||
|
categories.push_back({_slasherPerkIds, 3});
|
||||||
|
categories.push_back({_camperOfferingIds, -1});
|
||||||
|
categories.push_back({_slasherOfferingIds, -1});
|
||||||
|
|
||||||
|
categories.push_back({_camperItemIds, -1});
|
||||||
|
categories.push_back({_camperAddonIds, -1});
|
||||||
|
categories.push_back({_slasherAddonIds, -1});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_config.spoofCustomization)
|
||||||
|
{
|
||||||
|
categories.push_back({_catalogOutfitIds, 1});
|
||||||
|
categories.push_back({_catalogItemIds, 1});
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& item : itemsArr)
|
for (auto& item : itemsArr)
|
||||||
{
|
{
|
||||||
@@ -498,7 +525,9 @@ void Spoofer::onMessageList(std::string& body)
|
|||||||
doc["messages"].push_back(msg);
|
doc["messages"].push_back(msg);
|
||||||
|
|
||||||
body = doc.dump();
|
body = doc.dump();
|
||||||
|
#ifdef _DEBUG
|
||||||
Log::verbose("Spoofed message list");
|
Log::verbose("Spoofed message list");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
||||||
@@ -506,6 +535,11 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
|||||||
json doc = json::parse(body, nullptr, false);
|
json doc = json::parse(body, nullptr, false);
|
||||||
if (doc.is_discarded()) return Log::error("JSON parse error for bloodweb response");
|
if (doc.is_discarded()) return Log::error("JSON parse error for bloodweb response");
|
||||||
|
|
||||||
|
/*
|
||||||
|
return fake bloodweb data
|
||||||
|
*/
|
||||||
|
if (_config.spoofCharacterOwnership)
|
||||||
|
{
|
||||||
if (body.find("NotAllowedException") != std::string::npos && body.find("not owned") != std::string::npos)
|
if (body.find("NotAllowedException") != std::string::npos && body.find("not owned") != std::string::npos)
|
||||||
{
|
{
|
||||||
Log::info("Spoofing bloodweb error for unowned character");
|
Log::info("Spoofing bloodweb error for unowned character");
|
||||||
@@ -537,7 +571,33 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
bloodweb fixup for perks
|
||||||
|
(if all perks are unlocked, the game will interpret bloodwebs with perks as invalid so perks will be replaced with PLACEHOLDER_ITEMID)
|
||||||
|
*/
|
||||||
|
if (_config.spoofInventory)
|
||||||
|
{
|
||||||
|
if (doc.contains("bloodWebData") && doc["bloodWebData"].contains("ringData"))
|
||||||
|
{
|
||||||
|
for (auto& ring : doc["bloodWebData"]["ringData"])
|
||||||
|
{
|
||||||
|
if (!ring.contains("nodeData")) continue;
|
||||||
|
for (auto& node : ring["nodeData"])
|
||||||
|
{
|
||||||
|
if (!node.contains("contentId")) continue;
|
||||||
|
std::string contentId = node["contentId"];
|
||||||
|
if (_camperPerkIds.contains(contentId) || _slasherPerkIds.contains(contentId))
|
||||||
|
node["contentId"] = PLACEHOLDER_ITEMID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
prevent bloodweb reqs from overriding inventory values
|
||||||
|
*/
|
||||||
modifyCharacterData(doc);
|
modifyCharacterData(doc);
|
||||||
body = doc.dump();
|
body = doc.dump();
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -557,7 +617,6 @@ void Spoofer::serverResponseHandler(const std::string& url, std::string& body, s
|
|||||||
Log::verbose("BHVR api res @ {}", url);
|
Log::verbose("BHVR api res @ {}", url);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (url.find("api/v1/extensions/store/getCatalogItems") != std::string::npos) return onGetCatalogItems(body);
|
|
||||||
if (url.find("api/v1/dbd-character-data/get-all") != std::string::npos) return onGetAll(body);
|
if (url.find("api/v1/dbd-character-data/get-all") != std::string::npos) return onGetAll(body);
|
||||||
if (url.find("api/v1/dbd-character-data/get-all") != std::string::npos) return onGetAll(body);
|
if (url.find("api/v1/dbd-character-data/get-all") != std::string::npos) return onGetAll(body);
|
||||||
if (url.find("api/v1/dbd-inventories/all") != std::string::npos) return onInventoryAll(body);
|
if (url.find("api/v1/dbd-inventories/all") != std::string::npos) return onInventoryAll(body);
|
||||||
|
|||||||
+14
-5
@@ -9,6 +9,13 @@
|
|||||||
|
|
||||||
#include <nlohmann/json_fwd.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
|
struct SpooferConfig
|
||||||
|
{
|
||||||
|
bool spoofCharacterOwnership = false;
|
||||||
|
bool spoofInventory = true;
|
||||||
|
bool spoofCustomization = true;
|
||||||
|
};
|
||||||
|
|
||||||
class Spoofer
|
class Spoofer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -17,10 +24,11 @@ class Spoofer
|
|||||||
private:
|
private:
|
||||||
void registerListeners(Proxy* proxy);
|
void registerListeners(Proxy* proxy);
|
||||||
void loadData();
|
void loadData();
|
||||||
|
void loadConfig();
|
||||||
|
|
||||||
bool parseCatalog(std::string data);
|
bool parseStackable(std::string data, std::unordered_set<std::string>* camperSet,
|
||||||
bool parseStackable(std::string data, std::unordered_set<std::string>& camperSet,
|
std::unordered_set<std::string>* slasherSet, std::unordered_set<std::string>* globalSet);
|
||||||
std::unordered_set<std::string>& slasherSet);
|
bool parseCustomizations(std::string data);
|
||||||
|
|
||||||
std::string getRandomItem();
|
std::string getRandomItem();
|
||||||
int getRandomQuantity();
|
int getRandomQuantity();
|
||||||
@@ -28,7 +36,6 @@ class Spoofer
|
|||||||
void generateBloodweb(nlohmann::json& data);
|
void generateBloodweb(nlohmann::json& data);
|
||||||
void modifyCharacterData(nlohmann::json& js);
|
void modifyCharacterData(nlohmann::json& js);
|
||||||
|
|
||||||
void onGetCatalogItems(std::string& body);
|
|
||||||
void onGetAll(std::string& body);
|
void onGetAll(std::string& body);
|
||||||
void onInventoryAll(std::string& body);
|
void onInventoryAll(std::string& body);
|
||||||
void onMessageList(std::string& body);
|
void onMessageList(std::string& body);
|
||||||
@@ -37,11 +44,13 @@ class Spoofer
|
|||||||
void serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders);
|
void serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders);
|
||||||
void clientRequestHandler(std::string& url, const std::string& body, std::string& reqHeaders);
|
void clientRequestHandler(std::string& url, const std::string& body, std::string& reqHeaders);
|
||||||
|
|
||||||
|
SpooferConfig _config;
|
||||||
|
|
||||||
std::unordered_set<std::string> _camperItemIds;
|
std::unordered_set<std::string> _camperItemIds;
|
||||||
std::unordered_set<std::string> _slasherPowerIds;
|
|
||||||
|
|
||||||
std::unordered_set<std::string> _camperOfferingIds;
|
std::unordered_set<std::string> _camperOfferingIds;
|
||||||
std::unordered_set<std::string> _slasherOfferingIds;
|
std::unordered_set<std::string> _slasherOfferingIds;
|
||||||
|
std::unordered_set<std::string> _globalOfferingIds;
|
||||||
|
|
||||||
std::unordered_set<std::string> _camperAddonIds;
|
std::unordered_set<std::string> _camperAddonIds;
|
||||||
std::unordered_set<std::string> _slasherAddonIds;
|
std::unordered_set<std::string> _slasherAddonIds;
|
||||||
|
|||||||
@@ -0,0 +1,232 @@
|
|||||||
|
#include "ssl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <nerutils/log.h>
|
||||||
|
|
||||||
|
#include <openssl/bio.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/pem.h>
|
||||||
|
#include <openssl/x509v3.h>
|
||||||
|
#include <openssl/bn.h>
|
||||||
|
#include <openssl/rsa.h>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <ctime>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <wincrypt.h>
|
||||||
|
#include <processthreadsapi.h>
|
||||||
|
|
||||||
|
template <typename T, void (*f)(T*)> struct Deleter
|
||||||
|
{
|
||||||
|
void operator()(T* p) const { f(p); }
|
||||||
|
};
|
||||||
|
|
||||||
|
using EVP_PKEY_ptr = std::unique_ptr<EVP_PKEY, Deleter<EVP_PKEY, EVP_PKEY_free>>;
|
||||||
|
using X509_ptr = std::unique_ptr<X509, Deleter<X509, X509_free>>;
|
||||||
|
using SSL_CTX_ptr = std::unique_ptr<SSL_CTX, Deleter<SSL_CTX, SSL_CTX_free>>;
|
||||||
|
using BIO_ptr = std::unique_ptr<BIO, Deleter<BIO, BIO_vfree>>;
|
||||||
|
|
||||||
|
CertManager::CertManager() : _caPkey(nullptr), _caCert(nullptr), _sessionPkey(nullptr) {}
|
||||||
|
|
||||||
|
CertManager::~CertManager()
|
||||||
|
{
|
||||||
|
if (_caPkey) EVP_PKEY_free(_caPkey);
|
||||||
|
if (_caCert) X509_free(_caCert);
|
||||||
|
if (_sessionPkey) EVP_PKEY_free(_sessionPkey);
|
||||||
|
|
||||||
|
for (auto& pair : _hostContexts)
|
||||||
|
SSL_CTX_free(pair.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CertManager::init()
|
||||||
|
{
|
||||||
|
EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
|
||||||
|
if (!pctx) return false;
|
||||||
|
|
||||||
|
EVP_PKEY_keygen_init(pctx);
|
||||||
|
EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048);
|
||||||
|
|
||||||
|
EVP_PKEY* rawPkey = nullptr;
|
||||||
|
if (EVP_PKEY_keygen(pctx, &rawPkey) <= 0)
|
||||||
|
{
|
||||||
|
Log::error("Failed to generate session key");
|
||||||
|
EVP_PKEY_CTX_free(pctx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_sessionPkey = rawPkey;
|
||||||
|
EVP_PKEY_CTX_free(pctx);
|
||||||
|
|
||||||
|
if (loadCA())
|
||||||
|
{
|
||||||
|
Log::verbose("Loaded existing CA certificate");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::verbose("No CA found, generating");
|
||||||
|
return generateCA();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CertManager::loadCA()
|
||||||
|
{
|
||||||
|
std::string path = utils::getExePath();
|
||||||
|
|
||||||
|
BIO_ptr keyBio(BIO_new_file((path + "/key.pem").c_str(), "r"));
|
||||||
|
if (!keyBio) return false;
|
||||||
|
_caPkey = PEM_read_bio_PrivateKey(keyBio.get(), nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
|
BIO_ptr certBio(BIO_new_file((path + "/cert.pem").c_str(), "r"));
|
||||||
|
if (!certBio) return false;
|
||||||
|
_caCert = PEM_read_bio_X509(certBio.get(), nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
|
return (_caPkey && _caCert);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CertManager::installCert(X509* cert)
|
||||||
|
{
|
||||||
|
if (!cert) return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
X509 to DER
|
||||||
|
*/
|
||||||
|
int derLen = i2d_X509(cert, nullptr);
|
||||||
|
if (derLen < 0) return;
|
||||||
|
|
||||||
|
unsigned char* derBuf = new unsigned char[derLen];
|
||||||
|
unsigned char* p = derBuf;
|
||||||
|
i2d_X509(cert, &p);
|
||||||
|
|
||||||
|
PCCERT_CONTEXT certCtx = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, derBuf, derLen);
|
||||||
|
if (certCtx)
|
||||||
|
{
|
||||||
|
HCERTSTORE rootStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, L"Root");
|
||||||
|
if (rootStore)
|
||||||
|
{
|
||||||
|
BOOL success = CertAddCertificateContextToStore(rootStore, certCtx, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
Log::info("CA certificate installed");
|
||||||
|
else
|
||||||
|
Log::error("Failed to install CA certificate");
|
||||||
|
|
||||||
|
CertCloseStore(rootStore, 0);
|
||||||
|
}
|
||||||
|
CertFreeCertificateContext(certCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] derBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CertManager::generateCA()
|
||||||
|
{
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 gen(rd());
|
||||||
|
|
||||||
|
/*
|
||||||
|
key
|
||||||
|
*/
|
||||||
|
EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
|
||||||
|
EVP_PKEY_keygen_init(pctx);
|
||||||
|
EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048);
|
||||||
|
EVP_PKEY* rawCaKey = nullptr;
|
||||||
|
EVP_PKEY_keygen(pctx, &rawCaKey);
|
||||||
|
_caPkey = rawCaKey;
|
||||||
|
EVP_PKEY_CTX_free(pctx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
cert
|
||||||
|
*/
|
||||||
|
X509_ptr cert(X509_new());
|
||||||
|
X509_set_version(cert.get(), 2);
|
||||||
|
ASN1_INTEGER_set(X509_get_serialNumber(cert.get()), 1);
|
||||||
|
X509_gmtime_adj(X509_get_notBefore(cert.get()), 0);
|
||||||
|
X509_gmtime_adj(X509_get_notAfter(cert.get()), 31536000L); // 1 year
|
||||||
|
|
||||||
|
X509_name_st* subjName = X509_get_subject_name(cert.get());
|
||||||
|
std::string randomCN = utils::randomizeString(16);
|
||||||
|
X509_NAME_add_entry_by_txt(subjName, "CN", MBSTRING_ASC, (unsigned char*)randomCN.c_str(), -1, -1, 0);
|
||||||
|
X509_set_issuer_name(cert.get(), subjName);
|
||||||
|
X509_set_pubkey(cert.get(), _caPkey);
|
||||||
|
|
||||||
|
/*
|
||||||
|
CA constraints
|
||||||
|
*/
|
||||||
|
X509V3_CTX v3ctx;
|
||||||
|
X509V3_set_ctx(&v3ctx, cert.get(), cert.get(), nullptr, nullptr, 0);
|
||||||
|
X509_EXTENSION* ext = X509V3_EXT_conf_nid(nullptr, &v3ctx, NID_basic_constraints, "critical,CA:TRUE");
|
||||||
|
X509_add_ext(cert.get(), ext, -1);
|
||||||
|
X509_EXTENSION_free(ext);
|
||||||
|
|
||||||
|
if (X509_sign(cert.get(), _caPkey, EVP_sha256()) <= 0) return false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
out
|
||||||
|
*/
|
||||||
|
std::string path = utils::getExePath();
|
||||||
|
BIO_ptr kOut(BIO_new_file((path + "/key.pem").c_str(), "w"));
|
||||||
|
PEM_write_bio_PrivateKey(kOut.get(), _caPkey, nullptr, nullptr, 0, nullptr, nullptr);
|
||||||
|
|
||||||
|
BIO_ptr cOut(BIO_new_file((path + "/cert.pem").c_str(), "w"));
|
||||||
|
PEM_write_bio_X509(cOut.get(), cert.get());
|
||||||
|
|
||||||
|
/*
|
||||||
|
install and release
|
||||||
|
*/
|
||||||
|
installCert(cert.get());
|
||||||
|
|
||||||
|
_caCert = cert.release();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSL_CTX* CertManager::createHostContext(const std::string& host)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
if (_hostContexts.count(host)) return _hostContexts[host];
|
||||||
|
|
||||||
|
/*
|
||||||
|
cert base
|
||||||
|
*/
|
||||||
|
X509_ptr cert(X509_new());
|
||||||
|
X509_set_version(cert.get(), 2);
|
||||||
|
|
||||||
|
ASN1_INTEGER_set(X509_get_serialNumber(cert.get()), static_cast<long>(std::hash<std::string>{}(host) & 0x7FFFFFFF));
|
||||||
|
|
||||||
|
X509_gmtime_adj(X509_get_notBefore(cert.get()), 0);
|
||||||
|
X509_gmtime_adj(X509_get_notAfter(cert.get()), 31536000L);
|
||||||
|
|
||||||
|
X509_name_st* subjName = X509_get_subject_name(cert.get());
|
||||||
|
X509_NAME_add_entry_by_txt(subjName, "CN", MBSTRING_ASC, (unsigned char*)host.c_str(), -1, -1, 0);
|
||||||
|
X509_set_issuer_name(cert.get(), X509_get_subject_name(_caCert));
|
||||||
|
X509_set_pubkey(cert.get(), _sessionPkey);
|
||||||
|
|
||||||
|
/*
|
||||||
|
SAN
|
||||||
|
*/
|
||||||
|
X509V3_CTX v3ctx;
|
||||||
|
X509V3_set_ctx(&v3ctx, _caCert, cert.get(), nullptr, nullptr, 0);
|
||||||
|
std::string altName = "DNS:" + host;
|
||||||
|
X509_EXTENSION* ext = X509V3_EXT_conf_nid(nullptr, &v3ctx, NID_subject_alt_name, altName.c_str());
|
||||||
|
X509_add_ext(cert.get(), ext, -1);
|
||||||
|
X509_EXTENSION_free(ext);
|
||||||
|
|
||||||
|
/*
|
||||||
|
sign & ctx load
|
||||||
|
*/
|
||||||
|
if (X509_sign(cert.get(), _caPkey, EVP_sha256()) <= 0) return nullptr;
|
||||||
|
|
||||||
|
SSL_CTX* ctx = SSL_CTX_new(TLS_server_method());
|
||||||
|
if (!ctx) return nullptr;
|
||||||
|
|
||||||
|
if (SSL_CTX_use_certificate(ctx, cert.get()) <= 0 || SSL_CTX_use_PrivateKey(ctx, _sessionPkey) <= 0)
|
||||||
|
{
|
||||||
|
SSL_CTX_free(ctx);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hostContexts[host] = ctx;
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
struct x509_st;
|
||||||
|
struct X509_name_st;
|
||||||
|
struct ssl_st;
|
||||||
|
struct ssl_ctx_st;
|
||||||
|
struct evp_pkey_st;
|
||||||
|
|
||||||
|
typedef struct x509_st X509;
|
||||||
|
typedef struct ssl_st SSL;
|
||||||
|
typedef struct ssl_ctx_st SSL_CTX;
|
||||||
|
typedef struct evp_pkey_st EVP_PKEY;
|
||||||
|
|
||||||
|
class CertManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CertManager();
|
||||||
|
~CertManager();
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
SSL_CTX* createHostContext(const std::string& host);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool generateCA();
|
||||||
|
bool loadCA();
|
||||||
|
|
||||||
|
void installCert(X509* cert);
|
||||||
|
|
||||||
|
EVP_PKEY* _caPkey = nullptr;
|
||||||
|
X509* _caCert = nullptr;
|
||||||
|
EVP_PKEY* _sessionPkey = nullptr;
|
||||||
|
|
||||||
|
std::mutex _mutex;
|
||||||
|
std::unordered_map<std::string, SSL_CTX*> _hostContexts;
|
||||||
|
};
|
||||||
@@ -12,3 +12,13 @@ std::string utils::getExePath()
|
|||||||
if (pos != std::string::npos) return path.substr(0, pos + 1);
|
if (pos != std::string::npos) return path.substr(0, pos + 1);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string utils::randomizeString(size_t length)
|
||||||
|
{
|
||||||
|
const char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
std::string result;
|
||||||
|
result.resize(length);
|
||||||
|
for (size_t i = 0; i < length; ++i)
|
||||||
|
result[i] = charset[rand() % (sizeof(charset) - 1)];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -5,4 +5,5 @@
|
|||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
std::string getExePath();
|
std::string getExePath();
|
||||||
}
|
std::string randomizeString(size_t length);
|
||||||
|
} // namespace utils
|
||||||
Reference in New Issue
Block a user