@@ -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);
0 commit comments