From 1a72a4f5205fcb51164d2fd76311e6a209cb8d76 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Mon, 21 Jul 2025 04:34:48 +0800 Subject: [PATCH] Fix password inputting issue and improve authorization --- server/2015Remote/2015Remote.rc | Bin 90322 -> 90522 bytes server/2015Remote/2015RemoteDlg.cpp | 58 ++++++++++++++++++++++------ server/2015Remote/2015RemoteDlg.h | 1 + server/2015Remote/BuildDlg.cpp | 2 +- server/2015Remote/CPasswordDlg.cpp | 6 +-- server/2015Remote/InputDlg.cpp | 1 + server/2015Remote/SettingDlg.cpp | 2 +- server/2015Remote/resource.h | Bin 44798 -> 44986 bytes 8 files changed, 53 insertions(+), 17 deletions(-) diff --git a/server/2015Remote/2015Remote.rc b/server/2015Remote/2015Remote.rc index e1dae101db1f4d1e2a10757d8ba71c2bcc45efcf..0cd4d275835a936e4071dca4e0f8f2dcce984580 100644 GIT binary patch delta 147 zcmca~kagB!)(sNPZ1?(?CKsem4zQBjY}4$}&O5n3HSlrp6F&_GH3rYg2frFmKfuk% zBk9TD#}L2}$`Ha352PI#f`Krc!Ji>$a^h?8=^um{eWurNF}|4m?h4oR2f~aT)9-LF z@@*I3Vcf$w+3%^$^agIA*e4c7tLgi=7`djO;bzpEK7oT#Vfq{aMy_pqjF*A{AKo!z delta 79 zcmV-V0I>g>!v)g81+W-{2EL02S#V{OP&yv7JcB@omqZHz=#$Xp91Zu2LTrd*LuV)e lCIC>EQ40Y-mv9aNE|VVb2)8~A0m=cF;35Gkx4sSm+)~p+9YX*B diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index 004a9ee..faf4769 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -410,6 +410,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx) ON_NOTIFY(NM_DBLCLK, IDC_ONLINE, &CMy2015RemoteDlg::OnListClick) ON_COMMAND(ID_ONLINE_UNAUTHORIZE, &CMy2015RemoteDlg::OnOnlineUnauthorize) ON_COMMAND(ID_TOOL_REQUEST_AUTH, &CMy2015RemoteDlg::OnToolRequestAuth) + ON_COMMAND(ID_TOOL_INPUT_PASSWORD, &CMy2015RemoteDlg::OnToolInputPassword) END_MESSAGE_MAP() @@ -927,7 +928,7 @@ BOOL CMy2015RemoteDlg::OnInitDialog() int nMaxConnection = THIS_CFG.GetInt("settings", "MaxConnection"); m_nMaxConnection = nMaxConnection <= 0 ? 10000 : nMaxConnection; } - const std::string method = THIS_CFG.GetStr("settings", "UDPOption"); + const std::string method = THIS_CFG.GetStr("settings", "UDPOption", "0"); if (!Activate(nPort, m_nMaxConnection, method)){ OnCancel(); return FALSE; @@ -948,10 +949,12 @@ BOOL CMy2015RemoteDlg::OnInitDialog() ExitProcess(-1); return FALSE; } + int tm = THIS_CFG.GetInt("settings", "Notify", 10); + tm = min(tm, 10); #ifdef _DEBUG - SetTimer(TIMER_CHECK, 10 * 1000, NULL); + SetTimer(TIMER_CHECK, max(1, tm) * 1000, NULL); #else - SetTimer(TIMER_CHECK, 600 * 1000, NULL); + SetTimer(TIMER_CHECK, max(1, tm) * 60 * 1000, NULL); #endif IPConverter cvt; CString tip = !ip.empty() && ip != cvt.getPublicIP() ? @@ -1085,18 +1088,20 @@ LRESULT CMy2015RemoteDlg::OnPasswordCheck(WPARAM wParam, LPARAM lParam) { isChecking = true; if (!CheckValid(-1)) { - KillTimer(TIMER_CHECK); CInputDialog dlg(this); dlg.m_str = m_superPass.c_str(); dlg.Init("输入密码", "输入主控程序的密码:"); dlg.DoModal(); if (hashSHA256(dlg.m_str.GetString()) != GetPwdHash()) { - THIS_APP->UpdateMaxConnection(1); + KillTimer(TIMER_CHECK); + m_nMaxConnection = 1; + THIS_APP->UpdateMaxConnection(m_nMaxConnection); + int tm = THIS_CFG.GetInt("settings", "Notify", 10); + THIS_CFG.SetInt("settings", "Notify", tm - 1); MessageBox("请向管理员申请口令。", "提示", MB_ICONWARNING); } else { m_superPass = dlg.m_str.GetString(); - MessageBox("请及时对当前主控程序授权: 在工具菜单中生成口令!", "提示", MB_ICONWARNING); } } isChecking = false; @@ -1471,7 +1476,6 @@ bool CMy2015RemoteDlg::CheckValid(int trail) { const Validation *verify = GetValidation(); std::string masterHash = GetMasterHash(); if (masterHash != GetPwdHash() && !verify->IsValid()) { - KillTimer(TIMER_CHECK); MessageBox("此程序已经失效,请联系管理员处理!", "提示", MB_ICONWARNING); OnMainExit(); ExitProcess(-1); @@ -1488,7 +1492,6 @@ bool CMy2015RemoteDlg::CheckValid(int trail) { dlg.m_sDeviceID = deviceID.c_str(); dlg.m_sPassword = pwd; if (pwd.IsEmpty() && IDOK != dlg.DoModal() || dlg.m_sPassword.IsEmpty()) { - KillTimer(TIMER_CHECK); return false; } @@ -1498,7 +1501,6 @@ bool CMy2015RemoteDlg::CheckValid(int trail) { { THIS_CFG.SetStr(settings, pwdKey, ""); MessageBox("格式错误,请重新申请口令!", "提示", MB_ICONINFORMATION); - KillTimer(TIMER_CHECK); return false; } std::vector subvector(v.end() - 4, v.end()); @@ -1508,10 +1510,9 @@ bool CMy2015RemoteDlg::CheckValid(int trail) { std::string fixedKey = getFixedLengthID(finalKey); if (hash256 != fixedKey) { THIS_CFG.SetStr(settings, pwdKey, ""); - if (pwd.IsEmpty() || (IDOK != dlg.DoModal() || hash256 != fixedKey)) { + if (pwd.IsEmpty() || hash256 != fixedKey || IDOK != dlg.DoModal()) { if (!dlg.m_sPassword.IsEmpty()) MessageBox("口令错误, 无法继续操作!", "提示", MB_ICONWARNING); - KillTimer(TIMER_CHECK); return false; } } @@ -1522,11 +1523,16 @@ bool CMy2015RemoteDlg::CheckValid(int trail) { if (curDate < v[0] || curDate > v[1]) { THIS_CFG.SetStr(settings, pwdKey, ""); MessageBox("口令过期,请重新申请口令!", "提示", MB_ICONINFORMATION); - KillTimer(TIMER_CHECK); return false; } if (dlg.m_sPassword != pwd) THIS_CFG.SetStr(settings, pwdKey, dlg.m_sPassword.GetString()); + + int maxConn = v.size() == 7 ? atoi(v[2].c_str()) : 1; + if (maxConn != m_nMaxConnection) { + m_nMaxConnection = maxConn; + THIS_APP->UpdateMaxConnection(m_nMaxConnection); + } } return true; } @@ -2322,6 +2328,10 @@ void CMy2015RemoteDlg::OnToolAuth() dlg.DoModal(); if (!dlg.m_sUserPwd.IsEmpty()){ m_superPass = dlg.m_sUserPwd; + if (deviceID.c_str() == dlg.m_sDeviceID) { + m_nMaxConnection = dlg.m_nHostNum; + THIS_APP->UpdateMaxConnection(m_nMaxConnection); + } } } @@ -2856,3 +2866,27 @@ void CMy2015RemoteDlg::OnToolRequestAuth() CString url = _T("https://github.com/yuanyuanxiang/SimpleRemoter/wiki#请求授权"); ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWNORMAL); } + + +void CMy2015RemoteDlg::OnToolInputPassword() +{ + if (CheckValid(-1)) { + CString pwd = THIS_CFG.GetStr("settings", "Password", "").c_str(); + auto v = splitString(pwd.GetBuffer(), '-'); + CString info; + info.Format("软件有效期限: %s — %s, 并发连接数量: %d.", v[0].c_str(), v[1].c_str(), atoi(v[2].c_str())); + if (IDYES == MessageBoxA(info + "\n如需修改授权信息,请联系管理员。是否现在修改授权?", "提示", MB_YESNO | MB_ICONINFORMATION)) { + CInputDialog dlg(this); + dlg.m_str = pwd; + dlg.Init("更改口令", "请输入新的口令:"); + if (dlg.DoModal() == IDOK) { + THIS_CFG.SetStr("settings", "Password", dlg.m_str.GetString()); +#ifdef _DEBUG + SetTimer(TIMER_CHECK, 10 * 1000, NULL); +#else + SetTimer(TIMER_CHECK, 600 * 1000, NULL); +#endif + } + } + } +} diff --git a/server/2015Remote/2015RemoteDlg.h b/server/2015Remote/2015RemoteDlg.h index 1bac030..8398ac4 100644 --- a/server/2015Remote/2015RemoteDlg.h +++ b/server/2015Remote/2015RemoteDlg.h @@ -264,4 +264,5 @@ public: afx_msg void OnOnlineUnauthorize(); afx_msg void OnToolRequestAuth(); afx_msg LRESULT OnPasswordCheck(WPARAM wParam, LPARAM lParam); + afx_msg void OnToolInputPassword(); }; diff --git a/server/2015Remote/BuildDlg.cpp b/server/2015Remote/BuildDlg.cpp index f74b1ff..cc40b3f 100644 --- a/server/2015Remote/BuildDlg.cpp +++ b/server/2015Remote/BuildDlg.cpp @@ -257,7 +257,7 @@ BOOL CBuildDlg::OnInitDialog() m_ComboExe.InsertString(IndexGhost, "ghost.exe"); m_ComboExe.InsertString(IndexServerDll, "ServerDll.dll"); m_ComboExe.InsertString(OTHER_ITEM, CString("ѡļ")); - m_ComboExe.SetCurSel(0); + m_ComboExe.SetCurSel(IndexTestRun_MemDLL); m_ComboBits.InsertString(0, "64λ"); m_ComboBits.InsertString(1, "32λ"); diff --git a/server/2015Remote/CPasswordDlg.cpp b/server/2015Remote/CPasswordDlg.cpp index 632d613..9ea3716 100644 --- a/server/2015Remote/CPasswordDlg.cpp +++ b/server/2015Remote/CPasswordDlg.cpp @@ -94,7 +94,7 @@ void CPasswordDlg::DoDataExchange(CDataExchange* pDX) DDX_Text(pDX, IDC_EDIT_DEVICEID, m_sDeviceID); DDV_MaxChars(pDX, m_sDeviceID, 19); DDX_Text(pDX, IDC_EDIT_DEVICEPWD, m_sPassword); - DDV_MaxChars(pDX, m_sPassword, 37); + DDV_MaxChars(pDX, m_sPassword, 42); } @@ -144,7 +144,7 @@ void CPwdGenDlg::DoDataExchange(CDataExchange* pDX) DDX_Text(pDX, IDC_EDIT_DEVICEID, m_sDeviceID); DDV_MaxChars(pDX, m_sDeviceID, 19); DDX_Text(pDX, IDC_EDIT_DEVICEPWD, m_sPassword); - DDV_MaxChars(pDX, m_sPassword, 37); + DDV_MaxChars(pDX, m_sPassword, 42); DDX_Text(pDX, IDC_EDIT_USERPWD, m_sUserPwd); DDV_MaxChars(pDX, m_sUserPwd, 24); DDX_Control(pDX, IDC_EXPIRE_DATE, m_PwdExpireDate); @@ -153,7 +153,7 @@ void CPwdGenDlg::DoDataExchange(CDataExchange* pDX) DDX_DateTimeCtrl(pDX, IDC_START_DATE, m_StartTm); DDX_Control(pDX, IDC_EDIT_HOSTNUM, m_EditHostNum); DDX_Text(pDX, IDC_EDIT_HOSTNUM, m_nHostNum); - DDV_MinMaxInt(pDX, m_nHostNum, 1, 9999); + DDV_MinMaxInt(pDX, m_nHostNum, 1, 10000); } diff --git a/server/2015Remote/InputDlg.cpp b/server/2015Remote/InputDlg.cpp index 1e6dc19..9f371cd 100644 --- a/server/2015Remote/InputDlg.cpp +++ b/server/2015Remote/InputDlg.cpp @@ -57,6 +57,7 @@ BOOL CInputDialog::OnInitDialog() SetWindowText(m_sCaption); GetDlgItem(IDC_STATIC)->SetWindowText(m_sPrompt); + GetDlgItem(IDC_EDIT_FOLDERNAME)->SetWindowText(m_str); m_Static2thInput.SetWindowTextA(m_sItemName); m_Static2thInput.ShowWindow(m_sItemName.IsEmpty() ? SW_HIDE : SW_SHOW); diff --git a/server/2015Remote/SettingDlg.cpp b/server/2015Remote/SettingDlg.cpp index 62761cd..c134c64 100644 --- a/server/2015Remote/SettingDlg.cpp +++ b/server/2015Remote/SettingDlg.cpp @@ -74,7 +74,7 @@ BOOL CSettingDlg::OnInitDialog() m_sPublicIP = THIS_CFG.GetStr("settings", "master", "").c_str(); m_sPublicIP = m_sPublicIP.IsEmpty() ? cvt.getPublicIP().c_str() : m_sPublicIP; std::string nPort = THIS_CFG.GetStr("settings", "ghost", "6543"); - m_sUdpOption = THIS_CFG.GetStr("settings", "UDPOption", "").c_str(); + m_sUdpOption = THIS_CFG.GetStr("settings", "UDPOption", "0").c_str(); int DXGI = THIS_CFG.GetInt("settings", "DXGI"); diff --git a/server/2015Remote/resource.h b/server/2015Remote/resource.h index 9c83c8ec24d20afb827d56a46e668af9ea3f907b..6aabb768557fa57e48d42cfa8cbde4a30649b0de 100644 GIT binary patch delta 74 zcmV-Q0JZ=A-2%Gb008ju` g092DP8z+;{s|W!#vz4rk0h0nD7L$Oj6q8J@vWOrZApigX delta 26 kcmV+#0OkL>-va*K0