layout: Add a function to get master hash
fix: Memory leak when WinOS client login
This commit is contained in:
@@ -26,6 +26,11 @@ config& GetThisCfg() {
|
||||
return *cfg;
|
||||
}
|
||||
|
||||
std::string GetMasterHash() {
|
||||
static std::string hash(skCrypt(MASTER_HASH));
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ֪BUG<55><47><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹʱ<D6B9><CAB1><EFBFBD>ô˺<C3B4><CBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>dump<6D>ļ<EFBFBD><C4BC><EFBFBD>dumpĿ¼.
|
||||
@@ -75,7 +80,7 @@ CMy2015RemoteApp::CMy2015RemoteApp()
|
||||
// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> InitInstance <20><>
|
||||
m_Mutex = NULL;
|
||||
std::string masterHash(skCrypt(MASTER_HASH));
|
||||
std::string masterHash(GetMasterHash());
|
||||
m_iniFile = GetPwdHash() == masterHash ? new config : new iniFile;
|
||||
|
||||
srand(static_cast<unsigned int>(time(0)));
|
||||
@@ -91,7 +96,7 @@ CMy2015RemoteApp theApp;
|
||||
|
||||
BOOL CMy2015RemoteApp::InitInstance()
|
||||
{
|
||||
std::string masterHash(skCrypt(MASTER_HASH));
|
||||
std::string masterHash(GetMasterHash());
|
||||
std::string mu = GetPwdHash()==masterHash ? "MASTER.EXE" : "YAMA.EXE";
|
||||
#ifndef _DEBUG
|
||||
{
|
||||
|
||||
@@ -132,6 +132,8 @@ CMy2015RemoteApp* GetThisApp();
|
||||
|
||||
config& GetThisCfg();
|
||||
|
||||
std::string GetMasterHash();
|
||||
|
||||
#define THIS_APP GetThisApp()
|
||||
|
||||
#define THIS_CFG GetThisCfg()
|
||||
|
||||
@@ -232,7 +232,7 @@ DllInfo* ReadPluginDll(const std::string& filename) {
|
||||
delete[] buffer;
|
||||
return nullptr;
|
||||
}
|
||||
std::string masterHash(skCrypt(MASTER_HASH));
|
||||
std::string masterHash(GetMasterHash());
|
||||
int offset = MemoryFind((char*)dllData, masterHash.c_str(), fileSize, masterHash.length());
|
||||
if (offset != -1) {
|
||||
std::string masterId = GetPwdHash(), hmac = GetHMAC();
|
||||
@@ -447,7 +447,7 @@ VOID CMy2015RemoteDlg::CreateSolidMenu()
|
||||
{
|
||||
m_MainMenu.LoadMenu(IDR_MENU_MAIN);
|
||||
CMenu* SubMenu = m_MainMenu.GetSubMenu(1);
|
||||
std::string masterHash(skCrypt(MASTER_HASH));
|
||||
std::string masterHash(GetMasterHash());
|
||||
if (GetPwdHash() != masterHash) {
|
||||
SubMenu->DeleteMenu(ID_TOOL_GEN_MASTER, MF_BYCOMMAND);
|
||||
}
|
||||
@@ -725,6 +725,7 @@ Buffer* ReadKernelDll(bool is64Bit, bool isDLL=true, const std::string &addr="")
|
||||
if (!addr.empty()) {
|
||||
splitIpPort(addr, ip, port);
|
||||
server->SetServer(ip.c_str(), atoi(port.c_str()));
|
||||
server->SetAdminId(GetMasterHash().c_str());
|
||||
}
|
||||
server->SetType(isDLL ? CLIENT_TYPE_MEMDLL : CLIENT_TYPE_SHELLCODE);
|
||||
memcpy(server->pwdHash, GetPwdHash().c_str(), 64);
|
||||
@@ -831,7 +832,7 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
||||
OnMainExit();
|
||||
return FALSE;
|
||||
}
|
||||
if (GetPwdHash() == std::string(skCrypt(MASTER_HASH))) {
|
||||
if (GetPwdHash() == GetMasterHash()) {
|
||||
auto pass = THIS_CFG.GetStr("settings", "superAdmin");
|
||||
if (hashSHA256(pass) == GetPwdHash()) {
|
||||
m_superPass = pass;
|
||||
@@ -883,6 +884,8 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
||||
if (offset != -1) {
|
||||
CONNECT_ADDRESS* p = (CONNECT_ADDRESS*)(data + offset);
|
||||
p->SetServer(v->Admin, v->Port);
|
||||
p->SetAdminId(GetMasterHash().c_str());
|
||||
p->iType = CLIENT_TYPE_MEMDLL;
|
||||
memcpy(p->pwdHash, GetPwdHash().c_str(), 64);
|
||||
m_tinyDLL = MemoryLoadLibrary(data, size);
|
||||
}
|
||||
@@ -1068,7 +1071,7 @@ void CMy2015RemoteDlg::OnTimer(UINT_PTR nIDEvent)
|
||||
if (!m_superPass.empty()) {
|
||||
Mprintf(">>> Timer is killed <<<\n");
|
||||
KillTimer(nIDEvent);
|
||||
std::string masterHash = std::string(skCrypt(MASTER_HASH));
|
||||
std::string masterHash = GetMasterHash();
|
||||
if (GetPwdHash() == masterHash) {
|
||||
THIS_CFG.SetStr("settings", "superAdmin", m_superPass);
|
||||
THIS_CFG.SetStr("settings", "HMAC", genHMAC(masterHash, m_superPass));
|
||||
@@ -1246,7 +1249,7 @@ void CMy2015RemoteDlg::OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
SubMenu->EnableMenuItem(i, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); //菜单全部变灰
|
||||
}
|
||||
}
|
||||
else if (GetPwdHash() != std::string(skCrypt(MASTER_HASH))) {
|
||||
else if (GetPwdHash() != GetMasterHash()) {
|
||||
SubMenu->EnableMenuItem(ID_ONLINE_AUTHORIZE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||
SubMenu->EnableMenuItem(ID_ONLINE_UNAUTHORIZE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||
}
|
||||
@@ -1444,7 +1447,7 @@ bool CMy2015RemoteDlg::CheckValid(int trail) {
|
||||
|
||||
if (!isTrail) {
|
||||
const Validation *verify = GetValidation();
|
||||
std::string masterHash = skCrypt(MASTER_HASH);
|
||||
std::string masterHash = GetMasterHash();
|
||||
if (masterHash != GetPwdHash() && !verify->IsValid()) {
|
||||
KillTimer(TIMER_CHECK);
|
||||
MessageBox("此程序已经失效,请联系管理员处理!", "提示", MB_ICONWARNING);
|
||||
@@ -2517,7 +2520,7 @@ void CMy2015RemoteDlg::OnToolGenMaster()
|
||||
MessageBox("请通过菜单设置当前主控程序的公网地址(域名)! 此地址会写入即将生成的主控程序中。"
|
||||
"\n只有正确设置公网地址,才能在线延长由本程序所生成的主控程序的有效期。", "提示", MB_ICONINFORMATION);
|
||||
}
|
||||
std::string masterHash(skCrypt(MASTER_HASH));
|
||||
std::string masterHash(GetMasterHash());
|
||||
if (m_superPass.empty()) {
|
||||
CInputDialog pass(this);
|
||||
pass.Init("主控生成", "当前主控程序的密码:");
|
||||
@@ -2706,7 +2709,7 @@ void CMy2015RemoteDlg::OnOnlineAuthorize()
|
||||
pass.Init("需要密码", "当前主控程序的密码:");
|
||||
if (pass.DoModal() != IDOK || pass.m_str.IsEmpty())
|
||||
return;
|
||||
std::string masterHash(skCrypt(MASTER_HASH));
|
||||
std::string masterHash(GetMasterHash());
|
||||
if (hashSHA256(pass.m_str.GetBuffer()) != masterHash) {
|
||||
MessageBox("密码不正确!", "错误", MB_ICONWARNING);
|
||||
return;
|
||||
@@ -2795,7 +2798,7 @@ void CMy2015RemoteDlg::OnOnlineUnauthorize()
|
||||
pass.Init("需要密码", "当前主控程序的密码:");
|
||||
if (pass.DoModal() != IDOK || pass.m_str.IsEmpty())
|
||||
return;
|
||||
std::string masterHash(skCrypt(MASTER_HASH));
|
||||
std::string masterHash(GetMasterHash());
|
||||
if (hashSHA256(pass.m_str.GetBuffer()) != masterHash) {
|
||||
MessageBox("密码不正确!", "错误", MB_ICONWARNING);
|
||||
return;
|
||||
|
||||
@@ -149,6 +149,7 @@ void CBuildDlg::OnBnClickedOk()
|
||||
}
|
||||
//////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ//////////////////////
|
||||
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "", typ, false, DLL_VERSION, 0, startup, HeaderEncV0 };
|
||||
g_ConnectAddress.SetAdminId(GetMasterHash().c_str());
|
||||
g_ConnectAddress.SetServer(m_strIP, atoi(m_strPort));
|
||||
g_ConnectAddress.runningType = m_ComboRunType.GetCurSel();
|
||||
g_ConnectAddress.protoType = m_ComboProto.GetCurSel();
|
||||
|
||||
@@ -62,7 +62,7 @@ bool WritePwdHash(char* target, const std::string & pwdHash, const Validation& v
|
||||
|
||||
bool IsPwdHashValid(const char* hash) {
|
||||
const char* ptr = hash ? hash : g_MasterID;
|
||||
if (ptr == std::string(skCrypt(MASTER_HASH)))
|
||||
if (ptr == GetMasterHash())
|
||||
return true;
|
||||
std::string pwdHash(ptr, 64), s1(ptr +64, 32), s2(ptr +96, 4);
|
||||
char output32[33], output4[5];
|
||||
|
||||
@@ -479,6 +479,7 @@ BOOL ParseReceivedData(CONTEXT_OBJECT * ContextObject, DWORD dwTrans, pfnNotifyP
|
||||
ContextObject->InDeCompressedBuffer.WriteBuffer(CompressedBuffer, ulCompressedLength);
|
||||
if (m_NotifyProc(ContextObject))
|
||||
ret = CompressedBuffer[0] == TOKEN_LOGIN ? 999 : 1;
|
||||
SAFE_DELETE_ARRAY(CompressedBuffer);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user