Compare commits
7 Commits
v0.1.24
...
d4650aac84
| Author | SHA1 | Date | |
|---|---|---|---|
| d4650aac84 | |||
| 73b1c95257 | |||
| 93fe999249 | |||
| 393a591485 | |||
| 2b8cbafa19 | |||
| 623542046a | |||
| 90a6ab1ba8 |
@@ -8,3 +8,4 @@ for /r "src" %%f in (*.cpp *.h *.cs) do (
|
|||||||
|
|
||||||
echo done
|
echo done
|
||||||
pause
|
pause
|
||||||
|
|
||||||
+105
-109
@@ -1,111 +1,107 @@
|
|||||||
{
|
{
|
||||||
"Camper": {
|
"Campers": [
|
||||||
"Items": [
|
"Father_Key_Card",
|
||||||
"Father_Key_Card",
|
"FireflyLantern",
|
||||||
"FireflyLantern",
|
"Item_Camper_AlexsToolbox",
|
||||||
"Item_Camper_AlexsToolbox",
|
"Item_Camper_AnniversaryToolbox",
|
||||||
"Item_Camper_AnniversaryToolbox",
|
"Item_Camper_BeigeMap",
|
||||||
"Item_Camper_BeigeMap",
|
"Item_Camper_BrokenKey",
|
||||||
"Item_Camper_BrokenKey",
|
"Item_Camper_CommodiousToolbox",
|
||||||
"Item_Camper_CommodiousToolbox",
|
"Item_Camper_ContaminationSerum",
|
||||||
"Item_Camper_ContaminationSerum",
|
"Item_Camper_DullKey",
|
||||||
"Item_Camper_DullKey",
|
"Item_Camper_EngineerToolbox",
|
||||||
"Item_Camper_EngineerToolbox",
|
"Item_Camper_FadedMap",
|
||||||
"Item_Camper_FadedMap",
|
"Item_Camper_Firecracker_Anniversary2019",
|
||||||
"Item_Camper_Firecracker_Anniversary2019",
|
"Item_Camper_Firecracker_Chinese",
|
||||||
"Item_Camper_Firecracker_Chinese",
|
"Item_Camper_Firecracker_Flashbang",
|
||||||
"Item_Camper_Firecracker_Flashbang",
|
"Item_Camper_Firecracker_WinterEvent",
|
||||||
"Item_Camper_Firecracker_WinterEvent",
|
"Item_Camper_Flashlight",
|
||||||
"Item_Camper_Flashlight",
|
"Item_Camper_Flashlight_Anniversary2020",
|
||||||
"Item_Camper_Flashlight_Anniversary2020",
|
"Item_Camper_Flashlight_Anniversary2022",
|
||||||
"Item_Camper_Flashlight_Anniversary2022",
|
"Item_Camper_Flashlight_Random",
|
||||||
"Item_Camper_Flashlight_Random",
|
"Item_Camper_Flashlight02",
|
||||||
"Item_Camper_Flashlight02",
|
"Item_Camper_Flashlight03",
|
||||||
"Item_Camper_Flashlight03",
|
"Item_Camper_Flashlight04",
|
||||||
"Item_Camper_Flashlight04",
|
"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_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",
|
"Item_Camper_K36MagicItem_VecnaHand",
|
||||||
"Item_Camper_K36MagicItem_VecnaHand",
|
"Item_Camper_Key",
|
||||||
"Item_Camper_Key",
|
"Item_Camper_Key_Random",
|
||||||
"Item_Camper_Key_Random",
|
"Item_Camper_LunarToolbox",
|
||||||
"Item_Camper_LunarToolbox",
|
"Item_Camper_Map_Random",
|
||||||
"Item_Camper_Map_Random",
|
"Item_Camper_Map_Spring2024",
|
||||||
"Item_Camper_Map_Spring2024",
|
"Item_Camper_MechanicsToolbox",
|
||||||
"Item_Camper_MechanicsToolbox",
|
"Item_Camper_MedKit",
|
||||||
"Item_Camper_MedKit",
|
"Item_Camper_Medkit_Anniversary2020",
|
||||||
"Item_Camper_Medkit_Anniversary2020",
|
"Item_Camper_Medkit_Anniversary2022",
|
||||||
"Item_Camper_Medkit_Anniversary2022",
|
"Item_Camper_MedKit_Random",
|
||||||
"Item_Camper_MedKit_Random",
|
"Item_Camper_MedKit02",
|
||||||
"Item_Camper_MedKit02",
|
"Item_Camper_MedKit03",
|
||||||
"Item_Camper_MedKit03",
|
"Item_Camper_MedKit04",
|
||||||
"Item_Camper_MedKit04",
|
"Item_Camper_Medkit05",
|
||||||
"Item_Camper_Medkit05",
|
"Item_Camper_OnryoTape",
|
||||||
"Item_Camper_OnryoTape",
|
"Item_Camper_RainbowMap",
|
||||||
"Item_Camper_RainbowMap",
|
"Item_Camper_Toolbox",
|
||||||
"Item_Camper_Toolbox",
|
"Item_Camper_Toolbox_Anniversary2022",
|
||||||
"Item_Camper_Toolbox_Anniversary2022",
|
"Item_Camper_Toolbox_Random",
|
||||||
"Item_Camper_Toolbox_Random",
|
"Item_Camper_VoidBomb_Halloween2024",
|
||||||
"Item_Camper_VoidBomb_Halloween2024",
|
"Item_Camper_WornoutToolbox",
|
||||||
"Item_Camper_WornoutToolbox",
|
"Item_FragileObject",
|
||||||
"Item_FragileObject",
|
"Item_LamentConfiguration",
|
||||||
"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",
|
||||||
"Slasher": {
|
"Item_Slasher_Beartrap",
|
||||||
"Powers": [
|
"Item_Slasher_Blinker",
|
||||||
"Item_Blighted_Serum",
|
"Item_Slasher_Chainsaw",
|
||||||
"Item_Slasher_Beartrap",
|
"Item_Slasher_CloakBell",
|
||||||
"Item_Slasher_Blinker",
|
"Item_Slasher_DreamInducer",
|
||||||
"Item_Slasher_Chainsaw",
|
"Item_Slasher_Frenzy",
|
||||||
"Item_Slasher_CloakBell",
|
"Item_Slasher_GasBomb",
|
||||||
"Item_Slasher_DreamInducer",
|
"Item_Slasher_GhostPower",
|
||||||
"Item_Slasher_Frenzy",
|
"Item_Slasher_HarpoonRifle",
|
||||||
"Item_Slasher_GasBomb",
|
"Item_Slasher_Hatchet",
|
||||||
"Item_Slasher_GhostPower",
|
"Item_Slasher_K21Power",
|
||||||
"Item_Slasher_HarpoonRifle",
|
"Item_Slasher_K22Power",
|
||||||
"Item_Slasher_Hatchet",
|
"Item_Slasher_K24Power",
|
||||||
"Item_Slasher_K21Power",
|
"Item_Slasher_K25Power",
|
||||||
"Item_Slasher_K22Power",
|
"Item_Slasher_K26Power",
|
||||||
"Item_Slasher_K24Power",
|
"Item_Slasher_K27Power",
|
||||||
"Item_Slasher_K25Power",
|
"Item_Slasher_K28Power",
|
||||||
"Item_Slasher_K26Power",
|
"Item_Slasher_K29Power",
|
||||||
"Item_Slasher_K27Power",
|
"Item_Slasher_K30Power",
|
||||||
"Item_Slasher_K28Power",
|
"Item_Slasher_K31Power",
|
||||||
"Item_Slasher_K29Power",
|
"Item_Slasher_K32Power",
|
||||||
"Item_Slasher_K30Power",
|
"Item_Slasher_K33Power",
|
||||||
"Item_Slasher_K31Power",
|
"Item_Slasher_K34Power",
|
||||||
"Item_Slasher_K32Power",
|
"Item_Slasher_K35Power",
|
||||||
"Item_Slasher_K33Power",
|
"Item_Slasher_K36Power",
|
||||||
"Item_Slasher_K34Power",
|
"Item_Slasher_K37Power",
|
||||||
"Item_Slasher_K35Power",
|
"Item_Slasher_K38Power",
|
||||||
"Item_Slasher_K36Power",
|
"Item_Slasher_K39Power",
|
||||||
"Item_Slasher_K37Power",
|
"Item_Slasher_K40Power",
|
||||||
"Item_Slasher_K38Power",
|
"Item_Slasher_K41Power",
|
||||||
"Item_Slasher_K39Power",
|
"Item_Slasher_K42Power",
|
||||||
"Item_Slasher_K40Power",
|
"Item_Slasher_Kanobo",
|
||||||
"Item_Slasher_K41Power",
|
"Item_Slasher_Killer07Item",
|
||||||
"Item_Slasher_K42Power",
|
"Item_Slasher_LFChainsaw",
|
||||||
"Item_Slasher_Kanobo",
|
"Item_Slasher_PhantomTrap",
|
||||||
"Item_Slasher_Killer07Item",
|
"Item_Slasher_PhaseWalker",
|
||||||
"Item_Slasher_LFChainsaw",
|
"Item_Slasher_PlaguePower",
|
||||||
"Item_Slasher_PhantomTrap",
|
"Item_Slasher_QatarKillerPower",
|
||||||
"Item_Slasher_PhaseWalker",
|
"Item_Slasher_ReverseBearTrap",
|
||||||
"Item_Slasher_PlaguePower",
|
"Item_Slasher_Stalker",
|
||||||
"Item_Slasher_QatarKillerPower",
|
"Item_Slasher_ThrowingKnives",
|
||||||
"Item_Slasher_ReverseBearTrap",
|
"Item_Slasher_TormentMode"
|
||||||
"Item_Slasher_Stalker",
|
]
|
||||||
"Item_Slasher_ThrowingKnives",
|
|
||||||
"Item_Slasher_TormentMode"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -104,8 +104,8 @@ class DumpByDaylight
|
|||||||
|
|
||||||
var itemsSerialized = new
|
var itemsSerialized = new
|
||||||
{
|
{
|
||||||
Camper = new { Items = camperItems.OrderBy(x => x).ToList() },
|
Campers = camperItems.OrderBy(x => x).ToList(),
|
||||||
Slasher = new { Powers = slasherPowers.OrderBy(x => x).ToList() }
|
Slashers = slasherPowers.OrderBy(x => x).ToList()
|
||||||
};
|
};
|
||||||
File.WriteAllText("items.json", JsonConvert.SerializeObject(itemsSerialized, Formatting.Indented));
|
File.WriteAllText("items.json", JsonConvert.SerializeObject(itemsSerialized, Formatting.Indented));
|
||||||
|
|
||||||
|
|||||||
+396
-437
@@ -1,11 +1,13 @@
|
|||||||
#include "spoofing.h"
|
#include "spoofing.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
#include <vector>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include <minwindef.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <nerutils/log.h>
|
#include <nerutils/log.h>
|
||||||
|
|
||||||
@@ -13,24 +15,34 @@
|
|||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
std::string getExeDir()
|
static std::random_device rd;
|
||||||
|
static std::mt19937 gen(rd());
|
||||||
|
|
||||||
|
/*
|
||||||
|
utils
|
||||||
|
*/
|
||||||
|
std::unordered_set<std::string> slasherNames = {
|
||||||
|
"Chuckles", "Bob", "HillBilly", "Nurse", "Shape", "Witch", "Killer07", "Cannibal", "Bear",
|
||||||
|
"Nightmare", "Pig", "Clown", "Spirit", "Plague", "Ghostface", "Demogorgon", "Oni", "Gunslinger"};
|
||||||
|
|
||||||
|
bool isSlasher(std::string name)
|
||||||
{
|
{
|
||||||
char buffer[MAX_PATH];
|
if (slasherNames.contains(name) || (name.length() == 3 && name[0] == 'K')) return true;
|
||||||
GetModuleFileNameA(NULL, buffer, MAX_PATH);
|
return false;
|
||||||
std::string path(buffer);
|
|
||||||
size_t pos = path.find_last_of("\\/");
|
|
||||||
if (pos != std::string::npos) return path.substr(0, pos + 1);
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
setup / init
|
||||||
|
*/
|
||||||
void Spoofer::init(Proxy* proxy)
|
void Spoofer::init(Proxy* proxy)
|
||||||
{
|
{
|
||||||
loadData();
|
|
||||||
registerListeners(proxy);
|
registerListeners(proxy);
|
||||||
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spoofer::registerListeners(Proxy* proxy)
|
void Spoofer::registerListeners(Proxy* proxy)
|
||||||
{
|
{
|
||||||
|
Log::info("Registering Proxy event listeners for spoofer");
|
||||||
proxy->OnServerResponse.addListener([this](const std::string& url, std::string& body, std::string& respHeaders) {
|
proxy->OnServerResponse.addListener([this](const std::string& url, std::string& body, std::string& respHeaders) {
|
||||||
this->serverResponseHandler(url, body, respHeaders);
|
this->serverResponseHandler(url, body, respHeaders);
|
||||||
});
|
});
|
||||||
@@ -40,241 +52,257 @@ 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 dump data");
|
Log::info("Loading data");
|
||||||
|
|
||||||
std::string catalogDumpPath = getExeDir() + "catalog.json";
|
std::string catalogPath = utils::getExePath() + "catalog.json";
|
||||||
std::ifstream catalogFile(catalogDumpPath);
|
std::ifstream catalogFile(catalogPath);
|
||||||
if (catalogFile.is_open())
|
if (catalogFile.is_open())
|
||||||
{
|
{
|
||||||
std::stringstream buffer;
|
std::stringstream buff;
|
||||||
buffer << catalogFile.rdbuf();
|
buff << catalogFile.rdbuf();
|
||||||
parseCatalog(buffer.str());
|
if (!parseCatalog(buff.str())) Log::warning("Failed to parse catalog.json - Customizations won't be unlocked");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log::warning("Missing catalog.json");
|
Log::warning("Missing catalog.json - Customizations won't be unlocked");
|
||||||
|
|
||||||
std::string itemDumpPath = getExeDir() + "items.json";
|
LOADDATA("items.json", Items, _camperItemIds, _slasherPowerIds, "Items won't be added");
|
||||||
std::ifstream itemFile(itemDumpPath);
|
LOADDATA("offerings.json", Offerings, _camperOfferingIds, _slasherOfferingIds, "Offerings won't be added");
|
||||||
if (itemFile.is_open())
|
LOADDATA("addons.json", Addons, _camperAddonIds, _slasherAddonIds, "Addons won't be added");
|
||||||
|
LOADDATA("perks.json", Perks, _camperPerkIds, _slasherPerkIds, "Perks won't be added");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
data parsing
|
||||||
|
*/
|
||||||
|
bool Spoofer::parseCatalog(std::string data)
|
||||||
|
{
|
||||||
|
json doc = json::parse(data, nullptr, false);
|
||||||
|
|
||||||
|
if (doc.is_discarded())
|
||||||
{
|
{
|
||||||
try
|
Log::error("Failed to parse catalog");
|
||||||
{
|
return false;
|
||||||
std::string content((std::istreambuf_iterator<char>(itemFile)), std::istreambuf_iterator<char>());
|
|
||||||
json doc = json::parse(content);
|
|
||||||
|
|
||||||
if (doc.contains("Camper") && doc["Camper"].is_object())
|
|
||||||
if (doc["Camper"].contains("Items") && doc["Camper"]["Items"].is_array())
|
|
||||||
for (const auto& item : doc["Camper"]["Items"])
|
|
||||||
if (item.is_string()) _camperItemIds.insert(item.get<std::string>());
|
|
||||||
|
|
||||||
if (doc.contains("Slasher") && doc["Slasher"].is_object())
|
|
||||||
if (doc["Slasher"].contains("Powers") && doc["Slasher"]["Powers"].is_array())
|
|
||||||
for (const auto& item : doc["Slasher"]["Powers"])
|
|
||||||
if (item.is_string()) _slasherPowerIds.insert(item.get<std::string>());
|
|
||||||
}
|
|
||||||
catch (const json::parse_error& e)
|
|
||||||
{
|
|
||||||
Log::error("JSON parse error in {}: {}", "items.json", e.what());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Log::warning("Missing items.json");
|
|
||||||
|
|
||||||
std::string offeringDumpPath = getExeDir() + "offerings.json";
|
|
||||||
std::ifstream offeringsFile(offeringDumpPath);
|
|
||||||
if (offeringsFile.is_open())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::string content((std::istreambuf_iterator<char>(offeringsFile)), std::istreambuf_iterator<char>());
|
|
||||||
json doc = json::parse(content);
|
|
||||||
|
|
||||||
if (doc.contains("Slashers") && doc["Slashers"].is_array())
|
|
||||||
for (const auto& offering : doc["Slashers"])
|
|
||||||
if (offering.is_string()) _slasherOfferingIds.insert(offering.get<std::string>());
|
|
||||||
|
|
||||||
if (doc.contains("Campers") && doc["Campers"].is_array())
|
|
||||||
for (const auto& offering : doc["Campers"])
|
|
||||||
if (offering.is_string()) _camperOfferingIds.insert(offering.get<std::string>());
|
|
||||||
}
|
|
||||||
catch (const json::parse_error& e)
|
|
||||||
{
|
|
||||||
Log::error("JSON parse error in {}: {}", "offerings.json", e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Log::warning("Missing offerings.json");
|
|
||||||
|
|
||||||
std::string addonDumpPath = getExeDir() + "addons.json";
|
|
||||||
std::ifstream addonFile(addonDumpPath);
|
|
||||||
if (addonFile.is_open())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::string content((std::istreambuf_iterator<char>(addonFile)), std::istreambuf_iterator<char>());
|
|
||||||
json doc = json::parse(content);
|
|
||||||
|
|
||||||
if (doc.contains("Slashers") && doc["Slashers"].is_array())
|
|
||||||
for (const auto& item : doc["Slashers"])
|
|
||||||
if (item.is_string()) _slasherAddonIds.insert(item.get<std::string>());
|
|
||||||
|
|
||||||
if (doc.contains("Campers") && doc["Campers"].is_array())
|
|
||||||
for (const auto& power : doc["Campers"])
|
|
||||||
if (power.is_string()) _camperAddonIds.insert(power.get<std::string>());
|
|
||||||
}
|
|
||||||
catch (const json::parse_error& e)
|
|
||||||
{
|
|
||||||
Log::error("JSON parse error in {}: {}", "addons.json", e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Log::warning("Missing addons.json");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string perkDumpPaths = getExeDir() + "perks.json";
|
const auto& catalogData = doc.at("data");
|
||||||
std::ifstream perkFile(perkDumpPaths);
|
|
||||||
if (perkFile.is_open())
|
|
||||||
{
|
|
||||||
std::string content((std::istreambuf_iterator<char>(perkFile)), std::istreambuf_iterator<char>());
|
|
||||||
json doc = json::parse(content);
|
|
||||||
|
|
||||||
if (doc.contains("Slashers") && doc["Slashers"].is_array())
|
auto extractIds = [&](const std::string& key, std::unordered_set<std::string>& targetSet) {
|
||||||
for (const auto& item : doc["Slashers"])
|
if (catalogData.contains(key) && catalogData[key].contains("items"))
|
||||||
if (item.is_string()) _slasherPerkIds.insert(item.get<std::string>());
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
if (doc.contains("Campers") && doc["Campers"].is_array())
|
extractIds("item", _catalogItemIds);
|
||||||
for (const auto& power : doc["Campers"])
|
extractIds("outfit", _catalogOutfitIds);
|
||||||
if (power.is_string()) _camperPerkIds.insert(power.get<std::string>());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Log::warning("Missing perks.json");
|
|
||||||
}
|
}
|
||||||
catch (const json::parse_error& e)
|
catch (const json::exception& e)
|
||||||
{
|
{
|
||||||
Log::error("JSON parse error in {}: {}", "perks.json", e.what());
|
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);
|
||||||
|
if (doc.is_discarded())
|
||||||
|
{
|
||||||
|
Log::error("JSON parse error @ parseStackable");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto populate = [&](const std::string& key, std::unordered_set<std::string>& targetSet) {
|
||||||
|
if (doc.contains(key) && doc[key].is_array())
|
||||||
|
for (const auto& item : doc[key])
|
||||||
|
if (item.is_string())
|
||||||
|
targetSet.insert(item.get<std::string>());
|
||||||
|
else
|
||||||
|
Log::warning("Missing stackables array ({})", key);
|
||||||
|
};
|
||||||
|
|
||||||
|
populate("Slashers", slasherSet);
|
||||||
|
populate("Campers", camperSet);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
misc functions
|
||||||
|
*/
|
||||||
|
std::string Spoofer::getRandomItem()
|
||||||
|
{
|
||||||
|
std::vector<const std::unordered_set<std::string>*> allSets = {
|
||||||
|
&_camperItemIds, &_slasherPowerIds, &_camperOfferingIds, &_slasherOfferingIds,
|
||||||
|
&_camperAddonIds, &_slasherAddonIds, &_camperPerkIds, &_slasherPerkIds};
|
||||||
|
|
||||||
|
std::vector<const std::unordered_set<std::string>*> validSets;
|
||||||
|
for (auto* s : allSets)
|
||||||
|
if (!s->empty()) validSets.push_back(s);
|
||||||
|
|
||||||
|
if (validSets.empty()) return "Spring2024Offering";
|
||||||
|
|
||||||
|
std::uniform_int_distribution<> setDist(0, static_cast<int>(validSets.size()) - 1);
|
||||||
|
const auto& selectedSet = *validSets[setDist(gen)];
|
||||||
|
|
||||||
|
std::uniform_int_distribution<> itemDist(0, static_cast<int>(selectedSet.size()) - 1);
|
||||||
|
auto it = selectedSet.begin();
|
||||||
|
std::advance(it, itemDist(gen));
|
||||||
|
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Spoofer::getRandomQuantity()
|
||||||
|
{
|
||||||
|
std::uniform_int_distribution<> dist(64, 97);
|
||||||
|
return dist(gen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spoofer::generateBloodweb(nlohmann::json& js)
|
||||||
|
{
|
||||||
|
if (!js.is_object()) js = json::object();
|
||||||
|
|
||||||
|
std::vector<std::string> paths;
|
||||||
|
json ringDataArray = json::array();
|
||||||
|
|
||||||
|
ringDataArray.push_back({{"nodeData", {{{"nodeId", "0"}, {"state", "Collected"}}}}});
|
||||||
|
|
||||||
|
int nodesPerRing[] = {6, 12, 12};
|
||||||
|
std::vector<std::string> prevRingNodes = {"0"};
|
||||||
|
|
||||||
|
for (int ring = 1; ring <= 3; ++ring)
|
||||||
|
{
|
||||||
|
json nodeDataArray = json::array();
|
||||||
|
std::vector<std::string> currentRingNodes;
|
||||||
|
int numNodes = nodesPerRing[ring - 1];
|
||||||
|
|
||||||
|
for (int i = 1; i <= numNodes; ++i)
|
||||||
|
{
|
||||||
|
std::string childId = std::to_string((ring * 100) + i);
|
||||||
|
currentRingNodes.push_back(childId);
|
||||||
|
|
||||||
|
int parentIndex = (i - 1) / (numNodes / static_cast<int>(prevRingNodes.size()));
|
||||||
|
std::string parentId = prevRingNodes[(std::min)(parentIndex, (int)prevRingNodes.size() - 1)];
|
||||||
|
|
||||||
|
paths.push_back(parentId + "_" + childId);
|
||||||
|
|
||||||
|
std::string item = getRandomItem();
|
||||||
|
if (item.empty()) item = "Spring2024Offering";
|
||||||
|
|
||||||
|
nodeDataArray.push_back({{"nodeId", childId}, {"state", "Collected"}, {"contentId", item}});
|
||||||
|
}
|
||||||
|
ringDataArray.push_back({{"nodeData", nodeDataArray}});
|
||||||
|
prevRingNodes = std::move(currentRingNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
js["paths"] = paths;
|
||||||
|
js["ringData"] = ringDataArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
data modification
|
||||||
|
*/
|
||||||
|
void Spoofer::modifyCharacterData(json& js)
|
||||||
|
{
|
||||||
|
if (!js.contains("characterName") || !js["characterName"].is_string())
|
||||||
|
{
|
||||||
|
Log::verbose("attempted to modify invalid char");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info("Loaded: Camper items={}, Slasher powers={}, "
|
std::string name = js["characterName"];
|
||||||
"Slasher addons={}, Camper addons={}, Camper perks={}, Slasher perks={}"
|
bool slasher = isSlasher(js["characterName"]);
|
||||||
"Slasher offerings={}, Camper offerings={}",
|
|
||||||
_camperItemIds.size(), _slasherPowerIds.size(), _slasherAddonIds.size(), _camperAddonIds.size(),
|
|
||||||
_camperPerkIds.size(), _slasherPerkIds.size(), _slasherOfferingIds.size(), _camperOfferingIds.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Spoofer::parseCatalog(std::string data)
|
bool needsSpoofing = false;
|
||||||
{
|
if (js.value("isEntitled", true) == false)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
json doc = json::parse(data);
|
_unownedCharacters.insert(name);
|
||||||
|
js["isEntitled"] = true;
|
||||||
if (doc.contains("data")) doc = doc["data"];
|
js["purchaseInfo"] = {{"quantity", 1},
|
||||||
|
{"origin", "PlayerInventory"},
|
||||||
if (doc.contains("item") && doc["item"].contains("items") && doc["item"]["items"].is_array())
|
{"reason", "Item(s) added via Purchase"},
|
||||||
for (const auto& item : doc["item"]["items"])
|
{"lastUpdateAt", std::time(nullptr)},
|
||||||
if (item.is_string()) _catalogItemIds.insert(item.get<std::string>());
|
{"objectId", name}};
|
||||||
|
needsSpoofing = true;
|
||||||
if (doc.contains("outfit") && doc["outfit"].contains("items") && doc["outfit"]["items"].is_array())
|
|
||||||
for (const auto& item : doc["outfit"]["items"])
|
|
||||||
if (item.is_string()) _catalogOutfitIds.insert(item.get<std::string>());
|
|
||||||
|
|
||||||
Log::info("Parsed {} items and {} outfits from catalog", _catalogItemIds.size(), _catalogOutfitIds.size());
|
|
||||||
}
|
}
|
||||||
catch (const json::parse_error& e)
|
else if (_unownedCharacters.contains(name))
|
||||||
|
needsSpoofing = true;
|
||||||
|
|
||||||
|
/*
|
||||||
|
modifications for unowned characters (spoof level and fake bloodweb)
|
||||||
|
*/
|
||||||
|
if (needsSpoofing)
|
||||||
{
|
{
|
||||||
Log::error("JSON parse error in {}: {}", "parseCatalog", e.what());
|
if (js.contains("bloodWebLevel") && js["bloodWebLevel"].is_number() && js["bloodWebLevel"] <= 15)
|
||||||
|
if (!js.contains("prestigeLevel") || (js["prestigeLevel"].is_number() && js["prestigeLevel"] <= 0))
|
||||||
|
js["bloodWebLevel"] = 16;
|
||||||
|
|
||||||
|
if (js.contains("bloodWebData")) generateBloodweb(js["bloodWebData"]);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
void Spoofer::parseAndDumpCatalog(std::string& data)
|
|
||||||
{
|
|
||||||
std::string path = getExeDir() + "catalog.json";
|
|
||||||
std::ofstream file(path);
|
|
||||||
file << data;
|
|
||||||
file.close();
|
|
||||||
Log::info("Raw catalog saved to {}", path);
|
|
||||||
|
|
||||||
parseCatalog(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_set<std::string> killerNames = {
|
|
||||||
"Chuckles", "Bob", "HillBilly", "Nurse", "Shape", "Witch", "Killer07", "Cannibal", "Bear",
|
|
||||||
"Nightmare", "Pig", "Clown", "Spirit", "Plague", "Ghostface", "Demogorgon", "Oni", "Gunslinger"};
|
|
||||||
|
|
||||||
void Spoofer::modifyCharacterData(json& js)
|
|
||||||
{
|
|
||||||
std::unordered_set<std::string> existingItemIds;
|
|
||||||
bool isSlasher = false;
|
|
||||||
|
|
||||||
if (js.contains("characterName") && js["characterName"].is_string())
|
|
||||||
{
|
{
|
||||||
std::string name = js["characterName"];
|
/*
|
||||||
if (killerNames.contains(name) || (name.length() == 3 && name[0] == 'K')) isSlasher = true;
|
ghost node hotfix (untested)
|
||||||
}
|
*/
|
||||||
|
/* if (js.contains("bloodWebData") && js["bloodWebData"].contains("ringData"))
|
||||||
if (js.contains("prestigeLevel") && js["prestigeLevel"].get<int>() <= 1)
|
|
||||||
if (js.contains("bloodWebLevel") && js["bloodWebLevel"].get<int>() <= 15) js["bloodWebLevel"] = 16;
|
|
||||||
|
|
||||||
if (js.contains("bloodWebData"))
|
|
||||||
{
|
|
||||||
static std::random_device rd;
|
|
||||||
static std::mt19937 rng(rd());
|
|
||||||
|
|
||||||
std::unordered_set<std::string> stackableIds;
|
|
||||||
stackableIds.insert(_camperItemIds.begin(), _camperItemIds.end());
|
|
||||||
stackableIds.insert(_camperOfferingIds.begin(), _camperOfferingIds.end());
|
|
||||||
stackableIds.insert(_camperAddonIds.begin(), _camperAddonIds.end());
|
|
||||||
stackableIds.insert(_slasherAddonIds.begin(), _slasherAddonIds.end());
|
|
||||||
stackableIds.insert(_slasherOfferingIds.begin(), _slasherOfferingIds.end());
|
|
||||||
|
|
||||||
std::string selectedContentId = "Spring2024Offering";
|
|
||||||
auto it = stackableIds.begin();
|
|
||||||
std::advance(it, std::uniform_int_distribution<>(0, static_cast<int>(_camperOfferingIds.size()) - 1)(rng));
|
|
||||||
selectedContentId = *it;
|
|
||||||
|
|
||||||
std::vector<std::string> paths;
|
|
||||||
json ringDataArray = json::array();
|
|
||||||
|
|
||||||
ringDataArray.push_back({{"nodeData", json::array({{{"nodeId", "0"}, {"state", "Collected"}}})}});
|
|
||||||
|
|
||||||
int nodesPerRing[] = {6, 12, 12};
|
|
||||||
std::vector<std::string> prevRingNodes = {"0"};
|
|
||||||
|
|
||||||
for (int ring = 1; ring <= 3; ++ring)
|
|
||||||
{
|
{
|
||||||
json nodeDataArray = json::array();
|
auto& ringData = js["bloodWebData"]["ringData"];
|
||||||
std::vector<std::string> currentRingNodes;
|
|
||||||
int numNodes = nodesPerRing[ring - 1];
|
|
||||||
|
|
||||||
for (int i = 1; i <= numNodes; ++i)
|
for (auto& ring : ringData)
|
||||||
{
|
{
|
||||||
std::string childId = std::to_string((ring * 100) + i);
|
if (ring.contains("nodeData") && ring["nodeData"].is_array())
|
||||||
currentRingNodes.push_back(childId);
|
{
|
||||||
|
for (auto& node : ring["nodeData"])
|
||||||
int parentIndex = (i - 1) / (numNodes / static_cast<int>(prevRingNodes.size()));
|
{
|
||||||
|
if (node.contains("nodeId") && node["nodeId"] != "0")
|
||||||
if (parentIndex >= prevRingNodes.size()) parentIndex = static_cast<int>(prevRingNodes.size()) - 1;
|
{
|
||||||
|
if (!node.contains("contentId") || node["contentId"].get<std::string>().empty())
|
||||||
std::string parentId = prevRingNodes[parentIndex];
|
{
|
||||||
paths.push_back(parentId + "_" + childId);
|
node["contentId"] = "Spring2024Offering";
|
||||||
|
if (!node.contains("state"))
|
||||||
nodeDataArray.push_back(
|
node["state"] = "Available";
|
||||||
{{"nodeId", childId}, {"state", "Collected"}, {"contentId", selectedContentId}});
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
ringDataArray.push_back({{"nodeData", nodeDataArray}});
|
|
||||||
prevRingNodes = std::move(currentRingNodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
js["bloodWebData"]["paths"] = paths;
|
|
||||||
js["bloodWebData"]["ringData"] = ringDataArray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
item spoofing
|
||||||
|
*/
|
||||||
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> 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());
|
||||||
@@ -284,256 +312,187 @@ void Spoofer::modifyCharacterData(json& js)
|
|||||||
|
|
||||||
for (auto& item : js["characterItems"])
|
for (auto& item : js["characterItems"])
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
set existing items to rnd number
|
||||||
|
*/
|
||||||
if (item.contains("itemId") && item["itemId"].is_string())
|
if (item.contains("itemId") && item["itemId"].is_string())
|
||||||
{
|
{
|
||||||
std::string itemId = item["itemId"];
|
std::string itemId = item["itemId"];
|
||||||
existingItemIds.insert(itemId);
|
existingItemIds.insert(itemId);
|
||||||
|
if (stackableIds.contains(itemId)) item["quantity"] = getRandomQuantity();
|
||||||
if (_slasherPowerIds.find(itemId) != _slasherPowerIds.end())
|
|
||||||
isSlasher = true;
|
|
||||||
else if (stackableIds.contains(itemId))
|
|
||||||
item["quantity"] = 100;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSlasher)
|
auto appendItems = [&](const std::unordered_set<std::string>& idList, bool isPerk) {
|
||||||
|
for (const auto& itemId : idList)
|
||||||
|
if (existingItemIds.find(itemId) == existingItemIds.end())
|
||||||
|
js["characterItems"].push_back(
|
||||||
|
{{"itemId", itemId}, {"quantity", isPerk ? 3 : getRandomQuantity()}});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!slasher)
|
||||||
{
|
{
|
||||||
for (const std::string& itemId : _camperItemIds)
|
appendItems(_camperItemIds, false);
|
||||||
if (existingItemIds.find(itemId) == existingItemIds.end())
|
appendItems(_camperAddonIds, false);
|
||||||
js["characterItems"].push_back({{"itemId", itemId}, {"quantity", 100}});
|
appendItems(_camperOfferingIds, false);
|
||||||
for (const std::string& itemId : _camperAddonIds)
|
appendItems(_camperPerkIds, true);
|
||||||
if (existingItemIds.find(itemId) == existingItemIds.end())
|
|
||||||
js["characterItems"].push_back({{"itemId", itemId}, {"quantity", 100}});
|
|
||||||
for (const std::string& itemId : _camperOfferingIds)
|
|
||||||
if (existingItemIds.find(itemId) == existingItemIds.end())
|
|
||||||
js["characterItems"].push_back({{"itemId", itemId}, {"quantity", 100}});
|
|
||||||
for (const std::string& itemId : _camperPerkIds)
|
|
||||||
if (existingItemIds.find(itemId) == existingItemIds.end())
|
|
||||||
js["characterItems"].push_back({{"itemId", itemId}, {"quantity", 3}});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (const std::string& itemId : _slasherAddonIds)
|
appendItems(_slasherAddonIds, false);
|
||||||
if (existingItemIds.find(itemId) == existingItemIds.end())
|
appendItems(_slasherOfferingIds, false);
|
||||||
js["characterItems"].push_back({{"itemId", itemId}, {"quantity", 100}});
|
appendItems(_slasherPerkIds, true);
|
||||||
for (const std::string& itemId : _slasherOfferingIds)
|
|
||||||
if (existingItemIds.find(itemId) == existingItemIds.end())
|
|
||||||
js["characterItems"].push_back({{"itemId", itemId}, {"quantity", 100}});
|
|
||||||
for (const std::string& itemId : _slasherPerkIds)
|
|
||||||
if (existingItemIds.find(itemId) == existingItemIds.end())
|
|
||||||
js["characterItems"].push_back({{"itemId", itemId}, {"quantity", 3}});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::verbose("Spoofed data for character {}", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
endpoint handlers
|
||||||
|
*/
|
||||||
|
void Spoofer::onGetAll(std::string& body)
|
||||||
|
{
|
||||||
|
json doc = json::parse(body, nullptr, false);
|
||||||
|
if (doc.is_discarded()) return Log::error("JSON parse error for dbd-character-data/get-all");
|
||||||
|
if (!doc.contains("list") || !doc["list"].is_array())
|
||||||
|
return Log::error("Invalid json for dbd-character-data/get-all");
|
||||||
|
|
||||||
|
for (auto& charData : doc["list"])
|
||||||
|
modifyCharacterData(charData);
|
||||||
|
|
||||||
|
body = doc.dump();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spoofer::onInventoryAll(std::string& body)
|
||||||
|
{
|
||||||
|
json doc = json::parse(body, nullptr, false);
|
||||||
|
if (doc.is_discarded()) return Log::error("JSON parse error for dbd-inventories/all");
|
||||||
|
if (!doc.contains("inventoryItems") || !doc["inventoryItems"].is_array())
|
||||||
|
return Log::error("Invalid json for JSON parse error for dbd-inventories/all");
|
||||||
|
|
||||||
|
auto& itemsArr = doc["inventoryItems"];
|
||||||
|
std::unordered_set<std::string> existingIds;
|
||||||
|
int64_t now = std::time(nullptr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
item updates
|
||||||
|
*/
|
||||||
|
struct Category
|
||||||
|
{
|
||||||
|
const std::unordered_set<std::string>& source;
|
||||||
|
int quantity;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Category> categories = {{_camperPerkIds, 3}, {_slasherPerkIds, 3}, {_camperOfferingIds, -1},
|
||||||
|
{_slasherOfferingIds, -1}, {_catalogOutfitIds, 1}, {_catalogItemIds, 1}};
|
||||||
|
|
||||||
|
for (auto& item : itemsArr)
|
||||||
|
{
|
||||||
|
std::string id = item.value("objectId", "");
|
||||||
|
if (id.empty()) continue;
|
||||||
|
|
||||||
|
existingIds.insert(id);
|
||||||
|
|
||||||
|
for (const auto& cat : categories)
|
||||||
|
{
|
||||||
|
if (cat.source.contains(id))
|
||||||
|
{
|
||||||
|
item["quantity"] = (cat.quantity == -1) ? getRandomQuantity() : cat.quantity;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
item inserts
|
||||||
|
*/
|
||||||
|
for (const auto& cat : categories)
|
||||||
|
{
|
||||||
|
for (const std::string& id : cat.source)
|
||||||
|
{
|
||||||
|
if (!existingIds.contains(id))
|
||||||
|
{
|
||||||
|
int qty = (cat.quantity == -1) ? getRandomQuantity() : cat.quantity;
|
||||||
|
itemsArr.push_back({{"objectId", id}, {"quantity", qty}, {"lastUpdateAt", now}});
|
||||||
|
existingIds.insert(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body = doc.dump();
|
||||||
|
Log::verbose("Inventory spoofed");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
||||||
|
{
|
||||||
|
json doc = json::parse(body, nullptr, false);
|
||||||
|
if (doc.is_discarded()) return Log::error("JSON parse error for bloodweb response");
|
||||||
|
|
||||||
|
if (body.find("NotAllowedException") != std::string::npos && body.find("not owned") != std::string::npos)
|
||||||
|
{
|
||||||
|
Log::info("Spoofing bloodweb error for unowned character");
|
||||||
|
json mock;
|
||||||
|
mock["bloodWebLevelChanged"] = false;
|
||||||
|
mock["updatedWallets"] = json::array();
|
||||||
|
mock["bloodWebLevel"] = 16;
|
||||||
|
mock["prestigeLevel"] = 0;
|
||||||
|
mock["bloodWebData"] = json::object();
|
||||||
|
mock["characterItems"] = json::array();
|
||||||
|
mock["characterName"] = this->_lastBloodWebChar;
|
||||||
|
mock["isEntitled"] = true;
|
||||||
|
mock["purchaseInfo"] = {{"quantity", 1},
|
||||||
|
{"origin", "PlayerInventory"},
|
||||||
|
{"reason", "Item(s) added via Purchase"},
|
||||||
|
{"lastUpdateAt", std::time(nullptr)},
|
||||||
|
{"objectId", this->_lastBloodWebChar}};
|
||||||
|
|
||||||
|
_unownedCharacters.insert(this->_lastBloodWebChar); // probably not needed but just in case
|
||||||
|
|
||||||
|
modifyCharacterData(mock);
|
||||||
|
|
||||||
|
std::regex statusRegex(R"(HTTP\/\d\.\d\s+403)");
|
||||||
|
respHeaders = std::regex_replace(respHeaders, statusRegex, "HTTP/1.1 200");
|
||||||
|
|
||||||
|
body = mock.dump();
|
||||||
|
Log::verbose("Spoofed bloodweb request for unowned character.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modifyCharacterData(doc);
|
||||||
|
body = doc.dump();
|
||||||
|
Log::verbose("Spoofed bloodweb items for owned character");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
event handlers
|
||||||
|
*/
|
||||||
void Spoofer::serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders)
|
void Spoofer::serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders)
|
||||||
{
|
{
|
||||||
|
if (url.find("bhvrdbd.com") == std::string::npos) return;
|
||||||
|
std::lock_guard<std::mutex> lock(_mtx);
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (url.find("bhvrdbd.com") != std::string::npos) 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 parseAndDumpCatalog(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)
|
if (url.find("api/v1/dbd-character-data/bloodweb") != std::string::npos ||
|
||||||
{
|
url.find("api/v1/dbd-character-data/bulk-spending-bloodweb") != std::string::npos)
|
||||||
try
|
return onBloodweb(body, respHeaders);
|
||||||
{
|
|
||||||
json doc = json::parse(body);
|
|
||||||
auto& itemsArr = doc["inventoryItems"];
|
|
||||||
|
|
||||||
std::unordered_set<std::string> foundObjects;
|
|
||||||
std::unordered_set<std::string> foundAddons;
|
|
||||||
std::unordered_set<std::string> foundPerks;
|
|
||||||
std::unordered_set<std::string> foundOfferings;
|
|
||||||
std::unordered_set<std::string> foundCatalogItems;
|
|
||||||
|
|
||||||
std::unordered_set<std::string> offeringIds;
|
|
||||||
offeringIds.insert(_camperOfferingIds.begin(), _camperOfferingIds.end());
|
|
||||||
offeringIds.insert(_slasherOfferingIds.begin(), _slasherOfferingIds.end());
|
|
||||||
|
|
||||||
std::unordered_set<std::string> catalogIds;
|
|
||||||
catalogIds.insert(_catalogOutfitIds.begin(), _catalogOutfitIds.end());
|
|
||||||
catalogIds.insert(_catalogItemIds.begin(), _catalogItemIds.end());
|
|
||||||
|
|
||||||
std::unordered_set<std::string> perkIds;
|
|
||||||
perkIds.insert(_slasherPerkIds.begin(), _slasherPerkIds.end());
|
|
||||||
perkIds.insert(_camperPerkIds.begin(), _camperPerkIds.end());
|
|
||||||
|
|
||||||
for (auto& item : itemsArr)
|
|
||||||
{
|
|
||||||
std::string objectId = item["objectId"];
|
|
||||||
|
|
||||||
if (perkIds.find(objectId) != perkIds.end())
|
|
||||||
{
|
|
||||||
foundPerks.insert(objectId);
|
|
||||||
item["quantity"] = 3;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offeringIds.find(objectId) != offeringIds.end())
|
|
||||||
{
|
|
||||||
foundOfferings.insert(objectId);
|
|
||||||
item["quantity"] = 100;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (catalogIds.find(objectId) != catalogIds.end())
|
|
||||||
{
|
|
||||||
foundCatalogItems.insert(objectId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const std::string& id : perkIds)
|
|
||||||
{
|
|
||||||
if (foundPerks.find(id) == foundPerks.end())
|
|
||||||
{
|
|
||||||
itemsArr.push_back({
|
|
||||||
{"objectId", id},
|
|
||||||
{"quantity", 3},
|
|
||||||
{"lastUpdateAt", std::time(nullptr)},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const std::string& id : offeringIds)
|
|
||||||
{
|
|
||||||
if (foundOfferings.find(id) == foundOfferings.end())
|
|
||||||
{
|
|
||||||
itemsArr.push_back({
|
|
||||||
{"objectId", id},
|
|
||||||
{"quantity", 100},
|
|
||||||
{"lastUpdateAt", std::time(nullptr)},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const std::string& id : catalogIds)
|
|
||||||
{
|
|
||||||
if (foundCatalogItems.find(id) == foundCatalogItems.end())
|
|
||||||
{
|
|
||||||
itemsArr.push_back({
|
|
||||||
{"objectId", id},
|
|
||||||
{"quantity", 1},
|
|
||||||
{"lastUpdateAt", std::time(nullptr)},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string updatedJson = doc.dump();
|
|
||||||
body = updatedJson;
|
|
||||||
|
|
||||||
Log::verbose("Inventory updated: Items={}, Addons={}, Perks={}, Offerings={}", foundObjects.size(),
|
|
||||||
foundAddons.size(), foundPerks.size(), foundOfferings.size());
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (const json::parse_error& e)
|
|
||||||
{
|
|
||||||
Log::error("JSON parse error in {}: {}", url, e.what());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url.find("api/v1/dbd-character-data/get-all") != std::string::npos)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
json doc = json::parse(body);
|
|
||||||
auto& charList = doc["list"];
|
|
||||||
|
|
||||||
for (auto& charInfo : charList)
|
|
||||||
{
|
|
||||||
if (charInfo.contains("bloodWebLevel") && charInfo.at("bloodWebLevel").get<int>() <= 15)
|
|
||||||
if (!charInfo.contains("prestigeLevel") || charInfo.at("prestigeLevel").get<int>() <= 0)
|
|
||||||
charInfo["bloodWebLevel"] = 16;
|
|
||||||
|
|
||||||
if (charInfo.contains("bloodWebData") && charInfo.at("bloodWebData").contains("level"))
|
|
||||||
charInfo["bloodWebData"]["level"] = 1;
|
|
||||||
|
|
||||||
if (charInfo["isEntitled"] == false)
|
|
||||||
{
|
|
||||||
charInfo["isEntitled"] = true;
|
|
||||||
if (charInfo.contains("origin"))
|
|
||||||
{
|
|
||||||
charInfo["purchaseInfo"] = {{"quantity", 1},
|
|
||||||
{"origin", "PlayerInventory"},
|
|
||||||
{"reason", "Item(s) added via Purchase"},
|
|
||||||
{"lastUpdateAt", 1770702482},
|
|
||||||
{"objectId", charInfo["characterName"]}};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
modifyCharacterData(charInfo);
|
|
||||||
}
|
|
||||||
body = doc.dump();
|
|
||||||
}
|
|
||||||
catch (const json::parse_error& e)
|
|
||||||
{
|
|
||||||
Log::error("JSON parse error in {}: {}", url, e.what());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url.find("api/v1/dbd-character-data/") != std::string::npos)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
json doc = json::parse(body);
|
|
||||||
|
|
||||||
if (body.find("NotAllowedException") != std::string::npos && body.find("not owned") != std::string::npos)
|
|
||||||
{
|
|
||||||
Log::info("Spoofing bloodweb error for unowned character");
|
|
||||||
json mock;
|
|
||||||
mock["bloodWebLevelChanged"] = false;
|
|
||||||
mock["updatedWallets"] = json::array();
|
|
||||||
mock["bloodWebLevel"] = 16;
|
|
||||||
mock["prestigeLevel"] = 0;
|
|
||||||
mock["bloodWebData"] = {{"ringData", json::array()}, {"paths", json::array()}};
|
|
||||||
mock["characterItems"] = json::array();
|
|
||||||
mock["characterName"] = this->_lastBloodWebChar;
|
|
||||||
|
|
||||||
modifyCharacterData(mock);
|
|
||||||
|
|
||||||
size_t firstSpace = respHeaders.find(' ');
|
|
||||||
if (firstSpace != std::string::npos) respHeaders.replace(firstSpace + 1, 3, "200");
|
|
||||||
|
|
||||||
body = mock.dump();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
modifyCharacterData(doc);
|
|
||||||
body = doc.dump();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (const json::parse_error& e)
|
|
||||||
{
|
|
||||||
Log::error("JSON parse error in {}: {}", url, e.what());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spoofer::clientRequestHandler(std::string& url, const std::string& body, std::string& /*reqHeaders*/)
|
void Spoofer::clientRequestHandler(std::string& url, const std::string& body, std::string& /*reqHeaders*/)
|
||||||
{
|
{
|
||||||
|
if (url.find("bhvrdbd.com") == std::string::npos) return;
|
||||||
|
std::lock_guard<std::mutex> lock(_mtx);
|
||||||
|
|
||||||
if (url.find("api/v1/dbd-character-data/bloodweb") != std::string::npos ||
|
if (url.find("api/v1/dbd-character-data/bloodweb") != std::string::npos ||
|
||||||
url.find("api/v1/dbd-character-data/bulk-spending-bloodweb") != std::string::npos)
|
url.find("api/v1/dbd-character-data/bulk-spending-bloodweb") != std::string::npos)
|
||||||
{
|
{
|
||||||
try
|
json req = json::parse(body, nullptr, false);
|
||||||
{
|
if (req.is_discarded()) return Log::error("JSON parse error for bloodweb request handler");
|
||||||
json req = json::parse(body);
|
if (req.contains("characterName")) this->_lastBloodWebChar = req["characterName"];
|
||||||
if (req.contains("characterName"))
|
|
||||||
{
|
|
||||||
this->_lastBloodWebChar = req["characterName"];
|
|
||||||
Log::info("Detected bloodweb request for character: {}", this->_lastBloodWebChar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-4
@@ -5,6 +5,8 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include <nlohmann/json_fwd.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
class Spoofer
|
class Spoofer
|
||||||
@@ -16,11 +18,20 @@ class Spoofer
|
|||||||
void registerListeners(Proxy* proxy);
|
void registerListeners(Proxy* proxy);
|
||||||
void loadData();
|
void loadData();
|
||||||
|
|
||||||
void parseCatalog(std::string data);
|
bool parseCatalog(std::string data);
|
||||||
|
bool parseStackable(std::string data, std::unordered_set<std::string>& camperSet,
|
||||||
|
std::unordered_set<std::string>& slasherSet);
|
||||||
|
|
||||||
void parseAndDumpCatalog(std::string& data);
|
std::string getRandomItem();
|
||||||
|
int getRandomQuantity();
|
||||||
|
|
||||||
|
void generateBloodweb(nlohmann::json& data);
|
||||||
void modifyCharacterData(nlohmann::json& js);
|
void modifyCharacterData(nlohmann::json& js);
|
||||||
|
|
||||||
|
void onGetAll(std::string& body);
|
||||||
|
void onInventoryAll(std::string& body);
|
||||||
|
void onBloodweb(std::string& body, std::string& respHeaders);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@@ -33,11 +44,14 @@ class Spoofer
|
|||||||
std::unordered_set<std::string> _camperAddonIds;
|
std::unordered_set<std::string> _camperAddonIds;
|
||||||
std::unordered_set<std::string> _slasherAddonIds;
|
std::unordered_set<std::string> _slasherAddonIds;
|
||||||
|
|
||||||
std::unordered_set<std::string> _slasherPerkIds;
|
|
||||||
std::unordered_set<std::string> _camperPerkIds;
|
std::unordered_set<std::string> _camperPerkIds;
|
||||||
|
std::unordered_set<std::string> _slasherPerkIds;
|
||||||
|
|
||||||
std::unordered_set<std::string> _catalogOutfitIds;
|
std::unordered_set<std::string> _catalogOutfitIds;
|
||||||
std::unordered_set<std::string> _catalogItemIds;
|
std::unordered_set<std::string> _catalogItemIds;
|
||||||
|
|
||||||
std::string _lastBloodWebChar = "Ace";
|
std::unordered_set<std::string> _unownedCharacters;
|
||||||
|
|
||||||
|
std::string _lastBloodWebChar = "";
|
||||||
|
std::mutex _mtx;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user