Skip to content

Commit

Permalink
Merge pull request #32 from autumnlikescode/main
Browse files Browse the repository at this point in the history
Update x64 library for tokens
  • Loading branch information
Its-Networking authored Jun 13, 2024
2 parents 79f9ad4 + 5c9e1cb commit 193d761
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,40 @@ void KeyAuth::api::init()
XorStr("&enckey=") + sentKey +
XorStr("&name=") + curl_easy_escape(curl, name.c_str(), 0) +
XorStr("&ownerid=") + ownerid;

if (path != "" || !path.empty()) {

if (!std::filesystem::exists(path)) {
MessageBoxA(0, XorStr("File not found. Please make sure the file exists.").c_str(), NULL, MB_ICONERROR);
exit(0);
}
//get the contents of the file
std::ifstream file(path);
std::string token;
std::string thash;
std::getline(file, token);

auto exec = [&](const char* cmd) -> std::string
{
uint16_t line = -1;
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, decltype(&_pclose)> pipe(_popen(cmd, "r"), _pclose);
if (!pipe) {
throw std::runtime_error(XorStr("popen() failed!"));
}

while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result = buffer.data();
}
return result;
};

thash = exec(("certutil -hashfile \"" + path + XorStr("\" MD5 | find /i /v \"md5\" | find /i /v \"certutil\"")).c_str());

data += XorStr("&token=").c_str() + token;
data += XorStr("&thash=").c_str() + path;
}
curl_easy_cleanup(curl);

auto response = req(data, url);
Expand Down
4 changes: 2 additions & 2 deletions auth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace KeyAuth {
class api {
public:

std::string name, ownerid, secret, version, url;
std::string name, ownerid, secret, version, url, path;

api(std::string name, std::string ownerid, std::string secret, std::string version, std::string url) : name(name), ownerid(ownerid), secret(secret), version(version), url(url) {}
api(std::string name, std::string ownerid, std::string secret, std::string version, std::string url, std::string path) : name(name), ownerid(ownerid), secret(secret), version(version), url(url), path(path) {}

void ban(std::string reason = "");
void init();
Expand Down

0 comments on commit 193d761

Please sign in to comment.