This commit is contained in:
@@ -33,6 +33,11 @@ void Spoofer::registerListeners(Proxy* proxy)
|
||||
proxy->OnServerResponse.addListener([this](const std::string& url, std::string& body, std::string& respHeaders) {
|
||||
this->serverResponseHandler(url, body, respHeaders);
|
||||
});
|
||||
|
||||
proxy->OnClientRequest.addListener(
|
||||
[this](const std::string& url, const std::string& body, std::string& reqHeaders) {
|
||||
this->clientRequestHandler(url, body, reqHeaders);
|
||||
});
|
||||
}
|
||||
|
||||
void Spoofer::loadData()
|
||||
@@ -259,7 +264,7 @@ void Spoofer::modifyCharacterData(json& js)
|
||||
}
|
||||
}
|
||||
|
||||
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) Log::verbose("BHVR api res @ {}", url);
|
||||
|
||||
@@ -400,9 +405,37 @@ void Spoofer::serverResponseHandler(const std::string& url, std::string& body, s
|
||||
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 error for unowned character");
|
||||
json mock;
|
||||
mock["bloodWebLevelChanged"] = false;
|
||||
mock["updatedWallets"] = json::array();
|
||||
mock["bloodWebLevel"] = 15;
|
||||
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());
|
||||
@@ -410,3 +443,23 @@ void Spoofer::serverResponseHandler(const std::string& url, std::string& body, s
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Spoofer::clientRequestHandler(const std::string& url, const std::string& body, std::string& /*reqHeaders*/)
|
||||
{
|
||||
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
|
||||
{
|
||||
json req = json::parse(body);
|
||||
if (req.contains("characterName"))
|
||||
{
|
||||
this->_lastBloodWebChar = req["characterName"];
|
||||
Log::info("Detected bloodweb request for character: {}", this->_lastBloodWebChar);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class Spoofer
|
||||
void modifyCharacterData(nlohmann::json& js);
|
||||
|
||||
void serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders);
|
||||
void clientRequestHandler(const std::string& url, const std::string& body, std::string& reqHeaders);
|
||||
|
||||
std::unordered_set<std::string> _camperItemIds;
|
||||
std::unordered_set<std::string> _slasherPowerIds;
|
||||
@@ -37,4 +38,6 @@ class Spoofer
|
||||
|
||||
std::unordered_set<std::string> _catalogOutfitIds;
|
||||
std::unordered_set<std::string> _catalogItemIds;
|
||||
|
||||
std::string _lastBloodWebChar = "Ace";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user