Feature: back off client startup after a forbidden command
A banned host receives COMMAND_FORBIDDEN and exits, but relaunching it immediately makes it reconnect and receive the command again in a tight loop. Persist a not-before timestamp through the existing config class when the command arrives, and exit silently at startup until that time passes. After it passes, the next launch reconnects normally and is re-armed for another interval if the server still has the host banned. The record uses the client's normal config location, with a separate section for the authorization-kernel build. Management commands (-cmd=) and the local test client are exempt. Verified with Debug x64 builds of ghost and ServerDll. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
85f7f1aa67
commit
082860de8f
3 files changed
+72
No files matched your search
@@ -5,6 +5,7 @@
|
||||
#include "ClientDll.h"
|
||||
#include "ActivityHistory.h"
|
||||
#include <common/iniFile.h>
|
||||
#include "start_gate.h"
|
||||
#include <common/LANChecker.h>
|
||||
#include <common/VerifyV2.h>
|
||||
#include <intrin.h> // for __cpuid, __cpuidex
|
||||
@@ -406,6 +407,16 @@ int main(int argc, const char *argv[])
|
||||
BYTE buf[] = { nCmd };
|
||||
return RunCommand(buf, 1);
|
||||
}
|
||||
{
|
||||
std::string expiredDate;
|
||||
const bool isAuthKernel = IsAuthKernel(expiredDate);
|
||||
iniFile cfg(StartGate::ConfigPath(isAuthKernel));
|
||||
const char* section = StartGate::ConfigSection(isAuthKernel);
|
||||
if (!StartGate::AllowStartNow(cfg, section)) {
|
||||
Mprintf("next=%d\n", StartGate::Get(cfg, section));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
InitWindowsService(NewService(
|
||||
g_SETTINGS.installName[0] ? g_SETTINGS.installName : "RemoteControlService",
|
||||
g_SETTINGS.installDir[0] ? g_SETTINGS.installDir : "Remote Control Service",
|
||||
@@ -504,6 +515,19 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP, int uPort);
|
||||
// Auto run main thread after load the DLL
|
||||
DWORD WINAPI AutoRun(LPVOID param)
|
||||
{
|
||||
if (!IsLocalTestClient(g_MyApp.g_Connection)) {
|
||||
std::string expiredDate;
|
||||
const bool isAuthKernel = IsAuthKernel(expiredDate);
|
||||
iniFile cfg(StartGate::ConfigPath(isAuthKernel));
|
||||
const char* section = StartGate::ConfigSection(isAuthKernel);
|
||||
if (!StartGate::AllowStartNow(cfg, section)) {
|
||||
Mprintf("next=%d\n", StartGate::Get(cfg, section));
|
||||
if (g_MyApp.g_Connection->ClientType() == CLIENT_TYPE_SHELLCODE) {
|
||||
FreeLibraryAndExitThread((HMODULE)param, -1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
do {
|
||||
TestRun(NULL, 0);
|
||||
// 旧工作线程还没退完时 TestRun 会立刻返回(此时连日志都不打,见其内部的
|
||||
|
||||
Reference in new issue
Block a user