feat: handle kiseki.loc/asset redirects

This commit is contained in:
rjindael 2023-09-08 21:17:05 -07:00
parent 73e6fe9c75
commit d73e035dc4
No known key found for this signature in database
GPG Key ID: D069369C906CCF31
3 changed files with 57 additions and 1 deletions

View File

@ -29,5 +29,6 @@ public:
static std::string getModulePath();
static std::string getISOTimestamp();
static std::pair<bool, std::map<std::string, std::string>> parseURL(const std::string url);
static std::string getRedirectURL(const std::string url);
static std::pair<bool, std::string> httpGet(const std::string url);
};

View File

@ -138,6 +138,51 @@ std::string Helpers::getISOTimestamp()
return std::string(buffer);
}
std::string Helpers::getRedirectURL(const std::string url)
{
CURL* curl = curl_easy_init();
CURLcode result;
if (!curl)
{
return url;
}
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0);
curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
result = curl_easy_perform(curl);
if (result != CURLE_OK)
{
return url;
}
long response = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
if (response != 301 && response != 302)
{
return url;
}
char* redirectURL;
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirectURL);
std::string location = redirectURL ? std::string(redirectURL) : "";
curl_easy_cleanup(curl);
if (location.empty())
{
return url;
}
return location;
}
std::pair<bool, std::map<std::string, std::string>> Helpers::parseURL(const std::string url)
{
CURLU* curl = curl_url();

View File

@ -23,11 +23,21 @@ void __fastcall Http__httpGetPostWinInet_hook(Http* _this, void*, bool isPost, i
{
url["path"] = Helpers::toLower(url["path"]);
if (url["host"] == "roblox.com" || url["host"] == "www.roblox.com")
// TODO: This is a weird hack.
if (url["host"] == "kiseki.lol" || url["host"] == "www.kiseki.lol" || url["host"] == "kiseki.loc" || url["host"] == "www.kiseki.loc")
{
if (url["path"] == "/asset" || url["path"] == "/asset/")
{
std::string location = Helpers::getRedirectURL(url["scheme"] + "://" + url["host"] + "/asset?" + url["query"]);
_this = &_changed;
}
}
else if (url["host"] == "roblox.com" || url["host"] == "www.roblox.com")
{
if (url["path"] == "/game/tools/insertasset.ashx")
{
_changed.url = "https://sets.pizzaboxer.xyz/" + url["path"] + "?" + url["query"];
_this = &_changed;
}
else if (url["path"] == "/asset" || url["path"] == "/asset/" || url["path"] == "/asset/default.ashx")
{