Skip to content

Fixed a bunch of stuff #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 6 additions & 34 deletions auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ void KeyAuth::api::init()
if ((hasher(result ^ 0xA5A5) & 0xFFFF) == (expectedHash & 0xFFFF))
{
auto json = response_decoder.parse(response);
if (json[(XorStr("ownerid"))] != ownerid) {
LI_FN(exit)(8);
}

std::string message = json[(XorStr("message"))];

load_response_data(json);

if (json[(XorStr("ownerid"))] != ownerid) {
LI_FN(exit)(8);
Expand All @@ -188,6 +181,7 @@ void KeyAuth::api::init()
else if (json[(XorStr("message"))] == XorStr("invalidver"))
{
std::string dl = json[(XorStr("download"))];
api::app_data.downloadLink = json[XorStr("download")];
if (dl == "")
{
MessageBoxA(0, XorStr("Version in the loader does match the one on the dashboard, and the download link on dashboard is blank.\n\nTo fix this, either fix the loader so it matches the version on the dashboard. Or if you intended for it to have different versions, update the download link on dashboard so it will auto-update correctly.").c_str(), NULL, MB_ICONERROR);
Expand Down Expand Up @@ -290,26 +284,6 @@ void KeyAuth::api::login(std::string username, std::string password, std::string
file.close();
}

std::string message = json[(XorStr("message"))];

std::hash<int> hasher;
size_t expectedHash = hasher(68);
size_t resultCode = hasher(json[(XorStr("code"))]);

if (!json[(XorStr("success"))] || (json[(XorStr("success"))] && (resultCode == expectedHash))) {
load_response_data(json);
if (json[(XorStr("success"))])
load_user_data(json[(XorStr("info"))]);

if (api::response.message != XorStr("Initialized").c_str()) {
LI_FN(GlobalAddAtomA)(seed.c_str());

std::string file_path = XorStr("C:\\ProgramData\\").c_str() + seed;
std::ofstream file(file_path);
if (file.is_open()) {
file << seed;
file.close();
}
std::string regPath = XorStr("Software\\").c_str() + seed;
HKEY hKey;
LONG result = RegCreateKeyExA(HKEY_CURRENT_USER, regPath.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
Expand Down Expand Up @@ -504,10 +478,6 @@ KeyAuth::api::Tfa& KeyAuth::api::Tfa::handleInput(KeyAuth::api& instance) {
instance.disable2fa(code);
}

}
else {
LI_FN(exit)(7);
}
}

void KeyAuth::api::web_login()
Expand Down Expand Up @@ -1873,8 +1843,6 @@ void checkRegistry() {
LI_FN(RegCloseKey)(hKey);
}
Sleep(1500); // thread interval
Sleep(1500); // thread interval
}
}

std::string checksum()
Expand Down Expand Up @@ -1921,9 +1889,13 @@ void RedactField(nlohmann::json& jsonObject, const std::string& fieldName)
}
}

void debugInfo(std::string data, std::string url, std::string response, std::string headers) {
void KeyAuth::api::debugInfo(std::string data, std::string url, std::string response, std::string headers) {
// output debug logs to C:\ProgramData\KeyAuth\Debug\

if (!KeyAuth::api::debug) {
return;
}

std::string redacted_response = "n/a";
// for logging the headers, since response is not avaliable there
if (response != "n/a") {
Expand Down
10 changes: 8 additions & 2 deletions auth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ namespace KeyAuth {
public:

std::string name, ownerid, version, url, path;
static bool debug;

api(std::string name, std::string ownerid, std::string version, std::string url, std::string path) : name(name), ownerid(ownerid), version(version), url(url), path(path) {}
api(std::string name, std::string ownerid, std::string version, std::string url, std::string path, bool debug = true) {
debug = debug;
}

void ban(std::string reason = "");
void init();
Expand Down Expand Up @@ -70,6 +73,7 @@ namespace KeyAuth {
std::string numKeys;
std::string version;
std::string customerPanelLink;
std::string downloadLink;
};

class responsedata {
Expand Down Expand Up @@ -102,6 +106,8 @@ namespace KeyAuth {
std::string sessionid, enckey;

static std::string req(std::string data, std::string url);

static void debugInfo(std::string data, std::string url, std::string response, std::string headers);


void load_user_data(nlohmann::json data) {
Expand Down Expand Up @@ -131,7 +137,7 @@ namespace KeyAuth {
api::app_data.version = data[XorStr("version")];
api::app_data.customerPanelLink = data[XorStr("customerPanelLink")];
}

void load_response_data(nlohmann::json data) {
api::response.success = data[XorStr("success")];
api::response.message = data["message"];
Expand Down
Loading
Loading