diff --git a/test/DNFTOOL.cpp b/test/DNFTOOL.cpp index af35584..46f0f31 100644 --- a/test/DNFTOOL.cpp +++ b/test/DNFTOOL.cpp @@ -1,5 +1,175 @@ #include "pch.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 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) { diff --git a/test/DNFTOOL.h b/test/DNFTOOL.h index d08ed7e..25ef5ba 100644 --- a/test/DNFTOOL.h +++ b/test/DNFTOOL.h @@ -65,6 +65,12 @@ private: public: + //获取用户IP + static std::string GetUserIp(); + + //验证IP是否通过 + static bool ReqIpLicense(std::string ippack, std::string Rqip); + //获取EXE使用头 号位数据 static int GetExeNutWrtNum(int Pos); diff --git a/test/dllmain.cpp b/test/dllmain.cpp index c22b4cb..a7085ff 100644 --- a/test/dllmain.cpp +++ b/test/dllmain.cpp @@ -4,13 +4,10 @@ #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 RbState = 0; int MbState = 0; -extern bool Sinw = false; void LenheartThread() @@ -29,194 +26,17 @@ void LenheartThread() { //鑾峰彇楠岃瘉鏈嶅姟鍣╥p std::string Rqip = DNFTOOL::GetIP(); + //std::string Rqip = "192.168.200.13"; //std::cout << "楠岃瘉鏈嶅姟鍣↖P:" << Rqip << std::endl; - - - //鑾峰彇楠岃瘉IP - std::string ippack; - //鑾峰彇ExeIP - int gameip = *(int*)0x1AE9CEC; - - /* - std::cout << gameip << std::endl; - //鍗曠嫭瀹氬埗鐨勮劚鏈篒P - if (gameip == 3735605) - { - - - Sinw = true; - //int skey[] = Skey;//瀹氫箟瑙e瘑鏁扮粍 - //Cutecode(nutstr, skey);//瑙e瘑 - - //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; - //宸茬粡寰楀埌浜嗘湰鏈篒P - - 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); - } - - - - - + //鑾峰彇鐢ㄦ埛IP + std::string ippack = DNFTOOL::GetUserIp(); //std::cout << "楠岃瘉IP:" << ippack << std::endl; - //宸茬粡鑾峰彇浜嗚鍙戦佺殑楠岃瘉IP - LenheartBase::CBASE64 bb; - ippack += "\nip"; + //楠岃瘉骞惰姹傚姞杞借剼鏈 + DNFTOOL::ReqIpLicense(ippack, Rqip); - 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("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 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;//瀹氫箟瑙e瘑鏁扮粍 - Cutecode(nutstr, skey);//瑙e瘑 - - 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++; - } - } + return; } } } @@ -249,7 +69,6 @@ __declspec(dllexport) void Lenheart() - //淇敼ui void HookHudUi() { diff --git a/test/hook.cpp b/test/hook.cpp index ccad664..683dab0 100644 --- a/test/hook.cpp +++ b/test/hook.cpp @@ -81,6 +81,7 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, //Hook文字 + #ifdef CODEDRAW if (CodeDrawMap.count(GameStr) == 1) { @@ -159,7 +160,7 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, #endif - //buff换装 + //强化系统 #ifdef NEWUPGRADE_SWITCH 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 #ifdef DRAWITEM + static bool OpenSw = false; if (!OpenSw) { @@ -745,31 +747,32 @@ int _fastcall newsub11A8F60(DWORD a1, DWORD Seat, int a2, int a3, int a4) } else { - uint32_t v = GetSqVm(); - SQPushRootTable(v); - SQPushString(v, L"Sq_DrawItemBack", -1); - SQ_Get(v, -2); - SQPushRootTable(v); - SQPushInt(v, a2); - SQPushInt(v, a3); - SQPushInt(v, a4); - SQ_Call(v, 4, 0, 1); - SQPop(v, 2); + //uint32_t v = GetSqVm(); + //SQPushRootTable(v); + //SQPushString(v, L"Sq_DrawItemBack", -1); + //SQ_Get(v, -2); + //SQPushRootTable(v); + //SQPushInt(v, a2); + //SQPushInt(v, a3); + //SQPushInt(v, a4); + //SQ_Call(v, 4, 0, 1); + //SQPop(v, 2); int ret = sub11A8F60(a1, 0, a2, a3, a4); - SQPushRootTable(v); - SQPushString(v, L"Sq_DrawItemFront", -1); - SQ_Get(v, -2); - SQPushRootTable(v); - SQPushInt(v, a2); - SQPushInt(v, a3); - SQPushInt(v, a4); - SQ_Call(v, 4, 0, 1); - SQPop(v, 2); + //SQPushRootTable(v); + //SQPushString(v, L"Sq_DrawItemFront", -1); + //SQ_Get(v, -2); + //SQPushRootTable(v); + //SQPushInt(v, a2); + //SQPushInt(v, a3); + //SQPushInt(v, a4); + //SQ_Call(v, 4, 0, 1); + //SQPop(v, 2); return ret; } + #endif } #endif @@ -989,6 +992,7 @@ DWORD** _fastcall NewEvent(DWORD thisc, DWORD Seat, DWORD a2, DWORD** a3, char a a2 += 167; a3 = (DWORD**)527; } + 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 + + +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() { - + MH_Initialize(); //MH_CreateHook((void*)0x9D2300, &New_9D2300, reinterpret_cast(&Old_9D2300)); @@ -1094,7 +1117,7 @@ int hook::RegisterHook() //HookNut函数注册 MH_CreateHook((void*)INIT_NUT_ADDRESS, &H_Register_Nut, reinterpret_cast(&MLnewclosure)); MH_EnableHook((void*)INIT_NUT_ADDRESS); - + //Hook绘制字符 MH_CreateHook((void*)INIT_NUT_DRAWCODE, &H_Register_DrawCode, reinterpret_cast(&DrawCodeF)); MH_EnableHook((void*)INIT_NUT_DRAWCODE); @@ -1192,8 +1215,8 @@ int hook::RegisterHook() //MH_EnableHook((void*)0x5A4BE0); - //MH_CreateHook((void*)0x1358A60, &NewSqPushStringFunc, reinterpret_cast(&OldSQPushString)); - //MH_EnableHook((void*)0x1358A60); + //MH_CreateHook((void*)0x11816B0, &New11816B0, reinterpret_cast(&Old11816B0)); + //MH_EnableHook((void*)0x11816B0); // HOOK exe 调用文本进 松鼠虚拟机 diff --git a/test/lsquirrel.h b/test/lsquirrel.h index 317f77b..ca97807 100644 --- a/test/lsquirrel.h +++ b/test/lsquirrel.h @@ -234,6 +234,7 @@ public:// public://NUT API 接口 static int sq_Test(uint32_t v);//测试接口 + static int sq_OpenConsole(uint32_t v);//打开控制台 static int sq_Switching(uint32_t v);//换装参数 static int sq_MoveMap(uint32_t v);//顺图 static int GetCharacterAttribute(uint32_t v);//读人物或装备属性 diff --git a/test/pch.h b/test/pch.h index 9057669..870e9e9 100644 --- a/test/pch.h +++ b/test/pch.h @@ -33,7 +33,8 @@ //#define LOCALHOSTS_SWITCH "鏈湴鍏嶉獙璇 寮鍚" -//#define SELL "鍞崠 寮鍚" +//#define SELL "璇锋眰鑴氭湰 寮鍚" +//#define RsHook "RsHook 寮鍚" //#define DOFILE_HOOK "缇ゆ湇dofile hook" diff --git a/test/sock.cpp b/test/sock.cpp index ebc4a92..fdbba44 100644 --- a/test/sock.cpp +++ b/test/sock.cpp @@ -11,6 +11,7 @@ void sock::Pack_Control(int idx, int code, void* p3, void* p4) Net_Get_Buffer(Buffer, Size); Buffer[Size] = '\0'; + //std::cout << Buffer << std::endl; /* std::fstream OutputFile; 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); 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 //世界Boss #if defined WORLDBOSS_SWITCH diff --git a/test/squirrel.cpp b/test/squirrel.cpp index 54c9295..fa5a7cd 100644 --- a/test/squirrel.cpp +++ b/test/squirrel.cpp @@ -369,9 +369,26 @@ int squirrel::sq_Switching(uint32_t v) 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) { + //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; } @@ -2134,6 +2151,7 @@ void squirrel::RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t void squirrel::R_Register_Nut() { 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_Err", Sq_Err); @@ -2284,12 +2302,17 @@ void squirrel::SqrCallBackFunc() void squirrel::InitGameScript() { uint32_t v = GetSqVm(); - //消息框黏贴 #ifdef COPY_MESSAGE * (WORD*)0x011C53B0 = 0x01B0; #endif // COPY_MESSAGE + //重复HOOK +#ifdef RsHook + auto Registerfunc = reinterpret_cast(0x7186D0); + Registerfunc(130, sock::Pack_Control, 0); +#endif // RsHook + #ifdef SELL SQPushRootTable(v);