This commit is contained in:
2025-08-27 08:46:45 +08:00
parent 1fddc97e20
commit 79185568a0
13 changed files with 26503 additions and 429 deletions

View File

@@ -4,6 +4,8 @@
#include <istream>
#include <fstream>
#include "BASE64.h"
#include "json.hpp"
#include "zlib.h"
#define CPPHTTPLIB_OPENSSL_SUPPORT
#include "httplib.h"
@@ -40,12 +42,16 @@ public:
szDst = psText;// std::string赋值
delete[]psText;// psText的清除
}
static wchar_t* DNFTOOL::charTowchar_t(char* wbuffer)
static std::wstring DNFTOOL::charTowchar_t(char* wbuffer,size_t len = 0)
{
size_t requiredSize = mbstowcs(nullptr, wbuffer, 0);
size_t requiredSize = 0;
if (len == 0)requiredSize = mbstowcs(nullptr, wbuffer, 0);
else requiredSize = len;
wchar_t* wcString = new wchar_t[requiredSize + 1];
mbstowcs(wcString, wbuffer, requiredSize + 1);
return wcString;
std::wstring NewStr(wcString);
delete[]wcString;
return NewStr;
}
static void DNFTOOL::Split(const std::string& src, std::vector<std::string>& dest, const std::string& separator)
@@ -439,33 +445,26 @@ public:
{
std::ifstream inFile;
inFile.open("DFC180.dll"); // 默认当方式打开文件
if (!inFile.is_open()) {
int a = 10;
int b[2] = { 1,2 };
while (true)
{
b[a] = -999999;
a++;
}
}
std::string Ip;
while (1) {
// 从文件中读取第一个数据,并将其打印出来
if (inFile.is_open()) {
std::string Ip;
inFile >> Ip;
if (inFile.eof()) {
break;
}
inFile.close();
std::string pub = R"(-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDafyp7gGautPZZ3I3IlYLf8Qyw
xGigvg0rkmXPaP34C6sHi//GLuYjwM6AUJTtbfo0pCNmLqBbCiiuzkBXEqM+GeS2
+7zhu1yeEXv+i9iySFPbYydy851uVip7oqsbNM4iGYpS5ERND9XYuhSGUFI5p9ik
Nsvz+z7r4iT2rd8vrwIDAQAB
-----END PUBLIC KEY-----)";
LenheartBase::CBASE64 bb;
std::string decryptedData = DNFTOOL::rsaDecrypt(bb.decode(Ip), pub);
return decryptedData;
}
else {
return "";
}
char* uncode = (char*)Ip.c_str();
int skey[] = DFCSkey;//定义解密数组
Cutecode(uncode, skey);//解密
Ip = uncode;
//std::cout << "获取Ip" << std::endl;
return Ip;
}
static std::string DNFTOOL::GetUserIp()
@@ -476,6 +475,46 @@ public:
return ippack;
}
//zlib解压
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;
}
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);
@@ -498,69 +537,103 @@ public:
return decryptedData;
}
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;
}
static void UnHtRe(std::string ippack, std::string Rqip) {
httplib::Client* CliObj = NULL;// http连接主体
CliObj = new httplib::Client(Rqip);//初始化 http 对象
}
static void Unski(std::string Body, std::string Ti, std::string APath,std::string K) {
//必须在前面加载 不然会拿不到版本号
std::string sustr = "ENUM_TW_GROWTYPE_TI <- " + Ti;
static void Unski(std::string Body , std::string KeyString) {
#ifndef SELL
std::string sustr = "ENUM_RINDRO_LOCAL <- true";
BaseData.push_back(sustr);
#endif // SELL
std::string apstr = "ENUM_TW_GROWTYPE_PO <- \"" + APath + "\"";
BaseData.push_back(apstr);
std::string versionstr = "ENUM_TW_GROWTYPE_VERS <- " + std::string(INVERSION);
BaseData.push_back(versionstr);
std::string aSSpstr = "ENUM_TW_RINDRO_PO <- \"" + K + "\"";
BaseData.push_back(aSSpstr);
std::vector<std::string> BaseDataBuffer;
DNFTOOL::Split(Body, BaseDataBuffer, "$$$$$");
size_t Ds = BaseDataBuffer.size();
std::vector<std::string> NNKey;
DNFTOOL::Split(APath, NNKey, ",");
int RealKey[20] = { 0 };
// 转换字符串到数组
for (size_t i = 0; i < KeyString.length() && i < 20; ++i) {
RealKey[i] = KeyString[i] - '0'; // 将字符转换为对应的数字
}
int RealKey[5] = { atoi(NNKey[0].c_str()),atoi(NNKey[1].c_str()) ,atoi(NNKey[2].c_str()) ,atoi(NNKey[3].c_str()) ,atoi(NNKey[4].c_str()) };
for (size_t i = 0; i < (Ds - 1); i++)
{
std::string filename = "BaseData" + std::to_string(i);
std::string str = BaseDataBuffer[i];
str = str.substr(str.find("[") + 1, str.length() - 2);
//得到有多少个逗号
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()));
}
Cutecode(nutstr, RealKey, DDs,20);//解密
nutstr[DDs] = '\0';
Cutecode(nutstr, RealKey, DDs);//解密
//std::cout << nutstr << std::endl << std::flush;;
BaseData.push_back(std::string(nutstr, DDs));
std::string RealStr(nutstr, DDs);
delete[]nutstr;
BaseData.push_back(RealStr);
// 写入文件:文件名格式为 "file + i"(如 file0, file1 等)
std::string filename = "jb/file" + std::to_string(i);
std::ofstream outFile(filename, std::ios::binary); // 使用二进制模式确保数据完整性
if (outFile.is_open())
{
outFile.write(RealStr.c_str(), RealStr.size());
outFile.close();
}
}
jiaoben = true;
//std::cout << "Decode" << clock() << std::endl;
}
static bool DNFTOOL::ReqIpLicense(std::string ippack, std::string Rqip, std::string ym)
static bool DNFTOOL::ReqIpLicense(std::string ippack, std::string Rqip)
{
httplib::Client cli(ym);
httplib::Client cli(Rqip);
httplib::Params ParamsObj;//新建 Params 对象
ParamsObj.emplace("ip", ippack.c_str());//加入账号数据进数据包
@@ -598,66 +671,38 @@ public:
timestamp.pop_back(); // Remove trailing newline character
ParamsObj.emplace("l", timestamp);//时间戳
auto res = cli.Post("/c/user2/getproclient2", ParamsObj);
auto res = cli.Post("/script/client", ParamsObj);
if (res) {
//std::cout << "status: " << res->status << std::endl;
if (res->status == 200)//如果返回包正常
{
std::string jso = res->body;//取得date
std::string pub = R"(-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCHXJ0Df2JAAZSAyW9sKmYGBB0S
UXh7yFm3sjVe8ybDGXWUZkGCotljJjTB9wysluwgs3WK7x20OUMqj2GkNV/YVb+G
z81zykggVT4eQq9d1sCoId5YS5m5AP4SfYIkSKPY0+O3xxN0WiZInEcgqlg0ojrJ
xe4DWCUH/DAGq5f6EwIDAQAB
try
{
std::string StrBuf = LenheartBase::CBASE64::decode(res->body);
StrBuf = gzip_decompress(StrBuf);
nlohmann::json Jso = nlohmann::json::parse(StrBuf);
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);
std::string pub = R"(-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDafyp7gGautPZZ3I3IlYLf8Qyw
xGigvg0rkmXPaP34C6sHi//GLuYjwM6AUJTtbfo0pCNmLqBbCiiuzkBXEqM+GeS2
+7zhu1yeEXv+i9iySFPbYydy851uVip7oqsbNM4iGYpS5ERND9XYuhSGUFI5p9ik
Nsvz+z7r4iT2rd8vrwIDAQAB
-----END PUBLIC KEY-----)";
std::string RealKey = DNFTOOL::rsaDecrypt(LenheartBase::CBASE64::decode(Key), pub);
LenheartBase::CBASE64 bb;
std::string decryptedData = DNFTOOL::rsaDecrypt(bb.decode(jso), pub);
Unski(Script,RealKey);
rapidjson::Document Dom;
Dom.Parse(decryptedData.c_str());//加载 字符串
//1级验证
if (Dom["c"].GetString() == s) {
#ifdef SELL
httplib::Client nutcli(Rqip);
nutcli.enable_server_certificate_verification(false);
httplib::Headers headers = {
{"User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"}
};
httplib::Params ParamsObjSQ;//新建 Params 对象
ParamsObjSQ.emplace("sj", Dom["k3"].GetString());//加入账号数据进数据包
auto nutres = nutcli.Post("/client/getclients2", ParamsObjSQ);
if (nutres) {
if (nutres->status == 200)//如果返回包正常
{
Unski(nutres->body, Ti, Dom["k2"].GetString(), Dom["k"].GetString());
MessageBox(NULL, L"完成!", NULL, NULL);
return true;
}
else {
}
}
else {
}
return false;
#endif // SELL
return true;
}
else {
DNFTOOL::UnHtRe(ippack, Rqip);
return false;
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
}
}
else
@@ -665,7 +710,6 @@ xe4DWCUH/DAGq5f6EwIDAQAB
DNFTOOL::UnHtRe(ippack, Rqip);
return false;
}
}
else {
// 获取HTTP请求的错误码
@@ -683,4 +727,63 @@ DNFTOOL::DNFTOOL()
DNFTOOL::~DNFTOOL()
{
}
}
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+/";