Rindro-Plugins/Include/DNFTOOL.hpp

789 lines
23 KiB
C++
Raw Normal View History

2024-09-16 17:08:48 +08:00
#pragma once
#include <Windows.h>
#include <string>
#include <istream>
#include <fstream>
#include "BASE64.h"
2025-08-27 08:46:45 +08:00
#include "json.hpp"
#include "zlib.h"
2024-09-16 17:08:48 +08:00
#define CPPHTTPLIB_OPENSSL_SUPPORT
#include "httplib.h"
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/filereadstream.h"
#include "rapidjson/filewritestream.h"
#include "rapidjson/istreamwrapper.h"
bool jiaoben = false;
std::vector<std::string> BaseData;
class DNFTOOL
{
public:
DNFTOOL();
~DNFTOOL();
private:
public:
static void DNFTOOL::Wchar_tToString(std::string& szDst, wchar_t* wchar)
{
wchar_t* wText = wchar;
DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, NULL, 0, NULL, FALSE);// WideCharToMultiByte<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
char* psText; // psTextΪchar*<2A><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><E9A3AC>Ϊ<EFBFBD><CEAA>ֵ<EFBFBD><D6B5>std::string<6E><67><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD>
psText = new char[dwNum];
WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, psText, dwNum, NULL, FALSE);// WideCharToMultiByte<74><65><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>
szDst = psText;// std::string<6E><67>ֵ
delete[]psText;// psText<78><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
2025-08-27 08:46:45 +08:00
static std::wstring DNFTOOL::charTowchar_t(char* wbuffer,size_t len = 0)
2024-09-16 17:08:48 +08:00
{
2025-08-27 08:46:45 +08:00
size_t requiredSize = 0;
if (len == 0)requiredSize = mbstowcs(nullptr, wbuffer, 0);
else requiredSize = len;
2024-09-16 17:08:48 +08:00
wchar_t* wcString = new wchar_t[requiredSize + 1];
mbstowcs(wcString, wbuffer, requiredSize + 1);
2025-08-27 08:46:45 +08:00
std::wstring NewStr(wcString);
delete[]wcString;
return NewStr;
2024-09-16 17:08:48 +08:00
}
static void DNFTOOL::Split(const std::string& src, std::vector<std::string>& dest, const std::string& separator)
{
std::string str = src;
std::string substring;
std::string::size_type start = 0, index;
dest.clear();
index = str.find_first_of(separator, start);
do
{
if (index != std::string::npos)
{
substring = str.substr(start, index - start);
dest.push_back(substring);
start = index + separator.size();
index = str.find(separator, start);
if (start == std::string::npos) break;
}
} while (index != std::string::npos);
//the last part
substring = str.substr(start);
dest.push_back(substring);
}
static char* DNFTOOL::U8ToUnicode(const char* szU8)
{
//UTF8 to Unicode
//Ԥת<D4A4><D7AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC>Ĵ<EFBFBD>С
int wcsLen = ::MultiByteToWideChar(CP_UTF8, NULL, szU8, strlen(szU8), NULL, 0);
//<2F><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>Ҫ<EFBFBD><D2AA>'\0'<27><><EFBFBD><EFBFBD><EFBFBD>ռ䣬MultiByteToWideChar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'\0'<27>ռ<EFBFBD>
wchar_t* wszString = new wchar_t[wcsLen + 1];
//ת<><D7AA>
::MultiByteToWideChar(CP_UTF8, NULL, szU8, strlen(szU8), wszString, wcsLen);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'\0'
wszString[wcsLen] = '\0';
char* m_char;
int len = WideCharToMultiByte(CP_ACP, 0, wszString, wcslen(wszString), NULL, 0, NULL, NULL);
m_char = new char[len + 1];
WideCharToMultiByte(CP_ACP, 0, wszString, wcslen(wszString), m_char, len, NULL, NULL);
delete[]wszString;
m_char[len] = '\0';
return m_char;
}
2024-11-08 11:30:08 +08:00
static char* DNFTOOL::SquirrelU2WOut(const wchar_t* Str)
{
size_t len = 0;
char* wbuffer = (char*)(Str);
while (true)
{
if (wbuffer[len] == 0 && wbuffer[len - 1] == 0)break;
++len;
}
char* cbuffer = new char[len / 2 + 1];
int k = 0;
for (size_t i = 0; i < len; i++)
{
if (i % 2 == 0)
{
cbuffer[k] = wbuffer[i];
++k;
}
}
cbuffer[len / 2] = '\0';
return cbuffer;
}
2024-09-16 17:08:48 +08:00
static char* DNFTOOL::SquirrelU2W(const wchar_t* Str)
{
size_t len = 0;
char* wbuffer = (char*)(Str);
while (true)
{
if (wbuffer[len] == 0 && wbuffer[len - 1] == 0)break;
++len;
}
char* cbuffer = new char[len / 2 + 1];
int k = 0;
for (size_t i = 0; i < len; i++)
{
if (i % 2 == 0)
{
cbuffer[k] = wbuffer[i];
++k;
}
}
cbuffer[len / 2] = '\0';
char* Text = U8ToUnicode(cbuffer);
delete[]cbuffer;
return Text;
}
static char* DNFTOOL::GBKTOUTF8(std::string& strGBK)//ת<><D7AA> GBK<42><4B><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>UTF8<46><38><EFBFBD><EFBFBD>
{
int len = MultiByteToWideChar(CP_ACP, 0, strGBK.c_str(), -1, NULL, 0);
wchar_t* wszUtf8 = new wchar_t[len];
memset(wszUtf8, 0, len);
MultiByteToWideChar(CP_ACP, 0, strGBK.c_str(), -1, wszUtf8, len);
len = WideCharToMultiByte(CP_UTF8, 0, wszUtf8, -1, NULL, 0, NULL, NULL);
char* szUtf8 = new char[len + 1];
memset(szUtf8, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wszUtf8, -1, szUtf8, len, NULL, NULL);
strGBK = szUtf8;
delete[] szUtf8;
delete[] wszUtf8;
return (char*)strGBK.c_str();
}
static char* DNFTOOL::wchar_tTochar(wchar_t* wbuffer)
{
size_t requiredSize = wcstombs(nullptr, wbuffer, 0);
char* key = new char[requiredSize + 1];
wcstombs(key, wbuffer, requiredSize + 1);
return key;
}
static std::string& ReplaceAll(std::string& str, const std::string& src, const std::string& dst) {
std::string::size_type pos(0);
while (true) {
if ((pos = str.find(src)) != std::string::npos) {
str.replace(pos, src.length(), dst);
}
else {
break;
}
}
return str;
}
2024-11-08 11:30:08 +08:00
static char* DNFTOOL::UnicodeToUtf8(const wchar_t* unicode, int len = -1)
2024-09-16 17:08:48 +08:00
{
2024-11-08 11:30:08 +08:00
if (len == -1)
2024-09-16 17:08:48 +08:00
len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL);
char* szUtf8 = (char*)malloc(len + 1);
memset(szUtf8, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, unicode, -1, szUtf8, len, NULL, NULL);
return szUtf8;
}
2024-11-08 11:30:08 +08:00
static wchar_t* BIG5ToUnicode(const char* szBIG5String)
{
UINT nCodePage = 950; //BIG5
int nLength = MultiByteToWideChar(nCodePage, 0, szBIG5String, -1, NULL, 0);
wchar_t* pBuffer = new wchar_t[nLength + 1];
MultiByteToWideChar(nCodePage, 0, szBIG5String, -1, pBuffer, nLength);
pBuffer[nLength] = 0;
return pBuffer;
}
static char* Big5ToUtf8(const wchar_t* big5WideChar , int len = -1) {
if(len == -1)
len = WideCharToMultiByte(CP_UTF8, 0, big5WideChar, -1, NULL, 0, NULL, NULL);
char* szUtf8 = (char*)malloc(len + 1);
memset(szUtf8, 0, len + 1);
// <20><><EFBFBD>ô<EFBFBD> Big5 <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ UTF-8
SetThreadLocale(MAKELCID(0x0404, SORT_DEFAULT));
WideCharToMultiByte(CP_UTF8, 0, big5WideChar, -1, szUtf8, len, NULL, NULL);
return szUtf8;
}
2024-09-16 17:08:48 +08:00
static int DNFTOOL::DNFDeCode(int Address)
{
DWORD nEax, nEcx8, nEsi, nEdx, nTmp;
nEax = *(int*)(Address);
if (nEax == -1)
return nEax;
nEcx8 = *(int*)(Address + 8);
if (nEcx8 == -1)
return nEcx8;
nEsi = *(int*)(0x1AF8D78);
nEdx = nEax >> 16;
nTmp = (nEdx << 2) + nEsi + 36;
nEdx = *(int*)(nTmp);
if (nEdx == -1)
return nEdx;
nEax = nEax & 65535;
nTmp = (nEax << 2) + nEdx + 8468;
nEax = *(int*)(nTmp);
if (nEax == -1)
return nEax;
_asm
{
mov eax, nEax
movzx edx, ax
mov nEdx, edx
}
nEsi = nEdx << 16;
nEsi = nEsi | nEdx;
nEax = nEsi ^ nEcx8;
return nEax;
}
static void DNFTOOL::DNFEnCode(int AddreSs, int Data)
{
long JEdi, JEcx, JEax, JEsi, JEdx, JSs;
JEcx = AddreSs;
JEax = *(int*)(0x1AF8DB8);
JEax = JEax + 1;
*(int*)(0x1AF8DB8) = JEax;
JEdx = JEax;
JEdx = JEdx >> 8;
JEdx = JEdx << 24;
JEdx = JEdx >> 24;
JEdx = *(int*)(JEdx * 2 + 0x1843F58);
JEdx = JEdx & 0xFFFF;
JEax = JEax << 24;
JEax = JEax >> 24;
JSs = *(int*)(JEax * 2 + 0x1844158);
JSs = JSs & 0xFFFF;
JEdx = JEdx ^ JSs;
JEax = JEdx;
JEax = JEax & 0xFFFF;
JEsi = Data;
JEdx = JEsi >> 16;
Sleep(10);
JSs = JEsi & 0xFFFF;
JEdx = JEdx + JSs;
JEdx = JEdx ^ JEax;
JEdi = JEdx;
JEdx = JEax;
JEax = JEax << 16;
JEax = JEax + JEdx;
JEsi = Data;
JEax = JEax ^ JEsi;
JEsi = AddreSs + 8;
*(int*)(JEsi) = JEax;
JEax = *(int*)(AddreSs);
JEsi = *(int*)(0x1AF8D78);
JEcx = JEdi;
JEcx = JEcx << 16;
JEcx = JEcx + JEdx;
JEdx = JEax;
JEdx = JEdx >> 16;
JEdx = *(int*)(JEsi + JEdx * 4 + 36);
JEax = JEax & 0xFFFF;
*(int*)(JEdx + JEax * 4 + 8468) = JEcx;
}
static int DNFTOOL::GetEquAddr(int addr)
{
switch (addr)
{
case 1:
return 0x3038;
break;
case 2:
return 0x304C;
break;
case 3:
return 0x3048;
break;
case 4:
return 0x3050;
break;
case 5:
return 0x3044;
break;
case 6:
return 0x3040;
break;
case 7:
return 0x3058;
break;
case 8:
return 0x305C;
break;
case 9:
return 0x3054;
break;
case 10:
return 0x3060;
break;
case 11:
return 0x3064;
break;
case 12:
return 0x303c;
break;
case 13://ñ<><C3B1>
return 0x3010;
break;
case 14://ͷ<><CDB7>
return 0x3014;
break;
case 15://<2F><>
return 0x3018;
break;
case 16:
return 0x301c;
break;
case 17:
return 0x3020;
break;
case 18:
return 0x3024;
break;
case 19:
return 0x3028;
break;
case 20:
return 0x302c;
break;
case 21:
return 0x3030;
break;
case 22:
return 0x3034;
break;
case 23:
return 0x3030;
break;
case 24:
return 0x3068;
break;
case 25:
return 0x306C;
break;
case 26:
return 0x3070;
break;
case 27:
return 0x3074;
break;
}
return -1;
}
static wchar_t* DNFTOOL::char2wchar(const char* cchar)
{
wchar_t* m_wchar;
int len = MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), NULL, 0);
m_wchar = new wchar_t[len + 1];
MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), m_wchar, len);
m_wchar[len] = '\0';
return m_wchar;
}
public:
static void DNFTOOL::WriteInt(int addr, int buf)
{
*(int*)addr = buf;
}
static void DNFTOOL::WriteByteArr(int addr, BYTE buf[], int len)
{
for (size_t i = 0; i < len; i++)
{
*(BYTE*)(addr + i) = (int)buf[i];
}
}
static int DNFTOOL::GetHook(int Addr, std::string <EFBFBD><EFBFBD>ַ, int Type)
{
size_t pos = <EFBFBD><EFBFBD>ַ.find("+");
size_t size = <EFBFBD><EFBFBD>ַ.size();
int GetHookArr[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
int i = 0;
while (pos != std::string::npos)
{
std::string x = <EFBFBD><EFBFBD>ַ.substr(0, pos);
GetHookArr[i] = stoi(x, 0, 16);
i++;
<EFBFBD><EFBFBD>ַ = <EFBFBD><EFBFBD>ַ.substr(pos + 1, size);
pos = <EFBFBD><EFBFBD>ַ.find("+");
}
int num;
num = *(int*)(Addr);
if (num != 0)
{
for (int z = 0; z < i; z++)
{
if (num <= 0 && z != i - 1)//<2F><><EFBFBD>ܶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD>
{
num = 0;
return num;
}
if (z == i - 1)
{
if (Type == 0)return *(int*)(num + GetHookArr[z]);
else return (num + GetHookArr[z]);
}
else
{
num = *(int*)(num + GetHookArr[z]);
}
}
}
return num;
}
static std::string DNFTOOL::GetIP()
{
std::ifstream inFile;
inFile.open("DFC180.dll"); // Ĭ<>ϵ<EFBFBD><CFB5><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
2025-08-27 08:46:45 +08:00
if (inFile.is_open()) {
std::string Ip;
2024-09-16 17:08:48 +08:00
inFile >> Ip;
2025-08-27 08:46:45 +08:00
inFile.close();
2024-09-16 17:08:48 +08:00
2025-08-27 08:46:45 +08:00
std::string pub = R"(-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDafyp7gGautPZZ3I3IlYLf8Qyw
xGigvg0rkmXPaP34C6sHi//GLuYjwM6AUJTtbfo0pCNmLqBbCiiuzkBXEqM+GeS2
+7zhu1yeEXv+i9iySFPbYydy851uVip7oqsbNM4iGYpS5ERND9XYuhSGUFI5p9ik
Nsvz+z7r4iT2rd8vrwIDAQAB
-----END PUBLIC KEY-----)";
2024-09-16 17:08:48 +08:00
2025-08-27 08:46:45 +08:00
LenheartBase::CBASE64 bb;
std::string decryptedData = DNFTOOL::rsaDecrypt(bb.decode(Ip), pub);
return decryptedData;
}
else {
return "";
}
2024-09-16 17:08:48 +08:00
}
static std::string DNFTOOL::GetUserIp()
{
std::string ippack;
wchar_t* wgameip = (wchar_t*)0x1AE9CEC;
DNFTOOL::Wchar_tToString(ippack, wgameip);
return ippack;
}
2025-08-27 08:46:45 +08:00
//zlib<69><62>ѹ
static std::string gzip_decompress(const std::string& compressed) {
z_stream zs;
memset(&zs, 0, sizeof(zs));
if (inflateInit2(&zs, 16 + MAX_WBITS) != Z_OK) {
//throw std::runtime_error("inflateInit failed");
return "null";
}
zs.next_in = (Bytef*)compressed.data();
zs.avail_in = compressed.size();
int ret;
char outbuffer[32768];
std::string outstring;
do {
zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
zs.avail_out = sizeof(outbuffer);
ret = inflate(&zs, 0);
if (outstring.size() < zs.total_out) {
outstring.append(outbuffer, zs.total_out - outstring.size());
}
} while (ret == Z_OK);
inflateEnd(&zs);
if (ret != Z_STREAM_END) {
//throw std::runtime_error("Exception during zlib decompression: (" + std::to_string(ret) + ") " + zs.msg);
return "null";
}
return outstring;
}
2024-09-16 17:08:48 +08:00
static std::string DNFTOOL::rsaDecrypt(const std::string& encryptedData, const std::string& publicKeyStr) {
RSA* rsa = RSA_new();
BIO* bio = BIO_new_mem_buf(const_cast<char*>(publicKeyStr.c_str()), -1);
PEM_read_bio_RSA_PUBKEY(bio, &rsa, NULL, NULL);
int rsaSize = RSA_size(rsa);
std::string decryptedData(rsaSize, 0);
int decryptedSize = RSA_public_decrypt(encryptedData.size(), reinterpret_cast<const unsigned char*>(encryptedData.c_str()), reinterpret_cast<unsigned char*>(&decryptedData[0]), rsa, RSA_PKCS1_PADDING);
if (decryptedSize == -1) {
std::cerr << "Error decrypting data" << std::endl;
return "";
}
RSA_free(rsa);
BIO_free(bio);
decryptedData.resize(decryptedSize);
return decryptedData;
}
2025-08-27 08:46:45 +08:00
static std::string rsaDecrypt8(const std::string& encryptedData, const std::string& publicKeyStr) {
RSA* rsa = nullptr;
BIO* bio = BIO_new_mem_buf(const_cast<char*>(publicKeyStr.c_str()), -1);
if (bio == nullptr) {
std::cerr << "Error creating BIO" << std::endl;
return "";
}
rsa = PEM_read_bio_RSA_PUBKEY(bio, &rsa, nullptr, nullptr);
if (rsa == nullptr) {
std::cerr << "Error reading public key" << std::endl;
BIO_free(bio);
return "";
}
int rsaSize = RSA_size(rsa);
std::string decryptedData(rsaSize, 0);
int decryptedSize = RSA_public_decrypt(encryptedData.size(),
reinterpret_cast<const unsigned char*>(encryptedData.c_str()),
reinterpret_cast<unsigned char*>(&decryptedData[0]),
rsa,
RSA_PKCS1_PADDING);
if (decryptedSize == -1) {
std::cerr << "Error decrypting data" << std::endl;
RSA_free(rsa);
BIO_free(bio);
return "";
}
RSA_free(rsa);
BIO_free(bio);
decryptedData.resize(decryptedSize);
return decryptedData;
}
2024-09-16 17:08:48 +08:00
static void UnHtRe(std::string ippack, std::string Rqip) {
httplib::Client* CliObj = NULL;// http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CliObj = new httplib::Client(Rqip);//<2F><>ʼ<EFBFBD><CABC> http <20><><EFBFBD><EFBFBD>
}
2025-08-27 08:46:45 +08:00
static void Unski(std::string Body , std::string KeyString) {
#ifndef SELL
std::string sustr = "ENUM_RINDRO_LOCAL <- true";
2024-09-16 17:08:48 +08:00
BaseData.push_back(sustr);
2025-08-27 08:46:45 +08:00
#endif // SELL
2024-09-16 17:08:48 +08:00
2024-11-08 11:30:08 +08:00
2024-09-16 17:08:48 +08:00
std::vector<std::string> BaseDataBuffer;
DNFTOOL::Split(Body, BaseDataBuffer, "$$$$$");
size_t Ds = BaseDataBuffer.size();
2025-08-27 08:46:45 +08:00
int RealKey[20] = { 0 };
// ת<><D7AA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (size_t i = 0; i < KeyString.length() && i < 20; ++i) {
RealKey[i] = KeyString[i] - '0'; // <20><><EFBFBD>ַ<EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
2024-09-16 17:08:48 +08:00
for (size_t i = 0; i < (Ds - 1); i++)
{
std::string str = BaseDataBuffer[i];
2025-08-27 08:46:45 +08:00
//<2F>õ<EFBFBD><C3B5>ж<EFBFBD><D0B6>ٸ<EFBFBD><D9B8><EFBFBD><EFBFBD><EFBFBD>
2024-09-16 17:08:48 +08:00
std::vector<std::string> Data;
DNFTOOL::Split(str, Data, ", ");
size_t DDs = Data.size();
char* nutstr = new char[DDs + 1];
for (size_t s = 0; s < DDs; s++)
{
nutstr[s] = char(atoi(Data[s].c_str()));
}
2025-08-27 08:46:45 +08:00
Cutecode(nutstr, RealKey, DDs,20);//<2F><><EFBFBD><EFBFBD>
2024-09-16 17:08:48 +08:00
nutstr[DDs] = '\0';
2025-08-27 08:46:45 +08:00
std::string RealStr(nutstr, DDs);
2024-09-16 17:08:48 +08:00
delete[]nutstr;
2025-08-27 08:46:45 +08:00
BaseData.push_back(RealStr);
2024-09-16 17:08:48 +08:00
2025-08-27 08:46:45 +08:00
// д<><D0B4><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʽΪ "file + i"<22><><EFBFBD><EFBFBD> file0, file1 <20>ȣ<EFBFBD>
std::string filename = "jb/file" + std::to_string(i);
std::ofstream outFile(filename, std::ios::binary); // ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>ģʽȷ<CABD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (outFile.is_open())
{
outFile.write(RealStr.c_str(), RealStr.size());
outFile.close();
}
}
2024-09-16 17:08:48 +08:00
jiaoben = true;
2025-08-27 08:46:45 +08:00
//std::cout << "Decode" << clock() << std::endl;
2024-09-16 17:08:48 +08:00
}
2025-08-27 08:46:45 +08:00
static bool DNFTOOL::ReqIpLicense(std::string ippack, std::string Rqip)
2024-09-16 17:08:48 +08:00
{
2025-08-27 08:46:45 +08:00
httplib::Client cli(Rqip);
2024-09-16 17:08:48 +08:00
httplib::Params ParamsObj;//<2F>½<EFBFBD> Params <20><><EFBFBD><EFBFBD>
ParamsObj.emplace("ip", ippack.c_str());//<2F><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><CBBA><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
std::string Ti = std::to_string(clock());
FILE* file2 = fopen("Script.pvf", "rb");
fseek(file2, 60, SEEK_SET);
int code1 = fgetc(file2);
fseek(file2, 1500, SEEK_SET);
int code2 = fgetc(file2);
fseek(file2, 4000, SEEK_SET);
int code3 = fgetc(file2);
fseek(file2, 16008, SEEK_SET);
int code4 = fgetc(file2);
fseek(file2, 24003, SEEK_SET);
int code5 = fgetc(file2);
fclose(file2);
std::string Apath = std::to_string(code1 % 10) + "," + std::to_string(code2 % 10) + "," + std::to_string(code3 % 10) + "," + std::to_string(code4 % 10) + "," + std::to_string(code5 % 10);
//<2F><><EFBFBD><EFBFBD>ֵ
std::string s = Ti + Apath;
ParamsObj.emplace("s", s.c_str());//<2F><><EFBFBD><EFBFBD>ֵ
ParamsObj.emplace("su", Ti.c_str());//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>
auto now = std::chrono::system_clock::now();
auto now_c = std::chrono::system_clock::to_time_t(now);
std::string timestamp = std::ctime(&now_c);
timestamp.pop_back(); // Remove trailing newline character
ParamsObj.emplace("l", timestamp);//ʱ<><CAB1><EFBFBD><EFBFBD>
2025-08-27 08:46:45 +08:00
auto res = cli.Post("/script/client", ParamsObj);
2024-09-16 17:08:48 +08:00
if (res) {
2025-08-27 08:46:45 +08:00
//std::cout << "status: " << res->status << std::endl;
2024-09-16 17:08:48 +08:00
if (res->status == 200)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ذ<EFBFBD><D8B0><EFBFBD><EFBFBD><EFBFBD>
{
2025-08-27 08:46:45 +08:00
try
{
std::string StrBuf = LenheartBase::CBASE64::decode(res->body);
StrBuf = gzip_decompress(StrBuf);
2024-09-16 17:08:48 +08:00
2025-08-27 08:46:45 +08:00
nlohmann::json Jso = nlohmann::json::parse(StrBuf);
2024-09-16 17:08:48 +08:00
2025-08-27 08:46:45 +08:00
std::string Key = Jso["key"].dump();
Key = Key.substr(1, Key.length() - 2);
std::string Script = Jso["getBaseScriptStr"].dump();
Script = Script.substr(1, Script.length() - 2);
2024-11-08 11:30:08 +08:00
2025-08-27 08:46:45 +08:00
std::string pub = R"(-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDafyp7gGautPZZ3I3IlYLf8Qyw
xGigvg0rkmXPaP34C6sHi//GLuYjwM6AUJTtbfo0pCNmLqBbCiiuzkBXEqM+GeS2
+7zhu1yeEXv+i9iySFPbYydy851uVip7oqsbNM4iGYpS5ERND9XYuhSGUFI5p9ik
Nsvz+z7r4iT2rd8vrwIDAQAB
-----END PUBLIC KEY-----)";
2024-11-08 11:30:08 +08:00
2025-08-27 08:46:45 +08:00
std::string RealKey = DNFTOOL::rsaDecrypt(LenheartBase::CBASE64::decode(Key), pub);
2024-11-08 11:30:08 +08:00
2025-08-27 08:46:45 +08:00
Unski(Script,RealKey);
2024-09-16 17:08:48 +08:00
}
2025-08-27 08:46:45 +08:00
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
2024-09-16 17:08:48 +08:00
}
}
else
{
DNFTOOL::UnHtRe(ippack, Rqip);
return false;
}
}
else {
// <20><>ȡHTTP<54><50><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>
DNFTOOL::UnHtRe(ippack, Rqip);
return false;
}
DNFTOOL::UnHtRe(ippack, Rqip);
return false;
}
};
DNFTOOL::DNFTOOL()
{
}
DNFTOOL::~DNFTOOL()
{
2025-08-27 08:46:45 +08:00
}
class Base64 {
private:
static const std::string base64_chars;
static inline bool is_base64(unsigned char c) {
return (isalnum(c) || (c == '+') || (c == '/'));
}
public:
static std::vector<unsigned char> decode(const std::string& encoded_string) {
int in_len = encoded_string.size();
int i = 0;
int j = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
std::vector<unsigned char> ret;
while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
char_array_4[i++] = encoded_string[in_]; in_++;
if (i == 4) {
for (i = 0; i < 4; i++)
char_array_4[i] = base64_chars.find(char_array_4[i]);
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (i = 0; (i < 3); i++)
ret.push_back(char_array_3[i]);
i = 0;
}
}
if (i) {
for (j = i; j < 4; j++)
char_array_4[j] = 0;
for (j = 0; j < 4; j++)
char_array_4[j] = base64_chars.find(char_array_4[j]);
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]);
}
return ret;
}
};
const std::string Base64::base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";