121212
This commit is contained in:
191
test/DNFTOOL.cpp
191
test/DNFTOOL.cpp
@@ -12,8 +12,8 @@ std::string DNFTOOL::GetUserIp()
|
||||
//获取ExeIP
|
||||
int gameip = *(int*)0x1AE9CEC;
|
||||
|
||||
|
||||
/*
|
||||
std::cout << gameip << std::endl;
|
||||
//单独定制的脱机IP
|
||||
if (gameip == 3735605)
|
||||
{
|
||||
@@ -68,10 +68,12 @@ std::string DNFTOOL::GetUserIp()
|
||||
else
|
||||
{
|
||||
wchar_t* wgameip = (wchar_t*)0x1AE9CEC;
|
||||
//wprintf(wgameip);
|
||||
//wchar_t* wgameip = (wchar_t*)0x15A73A4;
|
||||
DNFTOOL::Wchar_tToString(ippack, wgameip);
|
||||
}
|
||||
|
||||
|
||||
return ippack;
|
||||
}
|
||||
|
||||
@@ -144,12 +146,62 @@ void UnHtRe(std::string ippack, std::string Rqip) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
std::string 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;
|
||||
}
|
||||
|
||||
std::string base64_decode(const std::string& encoded_data) {
|
||||
BIO* bio, * b64;
|
||||
BUF_MEM* bufferPtr;
|
||||
|
||||
bio = BIO_new_mem_buf(encoded_data.c_str(), -1);
|
||||
b64 = BIO_new(BIO_f_base64());
|
||||
bio = BIO_push(b64, bio);
|
||||
|
||||
BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
|
||||
BIO_get_mem_ptr(bio, &bufferPtr);
|
||||
|
||||
std::string decoded_data(bufferPtr->data, bufferPtr->length);
|
||||
|
||||
BIO_free_all(bio);
|
||||
|
||||
return decoded_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DNFTOOL::ReqIpLicense(std::string ippack,std::string Rqip)
|
||||
{
|
||||
LenheartBase::CBASE64 bb;
|
||||
std::string New = "";
|
||||
bb.encryptByPublicPEMString(ippack, New, Pub_key);
|
||||
std::string enstring = bb.encode(New);
|
||||
|
||||
|
||||
//LenheartBase::CBASE64 bb;
|
||||
//std::string New = "";
|
||||
//bb.encryptByPublicPEMString(ippack, New, Pub_key);
|
||||
//std::string enstring = bb.encode(New);
|
||||
|
||||
|
||||
//httplib::SSLClient* CliObj = NULL;// http连接主体
|
||||
@@ -157,13 +209,20 @@ bool DNFTOOL::ReqIpLicense(std::string ippack,std::string Rqip)
|
||||
|
||||
httplib::Client cli("https://www.rindro.cn");
|
||||
|
||||
//cli.set_ca_cert_path("./ca-bundle.crt");
|
||||
|
||||
// Disable cert verification
|
||||
cli.enable_server_certificate_verification(false);
|
||||
//cli.set_read_timeout(30); // 读取超时30秒
|
||||
//cli.set_connection_timeout(30);
|
||||
//cli.set_write_timeout(30);
|
||||
|
||||
|
||||
httplib::Params ParamsObj;//新建 Params 对象
|
||||
ParamsObj.emplace("ip", enstring.c_str());//加入账号数据进数据包
|
||||
std::string Ti = std::to_string(clock());
|
||||
std::string NewTi = "";
|
||||
bb.encryptByPublicPEMString(Ti, NewTi, Pub_key);
|
||||
ParamsObj.emplace("ip", ippack.c_str());//加入账号数据进数据包
|
||||
|
||||
//程序运行时间
|
||||
std::string Ti = std::to_string(clock());
|
||||
|
||||
FILE* file2 = fopen("Script.pvf", "rb");
|
||||
fseek(file2, 60, SEEK_SET);
|
||||
@@ -179,96 +238,92 @@ bool DNFTOOL::ReqIpLicense(std::string ippack,std::string Rqip)
|
||||
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);
|
||||
std::string NewApath = "";
|
||||
bb.encryptByPublicPEMString(Apath, NewApath, Pub_key);
|
||||
|
||||
ParamsObj.emplace("su", bb.encode(NewTi).c_str());//程序运行到现在的时间
|
||||
ParamsObj.emplace("P", bb.encode(NewApath).c_str());//Apath
|
||||
//随机值
|
||||
std::string s = Ti + Apath;
|
||||
|
||||
|
||||
ParamsObj.emplace("s", s.c_str());//随机值
|
||||
ParamsObj.emplace("su", Ti.c_str());//程序运行的时间
|
||||
|
||||
|
||||
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);//时间戳
|
||||
|
||||
//CliObj->set_connection_timeout(0, 1000000); // 300 milliseconds
|
||||
//CliObj->set_read_timeout(5, 0); // 5 seconds
|
||||
//CliObj->set_write_timeout(5, 0); // 5 seconds
|
||||
|
||||
//auto res = CliObj->Post("/user/de", ParamsObj);
|
||||
auto res = cli.Get("/c/user/ds");
|
||||
if (!res) {
|
||||
// 获取HTTP请求的错误码
|
||||
std::cerr << "Request failed, error code: " << res.error() << std::endl;
|
||||
}
|
||||
auto res = cli.Post("/c/user/getproclient", ParamsObj);
|
||||
//auto res = cli.Get("/c/user/getproclient");
|
||||
if (res) {
|
||||
|
||||
if (res->status == 200)//如果返回包正常
|
||||
{
|
||||
std::string date = res->body;//取得date
|
||||
std::string jso = res->body;//取得date
|
||||
std::string pub = R"(-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCHXJ0Df2JAAZSAyW9sKmYGBB0S
|
||||
UXh7yFm3sjVe8ybDGXWUZkGCotljJjTB9wysluwgs3WK7x20OUMqj2GkNV/YVb+G
|
||||
z81zykggVT4eQq9d1sCoId5YS5m5AP4SfYIkSKPY0+O3xxN0WiZInEcgqlg0ojrJ
|
||||
xe4DWCUH/DAGq5f6EwIDAQAB
|
||||
-----END PUBLIC KEY-----)";
|
||||
|
||||
|
||||
LenheartBase::CBASE64 bb;
|
||||
std::string decryptedData = rsaDecrypt(bb.decode(jso), pub);
|
||||
|
||||
|
||||
|
||||
rapidjson::Document Dom;
|
||||
Dom.Parse(date.c_str());//加载 字符串
|
||||
Dom.Parse(decryptedData.c_str());//加载 字符串
|
||||
|
||||
std::string base64code = bb.decode(Dom["verify"].GetString());
|
||||
std::string verify = "";
|
||||
bb.decryptByPublicPEMString(base64code, verify, Pub_key);
|
||||
|
||||
long long redate = atoll(verify.c_str()) / 1000;
|
||||
time_t myt = time(0);
|
||||
long long nowdate = (long long)myt;
|
||||
__int64 absnum = abs(nowdate - redate);
|
||||
|
||||
base64code = bb.decode(Dom["su"].GetString());
|
||||
std::string gsu = "";
|
||||
bb.decryptByPublicPEMString(base64code, gsu, Pub_key);
|
||||
|
||||
base64code = bb.decode(Dom["P"].GetString());
|
||||
std::string gP = "";
|
||||
bb.decryptByPublicPEMString(base64code, gP, Pub_key);
|
||||
//1级验证
|
||||
if (Dom["ce"].GetString() == s) {
|
||||
|
||||
|
||||
|
||||
if (absnum < 18000 )
|
||||
{
|
||||
if (gsu != Ti)return false;
|
||||
#ifdef SELL
|
||||
if (Apath == gP) {
|
||||
httplib::Params nParamsObj;//新建 Params 对象
|
||||
nParamsObj.emplace("ip", enstring.c_str());//加入账号数据进数据包
|
||||
nParamsObj.emplace("su", bb.encode(NewTi).c_str());//加入账号数据进数据包
|
||||
nParamsObj.emplace("P", bb.encode(NewApath).c_str());//加入账号数据进数据包
|
||||
auto nres = CliObj->Post("/user/dr2", nParamsObj);
|
||||
|
||||
if (nres->status == 200)//如果返回包正常
|
||||
{
|
||||
Unski(nres->body, Ti, Apath);
|
||||
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"}
|
||||
};
|
||||
|
||||
auto nutres = nutcli.Get("/client/getclients", headers);
|
||||
|
||||
if (nutres) {
|
||||
if (nutres->status == 200)//如果返回包正常
|
||||
{
|
||||
Unski(nutres->body, Ti, Dom["key2"].GetString());
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
#endif // SELL
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//int a = 10;
|
||||
//int b[2] = { 1,2 };
|
||||
//while (true)
|
||||
//{
|
||||
// b[a] = -999999;
|
||||
// a++;
|
||||
//}
|
||||
else {
|
||||
UnHtRe(ippack, Rqip);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//int a = 10;
|
||||
//int b[2] = { 1,2 };
|
||||
//while (true)
|
||||
//{
|
||||
// b[a] = -999999;
|
||||
// a++;
|
||||
//}
|
||||
UnHtRe(ippack, Rqip);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
// 获取HTTP请求的错误码
|
||||
UnHtRe(ippack, Rqip);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user