| 197 | } |
| 198 | |
| 199 | bool CInternetAPI::PostData(const std::string & szHost, const std::string & szUrl, const char* c_szFileName, LPBYTE pData, std::size_t ulDataSize) |
| 200 | { |
| 201 | CHAR __formname[] = { 'u', 'p', 'l', 'o', 'a', 'd', 'e', 'd', 'f', 'i', 'l', 'e', 0x0 }; // uploadedfile |
| 202 | CHAR __formfilename[] = { 'L', 'o', 'g', '.', 't', 'x', 't', 0x0 }; // Log.txt |
| 203 | CHAR __boundary[] = { 'M', 'D', '5', '_', '0', 'b', 'e', '6', '3', 'c', 'd', 'a', '3', 'b', 'f', '4', '2', '1', '9', '3', 'e', '4', '3', '0', '3', 'd', 'b', '2', 'c', '5', 'a', 'c', '3', '1', '3', '8', 0x0 }; // MD5_0be63cda3bf42193e4303db2c5ac3138 |
| 204 | std::string boundary(__boundary); |
| 205 | |
| 206 | static std::string hdrs = xorstr("Content-Type: multipart/form-data; boundary=").crypt_get() + boundary; |
| 207 | std::ostringstream head; |
| 208 | head << xorstr("--").crypt_get() << boundary << xorstr("\r\n").crypt_get(); |
| 209 | head << xorstr("Content-Disposition: form-data; name=\"").crypt_get() << __formname << xorstr("\"; filename=\"").crypt_get() << __formfilename << xorstr("\"\r\n").crypt_get(); |
| 210 | head << xorstr("Content-Type: application/octet-stream\r\n").crypt_get(); |
| 211 | head << xorstr("Content-Transfer-Encoding: binary\r\n").crypt_get(); |
| 212 | head << xorstr("\r\n").crypt_get(); |
| 213 | static std::string tail = xorstr("\r\n--").crypt_get() + boundary + xorstr("--\r\n").crypt_get(); |
| 214 | |
| 215 | CHAR __POST[] = { 'P', 'O', 'S', 'T', 0x0 }; // POST |
| 216 | CHAR __HTTPtype[] = { 'H', 'T', 'T', 'P', '/', '1', '.', '1', 0x0 }; // HTTP/1.1 |
| 217 | CHAR __httpUseragent[] = { 'B', 'e', 't', 'a', 'S', 'h', 'i', 'e', 'l', 'd', 'V', '2', ' ', 'A', 'n', 't', 'i', 'c', 'h', 'e', 'a', 't', ' ', 'W', 'e', 'b', ' ', 'A', 'g', 'e', 'n', 't', 0x0 }; // BetaShieldV2 Anticheat Web Agent |
| 218 | |
| 219 | try { |
| 220 | |
| 221 | auto hInternet = g_winapiApiTable->InternetOpenA(__httpUseragent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); |
| 222 | if (hInternet == NULL) { |
| 223 | DEBUG_LOG(LL_ERR, "InternetOpenA fail! Error code: %u", g_winapiApiTable->GetLastError()); |
| 224 | return false; |
| 225 | } |
| 226 | |
| 227 | auto hConnect = g_winapiApiTable->InternetConnectA(hInternet, szHost.c_str(), INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); |
| 228 | if (hConnect == NULL) { |
| 229 | DEBUG_LOG(LL_ERR, "InternetConnectA fail! Error code: %u", g_winapiApiTable->GetLastError()); |
| 230 | |
| 231 | g_winapiApiTable->InternetCloseHandle(hInternet); |
| 232 | return false; |
| 233 | } |
| 234 | |
| 235 | auto hRequest = g_winapiApiTable->HttpOpenRequestA(hConnect, __POST, szUrl.c_str(), __HTTPtype, NULL, NULL, |
| 236 | INTERNET_FLAG_HYPERLINK | INTERNET_FLAG_IGNORE_CERT_CN_INVALID | |
| 237 | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | |
| 238 | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | |
| 239 | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | |
| 240 | INTERNET_FLAG_NO_AUTH | |
| 241 | INTERNET_FLAG_NO_CACHE_WRITE | |
| 242 | INTERNET_FLAG_NO_UI | |
| 243 | INTERNET_FLAG_PRAGMA_NOCACHE | |
| 244 | INTERNET_FLAG_RELOAD, NULL); |
| 245 | |
| 246 | if (hRequest == NULL) { |
| 247 | DEBUG_LOG(LL_ERR, "HttpOpenRequestA fail! Error code: %u", g_winapiApiTable->GetLastError()); |
| 248 | |
| 249 | g_winapiApiTable->InternetCloseHandle(hConnect); |
| 250 | g_winapiApiTable->InternetCloseHandle(hInternet); |
| 251 | return false; |
| 252 | } |
| 253 | |
| 254 | auto addReqHeaders = g_winapiApiTable->HttpAddRequestHeadersA(hRequest, hdrs.c_str(), -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD); |
| 255 | if (addReqHeaders == FALSE) { |
| 256 | DEBUG_LOG(LL_ERR, "HttpAddRequestHeadersA fail! Error code: %u", g_winapiApiTable->GetLastError()); |