Skip to content

Commit 193d761

Browse files
Merge pull request #32 from autumnlikescode/main
Update x64 library for tokens
2 parents 79f9ad4 + 5c9e1cb commit 193d761

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

auth.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,40 @@ void KeyAuth::api::init()
101101
XorStr("&enckey=") + sentKey +
102102
XorStr("&name=") + curl_easy_escape(curl, name.c_str(), 0) +
103103
XorStr("&ownerid=") + ownerid;
104+
105+
if (path != "" || !path.empty()) {
106+
107+
if (!std::filesystem::exists(path)) {
108+
MessageBoxA(0, XorStr("File not found. Please make sure the file exists.").c_str(), NULL, MB_ICONERROR);
109+
exit(0);
110+
}
111+
//get the contents of the file
112+
std::ifstream file(path);
113+
std::string token;
114+
std::string thash;
115+
std::getline(file, token);
116+
117+
auto exec = [&](const char* cmd) -> std::string
118+
{
119+
uint16_t line = -1;
120+
std::array<char, 128> buffer;
121+
std::string result;
122+
std::unique_ptr<FILE, decltype(&_pclose)> pipe(_popen(cmd, "r"), _pclose);
123+
if (!pipe) {
124+
throw std::runtime_error(XorStr("popen() failed!"));
125+
}
126+
127+
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
128+
result = buffer.data();
129+
}
130+
return result;
131+
};
132+
133+
thash = exec(("certutil -hashfile \"" + path + XorStr("\" MD5 | find /i /v \"md5\" | find /i /v \"certutil\"")).c_str());
134+
135+
data += XorStr("&token=").c_str() + token;
136+
data += XorStr("&thash=").c_str() + path;
137+
}
104138
curl_easy_cleanup(curl);
105139

106140
auto response = req(data, url);

auth.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ namespace KeyAuth {
1515
class api {
1616
public:
1717

18-
std::string name, ownerid, secret, version, url;
18+
std::string name, ownerid, secret, version, url, path;
1919

20-
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) {}
20+
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) {}
2121

2222
void ban(std::string reason = "");
2323
void init();

0 commit comments

Comments
 (0)