This commit is contained in:
947330670@qq.com 2023-05-12 16:08:39 +08:00
parent c1943df644
commit 26aea31550
8 changed files with 272 additions and 214 deletions

View File

@ -1,5 +1,175 @@
#include "pch.h" #include "pch.h"
#include "DNFTOOL.h" #include "DNFTOOL.h"
# define Pub_key "-----BEGIN RSA PUBLIC KEY-----\nMIGJAoGBAMiYuNW4K1rST7ZWYpWX6nEziXi5JveLPhDCLj0VZ/5/4dzBWrmoL/Ic\nFZuHOBJtYHm965713kKC9gtw2EyVgkqmXLT3105jEUqzNizfThc6C2ZL6vMmzUZl\nooxNyaOC5mWthPZtwlqQihYWT2nW/wKp8fpTouXihQOCPjqdRoVFAgMBAAE=\n-----END RSA PUBLIC KEY-----"
extern bool Sinw = false;
std::string DNFTOOL::GetUserIp()
{
std::string ippack;
//获取ExeIP
int gameip = *(int*)0x1AE9CEC;
/*
std::cout << gameip << std::endl;
//单独定制的脱机IP
if (gameip == 3735605)
{
Sinw = true;
//int skey[] = Skey;//定义解密数组
//Cutecode(nutstr, skey);//解密
//wchar_t* sfile = DNFTOOL::charTowchar_t((char*)"TTTT");
//wchar_t* ss = DNFTOOL::charTowchar_t((char*)nutstr);
//wprintf(L"Function:%s \n", ss);
//uint32_t v = GetSqVm();
//squirrel::SQdofileBuffer(v, sfile, ss);
return;
}
else {
int a = 10;
int b[2] = { 1,2 };
while (true)
{
b[a] = -999999;
a++;
}
}
*/
//如果ExeIP 等于 192.168.200.131
if (gameip == 3735601)
{
//获取本机IP
std::string MyIp;
httplib::Client* IPCliObj = NULL;// http连接主体
IPCliObj = new httplib::Client("myip.ipip.net");//初始化 http 对象
auto MyIpres = IPCliObj->Get("/");
if (MyIpres->status == 200)//如果返回包正常
{
MyIp = MyIpres->body;//取得date
}
//std::cout << "本机IP:" << MyIp << std::endl;
//已经得到了本机IP
int Pos = MyIp.find("IP", 0) + 5;
MyIp = MyIp.substr(Pos, MyIp.find(" ", Pos) - Pos);
ippack = MyIp;
}
else
{
wchar_t* wgameip = (wchar_t*)0x1AE9CEC;
DNFTOOL::Wchar_tToString(ippack, wgameip);
}
return ippack;
}
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);
httplib::Client* CliObj = NULL;// http连接主体
CliObj = new httplib::Client(Rqip + ":9007");//初始化 http 对象
httplib::Params ParamsObj;//新建 Params 对象
ParamsObj.emplace("ip", enstring.c_str());//加入账号数据进数据包
auto res = CliObj->Post("/user/current", ParamsObj);
if (res->status == 200)//如果返回包正常
{
std::string date = res->body;//取得date
rapidjson::Document Dom;
Dom.Parse(date.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);
//std::cout << absnum << std::endl;
if (absnum < 18000)
{
Sinw = true;
#ifdef SELL
int Size = Dom["size"].GetInt();//判断类型
std::cout << Size << std::endl;
for (int i = 0; i < Size; i++)
{
std::string filename = Dom["list"].GetArray()[i].GetArray()[0].GetString();
std::string str = Dom["list"].GetArray()[i].GetArray()[1].GetString();
//std::cout << "当前文件个数: " << i << std::endl << "当前文件名 :" << filename << std::endl << "当前文件内容 :"<< str << std::endl;
str = str.substr(str.find("[") + 1, str.length() - 2);
std::vector<std::string> Data;
DNFTOOL::Split(str, Data, ", ");
size_t Ds = Data.size();
char* nutstr = new char[Ds + 1];
for (size_t s = 0; s < Ds; s++)
{
nutstr[s] = char(atoi(Data[s].c_str()));
}
nutstr[Ds] = '\0';
int skey[] = Skey;//定义解密数组
Cutecode(nutstr, skey);//解密
wchar_t* sfile = DNFTOOL::charTowchar_t((char*)filename.c_str());
wchar_t* ss = DNFTOOL::charTowchar_t((char*)nutstr);
//wprintf(L"Function:%s \n", ss);
std::cout << i << std::endl;
uint32_t v = GetSqVm();
squirrel::SQdofileBuffer(v, sfile, ss);
}
#endif // SELL
return true;
}
else
{
int a = 10;
int b[2] = { 1,2 };
while (true)
{
b[a] = -999999;
a++;
}
}
}
else
{
int a = 10;
int b[2] = { 1,2 };
while (true)
{
b[a] = -999999;
a++;
}
}
}
int DNFTOOL::GetExeNutWrtNum(int Pos) int DNFTOOL::GetExeNutWrtNum(int Pos)
{ {

View File

@ -65,6 +65,12 @@ private:
public: public:
//获取用户IP
static std::string GetUserIp();
//验证IP是否通过
static bool ReqIpLicense(std::string ippack, std::string Rqip);
//获取EXE使用头 号位数据 //获取EXE使用头 号位数据
static int GetExeNutWrtNum(int Pos); static int GetExeNutWrtNum(int Pos);

View File

@ -4,13 +4,10 @@
#include "pch.h" #include "pch.h"
# define Pub_key "-----BEGIN RSA PUBLIC KEY-----\nMIGJAoGBAMiYuNW4K1rST7ZWYpWX6nEziXi5JveLPhDCLj0VZ/5/4dzBWrmoL/Ic\nFZuHOBJtYHm965713kKC9gtw2EyVgkqmXLT3105jEUqzNizfThc6C2ZL6vMmzUZl\nooxNyaOC5mWthPZtwlqQihYWT2nW/wKp8fpTouXihQOCPjqdRoVFAgMBAAE=\n-----END RSA PUBLIC KEY-----"
int LbState = 0; int LbState = 0;
int RbState = 0; int RbState = 0;
int MbState = 0; int MbState = 0;
extern bool Sinw = false;
void LenheartThread() void LenheartThread()
@ -29,194 +26,17 @@ void LenheartThread()
{ {
//获取验证服务器ip //获取验证服务器ip
std::string Rqip = DNFTOOL::GetIP(); std::string Rqip = DNFTOOL::GetIP();
//std::string Rqip = "192.168.200.13";
//std::cout << "验证服务器IP:" << Rqip << std::endl; //std::cout << "验证服务器IP:" << Rqip << std::endl;
//获取用户IP
std::string ippack = DNFTOOL::GetUserIp();
//获取验证IP
std::string ippack;
//获取ExeIP
int gameip = *(int*)0x1AE9CEC;
/*
std::cout << gameip << std::endl;
//单独定制的脱机IP
if (gameip == 3735605)
{
Sinw = true;
//int skey[] = Skey;//定义解密数组
//Cutecode(nutstr, skey);//解密
//wchar_t* sfile = DNFTOOL::charTowchar_t((char*)"TTTT");
//wchar_t* ss = DNFTOOL::charTowchar_t((char*)nutstr);
//wprintf(L"Function:%s \n", ss);
//uint32_t v = GetSqVm();
//squirrel::SQdofileBuffer(v, sfile, ss);
return;
}
else {
int a = 10;
int b[2] = { 1,2 };
while (true)
{
b[a] = -999999;
a++;
}
}
*/
//如果ExeIP 等于 192.168.200.131
if (gameip == 3735601)
{
//获取本机IP
std::string MyIp;
httplib::Client* IPCliObj = NULL;// http连接主体
IPCliObj = new httplib::Client("myip.ipip.net");//初始化 http 对象
auto MyIpres = IPCliObj->Get("/");
if (MyIpres->status == 200)//如果返回包正常
{
MyIp = MyIpres->body;//取得date
}
//std::cout << "本机IP:" << MyIp << std::endl;
//已经得到了本机IP
int Pos = MyIp.find("IP", 0) + 5;
MyIp = MyIp.substr(Pos, MyIp.find(" ", Pos) - Pos);
ippack = MyIp;
}
else
{
wchar_t* wgameip = (wchar_t*)0x1AE9CEC;
DNFTOOL::Wchar_tToString(ippack, wgameip);
}
//std::cout << "验证IP:" << ippack << std::endl; //std::cout << "验证IP:" << ippack << std::endl;
//已经获取了要发送的验证IP
LenheartBase::CBASE64 bb; //验证并请求加载脚本
ippack += "\nip"; DNFTOOL::ReqIpLicense(ippack, Rqip);
std::string New = ""; return;
bb.encryptByPublicPEMString(ippack, New,Pub_key);
std::string enstring = bb.encode(New);
httplib::Client* CliObj = NULL;// http连接主体
CliObj = new httplib::Client(Rqip + ":9007");//初始化 http 对象
httplib::Params ParamsObj;//新建 Params 对象
ParamsObj.emplace("ys", enstring.c_str());//加入账号数据进数据包
auto res = CliObj->Post("/yosin", ParamsObj);
if (res->status == 200)//如果返回包正常
{
std::string date = res->body;//取得date
std::string base64code = bb.decode(date);
std::string decrypt_text = "";
bb.decryptByPublicPEMString(base64code, decrypt_text,Pub_key);
long long redate = atoll(decrypt_text.c_str()) / 1000;
time_t myt = time(0);
long long nowdate = (long long)myt;
__int64 absnum = abs(nowdate - redate);
//std::cout << absnum << std::endl;
if (absnum < 18000)
{
Sinw = true;
#ifdef SELL
auto res = CliObj->Post("/transfer/getscript2", ParamsObj);
if (res->status == 200)//如果返回包正常
{
std::string date = res->body;//取得date
//std::cout << date << std::endl;
if (!date.empty())
{
rapidjson::Document Dom;
Dom.Parse(date.c_str());//加载 字符串
int Size = Dom["size"].GetInt();//判断类型
for (int i = 0; i < Size; i++)
{
std::string filename = Dom["list"].GetArray()[i].GetArray()[0].GetString();
std::string str = Dom["list"].GetArray()[i].GetArray()[1].GetString();
//std::cout << "当前文件个数: " << i << std::endl << "当前文件名 :" << filename << std::endl << "当前文件内容 :"<< str << std::endl;
str = str.substr(str.find("[") + 1, str.length() - 2);
std::vector<std::string> Data;
DNFTOOL::Split(str, Data, ", ");
size_t Ds = Data.size();
char* nutstr = new char[Ds + 1];
for (size_t s = 0; s < Ds; s++)
{
nutstr[s] = char(atoi(Data[s].c_str()));
}
nutstr[Ds] = '\0';
int skey[] = Skey;//定义解密数组
Cutecode(nutstr, skey);//解密
wchar_t* sfile = DNFTOOL::charTowchar_t((char*)filename.c_str());
wchar_t* ss = DNFTOOL::charTowchar_t((char*)nutstr);
//wprintf(L"Function:%s \n", ss);
uint32_t v = GetSqVm();
squirrel::SQdofileBuffer(v, sfile, ss);
}
}
}
#endif // SELL
return;
}
else
{
int a = 10;
int b[2] = { 1,2 };
while (true)
{
b[a] = -999999;
a++;
}
}
}
else
{
int a = 10;
int b[2] = { 1,2 };
while (true)
{
b[a] = -999999;
a++;
}
}
} }
} }
} }
@ -249,7 +69,6 @@ __declspec(dllexport) void Lenheart()
//修改ui //修改ui
void HookHudUi() void HookHudUi()
{ {

View File

@ -81,6 +81,7 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4,
//Hook文字 //Hook文字
#ifdef CODEDRAW #ifdef CODEDRAW
if (CodeDrawMap.count(GameStr) == 1) if (CodeDrawMap.count(GameStr) == 1)
{ {
@ -159,7 +160,7 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4,
#endif #endif
//buffťť×° //Ç¿»¯ÏµÍ³
#ifdef NEWUPGRADE_SWITCH #ifdef NEWUPGRADE_SWITCH
if (GameStr.find("LenheartUpgrade") != std::string::npos) if (GameStr.find("LenheartUpgrade") != std::string::npos)
{ {
@ -733,6 +734,7 @@ int _fastcall newsub11A8F60(DWORD a1, DWORD Seat, int a2, int a3, int a4)
#endif #endif
#ifdef DRAWITEM #ifdef DRAWITEM
static bool OpenSw = false; static bool OpenSw = false;
if (!OpenSw) if (!OpenSw)
{ {
@ -745,31 +747,32 @@ int _fastcall newsub11A8F60(DWORD a1, DWORD Seat, int a2, int a3, int a4)
} }
else else
{ {
uint32_t v = GetSqVm(); //uint32_t v = GetSqVm();
SQPushRootTable(v); //SQPushRootTable(v);
SQPushString(v, L"Sq_DrawItemBack", -1); //SQPushString(v, L"Sq_DrawItemBack", -1);
SQ_Get(v, -2); //SQ_Get(v, -2);
SQPushRootTable(v); //SQPushRootTable(v);
SQPushInt(v, a2); //SQPushInt(v, a2);
SQPushInt(v, a3); //SQPushInt(v, a3);
SQPushInt(v, a4); //SQPushInt(v, a4);
SQ_Call(v, 4, 0, 1); //SQ_Call(v, 4, 0, 1);
SQPop(v, 2); //SQPop(v, 2);
int ret = sub11A8F60(a1, 0, a2, a3, a4); int ret = sub11A8F60(a1, 0, a2, a3, a4);
SQPushRootTable(v); //SQPushRootTable(v);
SQPushString(v, L"Sq_DrawItemFront", -1); //SQPushString(v, L"Sq_DrawItemFront", -1);
SQ_Get(v, -2); //SQ_Get(v, -2);
SQPushRootTable(v); //SQPushRootTable(v);
SQPushInt(v, a2); //SQPushInt(v, a2);
SQPushInt(v, a3); //SQPushInt(v, a3);
SQPushInt(v, a4); //SQPushInt(v, a4);
SQ_Call(v, 4, 0, 1); //SQ_Call(v, 4, 0, 1);
SQPop(v, 2); //SQPop(v, 2);
return ret; return ret;
} }
#endif #endif
} }
#endif #endif
@ -989,6 +992,7 @@ DWORD** _fastcall NewEvent(DWORD thisc, DWORD Seat, DWORD a2, DWORD** a3, char a
a2 += 167; a2 += 167;
a3 = (DWORD**)527; a3 = (DWORD**)527;
} }
return OldEvent(thisc, Seat, a2, a3, a4); return OldEvent(thisc, Seat, a2, a3, a4);
} }
@ -1064,9 +1068,28 @@ DWORD _fastcall New11A8F60(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2, DWORD a3
} }
#endif #endif
typedef DWORD(_fastcall _11816B0)(DWORD thisc, DWORD Seat, DWORD* a2, int a3);
static _11816B0* Old11816B0;
//»æÍ¼HOOK
DWORD _fastcall New11816B0(DWORD thisc, DWORD Seat, DWORD* a2, int a3)
{
wchar_t* str = (wchar_t*)a3;
char* OutPutText = DNFTOOL::SquirrelU2W(str);
std::string B = OutPutText;
std::cout << B << std::endl;
delete[]OutPutText;
return Old11816B0(thisc, Seat, a2, a3);
}
int hook::RegisterHook() int hook::RegisterHook()
{ {
MH_Initialize(); MH_Initialize();
//MH_CreateHook((void*)0x9D2300, &New_9D2300, reinterpret_cast<void**>(&Old_9D2300)); //MH_CreateHook((void*)0x9D2300, &New_9D2300, reinterpret_cast<void**>(&Old_9D2300));
@ -1094,7 +1117,7 @@ int hook::RegisterHook()
//HookNut函数注册 //HookNut函数注册
MH_CreateHook((void*)INIT_NUT_ADDRESS, &H_Register_Nut, reinterpret_cast<void**>(&MLnewclosure)); MH_CreateHook((void*)INIT_NUT_ADDRESS, &H_Register_Nut, reinterpret_cast<void**>(&MLnewclosure));
MH_EnableHook((void*)INIT_NUT_ADDRESS); MH_EnableHook((void*)INIT_NUT_ADDRESS);
//Hook绘制字符 //Hook绘制字符
MH_CreateHook((void*)INIT_NUT_DRAWCODE, &H_Register_DrawCode, reinterpret_cast<void**>(&DrawCodeF)); MH_CreateHook((void*)INIT_NUT_DRAWCODE, &H_Register_DrawCode, reinterpret_cast<void**>(&DrawCodeF));
MH_EnableHook((void*)INIT_NUT_DRAWCODE); MH_EnableHook((void*)INIT_NUT_DRAWCODE);
@ -1192,8 +1215,8 @@ int hook::RegisterHook()
//MH_EnableHook((void*)0x5A4BE0); //MH_EnableHook((void*)0x5A4BE0);
//MH_CreateHook((void*)0x1358A60, &NewSqPushStringFunc, reinterpret_cast<void**>(&OldSQPushString)); //MH_CreateHook((void*)0x11816B0, &New11816B0, reinterpret_cast<void**>(&Old11816B0));
//MH_EnableHook((void*)0x1358A60); //MH_EnableHook((void*)0x11816B0);
// HOOK exe 调用文本进 松鼠虚拟机 // HOOK exe 调用文本进 松鼠虚拟机

View File

@ -234,6 +234,7 @@ public://
public://NUT API 接口 public://NUT API 接口
static int sq_Test(uint32_t v);//测试接口 static int sq_Test(uint32_t v);//测试接口
static int sq_OpenConsole(uint32_t v);//´ò¿ª¿ØÖÆÌ¨
static int sq_Switching(uint32_t v);//换装参数 static int sq_Switching(uint32_t v);//换装参数
static int sq_MoveMap(uint32_t v);//顺图 static int sq_MoveMap(uint32_t v);//顺图
static int GetCharacterAttribute(uint32_t v);//读人物或装备属性 static int GetCharacterAttribute(uint32_t v);//读人物或装备属性

View File

@ -33,7 +33,8 @@
//#define LOCALHOSTS_SWITCH "本地免验证 开启" //#define LOCALHOSTS_SWITCH "本地免验证 开启"
//#define SELL "售卖 开启" //#define SELL "请求脚本 开启"
//#define RsHook "RsHook 开启"
//#define DOFILE_HOOK "群服dofile hook" //#define DOFILE_HOOK "群服dofile hook"

View File

@ -11,6 +11,7 @@ void sock::Pack_Control(int idx, int code, void* p3, void* p4)
Net_Get_Buffer(Buffer, Size); Net_Get_Buffer(Buffer, Size);
Buffer[Size] = '\0'; Buffer[Size] = '\0';
//std::cout << Buffer << std::endl;
/* /*
std::fstream OutputFile; std::fstream OutputFile;
OutputFile.open("Yosin_Log.txt", std::ios::app); OutputFile.open("Yosin_Log.txt", std::ios::app);
@ -71,6 +72,20 @@ void sock::Pack_Control(int idx, int code, void* p3, void* p4)
SQ_Call(v, 2, 0, 1); SQ_Call(v, 2, 0, 1);
SQPop(v, 2); SQPop(v, 2);
} }
#endif
//Ç©µ½
#if defined SIGNIN
if (Op > 20051000 && Op <= 20051999)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_Pack_Control", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushString(v, DNFTOOL::charTowchar_t(Buffer), -1);
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
}
#endif #endif
//ÊÀ½çBoss //ÊÀ½çBoss
#if defined WORLDBOSS_SWITCH #if defined WORLDBOSS_SWITCH

View File

@ -369,9 +369,26 @@ int squirrel::sq_Switching(uint32_t v)
return 1; return 1;
} }
//typedef int sub_1206600(int a1,int a2, int a3, int a4 ,int a5,...);
//static sub_1206600* Func1206600 = (sub_1206600*)0x1206600;
int squirrel::sq_Test(uint32_t v) int squirrel::sq_Test(uint32_t v)
{ {
//Func1206600(*(int*)0x1B45B94, 0x253, 0x1FD, 0xffffffff, *(int*)(0x19e868 + 0x1c));
return 0;
}
int squirrel::sq_OpenConsole(uint32_t v)
{
wchar_t* OutPutBuffer;
SQGetString(v, 2, &OutPutBuffer);
char* OutPutText = DNFTOOL::SquirrelU2W(OutPutBuffer);
AllocConsole();
SetConsoleTitleA(OutPutText);
//SetConsoleOutputCP(65001);
freopen(("CONOUT$"), ("w"), stdout);
freopen(("CONOUT$"), ("w"), stderr);
freopen(("CONIN$"), ("r"), stdin);
return 0; return 0;
} }
@ -2134,6 +2151,7 @@ void squirrel::RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t
void squirrel::R_Register_Nut() void squirrel::R_Register_Nut()
{ {
RegisterNutApi(L"L_sq_Test", squirrel::sq_Test); RegisterNutApi(L"L_sq_Test", squirrel::sq_Test);
RegisterNutApi(L"L_sq_OpenConsole", squirrel::sq_OpenConsole);
RegisterNutApi(L"L_sq_MoveMap", squirrel::sq_MoveMap); RegisterNutApi(L"L_sq_MoveMap", squirrel::sq_MoveMap);
RegisterNutApi(L"L_Sq_Err", Sq_Err); RegisterNutApi(L"L_Sq_Err", Sq_Err);
@ -2284,12 +2302,17 @@ void squirrel::SqrCallBackFunc()
void squirrel::InitGameScript() void squirrel::InitGameScript()
{ {
uint32_t v = GetSqVm(); uint32_t v = GetSqVm();
//ÏûÏ¢¿òð¤Ìù //ÏûÏ¢¿òð¤Ìù
#ifdef COPY_MESSAGE #ifdef COPY_MESSAGE
* (WORD*)0x011C53B0 = 0x01B0; * (WORD*)0x011C53B0 = 0x01B0;
#endif // COPY_MESSAGE #endif // COPY_MESSAGE
//ÖØ¸´HOOK
#ifdef RsHook
auto Registerfunc = reinterpret_cast<register_pack_handler_t>(0x7186D0);
Registerfunc(130, sock::Pack_Control, 0);
#endif // RsHook
#ifdef SELL #ifdef SELL
SQPushRootTable(v); SQPushRootTable(v);