diff --git a/res/characters.json b/res/characters.json new file mode 100644 index 0000000..de6e90b --- /dev/null +++ b/res/characters.json @@ -0,0 +1,95 @@ +[ + "Ace", + "Adam", + "Ash", + "Bear", + "Bill", + "Bob", + "Cannibal", + "Chuckles", + "Claudette", + "Clown", + "Demogorgon", + "Dwight", + "Eric", + "Feng", + "Ghostface", + "Gunslinger", + "HillBilly", + "Jake", + "Jane", + "Jeff", + "K20", + "K21", + "K22", + "K23", + "K24", + "K25", + "K26", + "K27", + "K28", + "K29", + "K30", + "K31", + "K32", + "K33", + "K34", + "K35", + "K36", + "K37", + "K38", + "K39", + "K40", + "K41", + "K42", + "Kate", + "Killer07", + "Laurie", + "Legion", + "Meg", + "Nancy", + "Nea", + "Nightmare", + "Nurse", + "Oni", + "Pig", + "Plague", + "Quentin", + "S22", + "S23", + "S24", + "S25", + "S26", + "S27", + "S28", + "S29", + "S30", + "S31", + "S32", + "S33", + "S34", + "S35", + "S36", + "S37", + "S38", + "S39", + "S40", + "S41", + "S42", + "S43", + "S44", + "S45", + "S46", + "S47", + "S48", + "S49", + "S50", + "S51", + "Shape", + "Smoke", + "Spirit", + "Steve", + "Witch", + "Yui", + "Zarina" +] \ No newline at end of file diff --git a/src/unlocker/spoofing.cpp b/src/unlocker/spoofing.cpp index ab417b3..7e74bf2 100644 --- a/src/unlocker/spoofing.cpp +++ b/src/unlocker/spoofing.cpp @@ -1,4 +1,4 @@ -#include "spoofing.h" +#include "spoofing.h" #include "utils.h" #include @@ -101,6 +101,26 @@ void Spoofer::loadData() Log::verbose("Loaded customizations.json"); } + /* + characters + */ + std::ifstream characterFile(utils::getExePath() + "characters.json"); + if (characterFile.is_open()) + { + std::stringstream buff; + buff << characterFile.rdbuf(); + json doc = json::parse(buff.str(), nullptr, false); + if (doc.is_discarded()) + Log::error("Failed to parse characters.json"); + else + { + for (const auto& character : doc) + { + if (character.is_string()) _characterList.insert(character.get()); + } + } + } + Log::verbose("Finished loading data"); Log::verbose("Items - {} camper", _camperItemIds.size()); @@ -110,6 +130,7 @@ void Spoofer::loadData() Log::verbose("Perks - {} camper | {} slasher ", _camperPerkIds.size(), _slasherPerkIds.size()); Log::verbose("Catalog - {} outfits | {} items", _catalogOutfitIds.size(), _catalogItemIds.size()); + Log::verbose("Characters - {}", _characterList.size()); } void Spoofer::loadConfig() @@ -382,6 +403,30 @@ void Spoofer::modifyCharacterData(json& js) #endif } +void Spoofer::onGetAllClient(std::string& body) +{ + if (!_config.spoofCharacterOwnership) return; + + json doc = json::parse(body, nullptr, false); + if (doc.is_discarded()) return Log::error("JSON parse error for dbd-inventories/all (client)"); + + if (doc.contains("ownedCharacters") && doc["ownedCharacters"].is_array()) + { + auto& jsonList = doc["ownedCharacters"]; + + for (const std::string& charName : _characterList) + { + if (charName == "K25") continue; + + if (std::find(jsonList.begin(), jsonList.end(), charName) == jsonList.end()) + jsonList.push_back(charName); + } + + body = doc.dump(); + Log::verbose("{}", body); + } +} + /* endpoint handlers */ @@ -632,16 +677,13 @@ void Spoofer::serverResponseHandler(const std::string& url, std::string& body, s return onBloodweb(body, respHeaders); } -void Spoofer::clientRequestHandler(std::string& url, const std::string& body, std::string& /*reqHeaders*/) +void Spoofer::clientRequestHandler(const std::string& url, std::string& body, std::string& /*reqHeaders*/) { if (url.find("bhvrdbd.com") == std::string::npos) return; std::lock_guard lock(_mtx); + if (url.find("api/v1/dbd-character-data/get-all") != std::string::npos) return onGetAllClient(body); 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) - { - json req = json::parse(body, nullptr, false); - if (req.is_discarded()) return Log::error("JSON parse error for bloodweb request handler"); - if (req.contains("characterName")) this->_lastBloodWebChar = req["characterName"]; return onBloodwebClient(body); } diff --git a/src/unlocker/spoofing.h b/src/unlocker/spoofing.h index 9180eb1..a0aa923 100644 --- a/src/unlocker/spoofing.h +++ b/src/unlocker/spoofing.h @@ -36,6 +36,7 @@ class Spoofer void generateBloodweb(nlohmann::json& data); void modifyCharacterData(nlohmann::json& js); + void onGetAllClient(std::string& body); void onGetAll(std::string& body); void onInventoryAll(std::string& body); void onMessageList(std::string& body); @@ -63,6 +64,7 @@ class Spoofer std::unordered_set _catalogItemIds; std::unordered_set _unownedCharacters; + std::unordered_set _characterList; std::string _lastBloodWebChar = ""; std::mutex _mtx;