init
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{5cabfae0-d81b-47a9-a7ba-bc7510be19df}</ProjectGuid>
|
||||
<RootNamespace>AnitCheatDLL</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>Anit_Cheat_DLL_x32</TargetName>
|
||||
<OutDir>$(SolutionDir)Bin\$(Platform)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>Anit_Cheat_DLL_x64</TargetName>
|
||||
<OutDir>$(SolutionDir)Bin\$(Platform)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;ANITCHEATDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;ANITCHEATDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;ANITCHEATDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;ANITCHEATDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="active_check.cpp" />
|
||||
<ClCompile Include="client_comm_shared.cpp" />
|
||||
<ClCompile Include="client_palpit.cpp" />
|
||||
<ClCompile Include="client_pipe.cpp" />
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="client_driver.cpp" />
|
||||
<ClCompile Include="driver_func.cpp" />
|
||||
<ClCompile Include="exprots_api_func.cpp" />
|
||||
<ClCompile Include="private_funcion.cpp" />
|
||||
<ClCompile Include="utils.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="active_check.h" />
|
||||
<ClInclude Include="Base.h" />
|
||||
<ClInclude Include="client_comm_shared.h" />
|
||||
<ClInclude Include="client_driver.h" />
|
||||
<ClInclude Include="client_palpit.h" />
|
||||
<ClInclude Include="client_pipe.h" />
|
||||
<ClInclude Include="driver_func.h" />
|
||||
<ClInclude Include="exprots_api_func.h" />
|
||||
<ClInclude Include="private_funcion.h" />
|
||||
<ClInclude Include="utils.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="exprots_api_func">
|
||||
<UniqueIdentifier>{4cff08df-0e1b-481a-942d-bd70368f6d90}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Driver">
|
||||
<UniqueIdentifier>{3b6d2fba-e76e-479d-b0da-d175d4c27e2f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="utils">
|
||||
<UniqueIdentifier>{fc2d9f5d-5c5f-45c0-8b29-64c039ca6699}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="private_funcion">
|
||||
<UniqueIdentifier>{6b86d410-ce98-4b8b-b00f-80a32eeeb438}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="comm_shared">
|
||||
<UniqueIdentifier>{76008651-8a11-42af-b854-41f7cd04a319}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="client_palpit">
|
||||
<UniqueIdentifier>{f04162c8-3fb0-4100-822c-af77bb70dbf5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="active_check">
|
||||
<UniqueIdentifier>{bdfbbba6-e274-4b3c-9f2e-0c2285fb3868}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="client_pipe">
|
||||
<UniqueIdentifier>{f1272f12-b056-43cc-840b-af2cacdf461e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="exprots_api_func.cpp">
|
||||
<Filter>exprots_api_func</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="client_driver.cpp">
|
||||
<Filter>Driver</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="client_comm_shared.cpp">
|
||||
<Filter>comm_shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utils.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="private_funcion.cpp">
|
||||
<Filter>private_funcion</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="client_palpit.cpp">
|
||||
<Filter>client_palpit</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="driver_func.cpp">
|
||||
<Filter>Driver</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="active_check.cpp">
|
||||
<Filter>active_check</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="client_pipe.cpp">
|
||||
<Filter>client_pipe</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Base.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="exprots_api_func.h">
|
||||
<Filter>exprots_api_func</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="client_driver.h">
|
||||
<Filter>Driver</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="client_comm_shared.h">
|
||||
<Filter>comm_shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="utils.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="private_funcion.h">
|
||||
<Filter>private_funcion</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="client_palpit.h">
|
||||
<Filter>client_palpit</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="driver_func.h">
|
||||
<Filter>Driver</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="active_check.h">
|
||||
<Filter>active_check</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="client_pipe.h">
|
||||
<Filter>client_pipe</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#ifndef BASE_H
|
||||
#define BASE_H
|
||||
#include <Windows.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <TlHelp32.h>
|
||||
#include <mutex>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#endif // !BASE_H
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "active_check.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace active_check
|
||||
{
|
||||
auto check_awesun_process() -> bool
|
||||
{
|
||||
auto dwPid = utils::GetProcessByName(L"AweSun.exe");
|
||||
|
||||
auto hwnd = FindWindow(L"FLUTTERVIEW", NULL);
|
||||
|
||||
if (dwPid || hwnd)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto check_todesk_process() -> bool
|
||||
{
|
||||
auto dwPid = utils::GetProcessByName(L"ToDesk.exe");
|
||||
|
||||
auto hwnd = FindWindow(NULL, L"ToDesk");
|
||||
|
||||
if (dwPid || hwnd)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto check_asklink_process() -> bool
|
||||
{
|
||||
auto dwPid = utils::GetProcessByName(L"AskLink.exe");
|
||||
|
||||
auto hwnd = FindWindow(NULL, L"AskLink");
|
||||
|
||||
if (dwPid || hwnd)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto check_uu_remote_process() -> bool
|
||||
{
|
||||
auto dwPid = utils::GetProcessByName(L"GameViewer.exe");
|
||||
|
||||
auto hwnd = FindWindow(NULL, L"ÍøÒ×UUÔ¶³Ì");
|
||||
|
||||
if (dwPid || hwnd)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto check_remote_app_process() -> bool
|
||||
{
|
||||
if (check_awesun_process() ||
|
||||
check_todesk_process() ||
|
||||
check_asklink_process() ||
|
||||
check_uu_remote_process())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "Base.h"
|
||||
|
||||
namespace active_check
|
||||
{
|
||||
//检测向日葵进程
|
||||
auto check_awesun_process() -> bool;
|
||||
|
||||
//检测Todesk进程
|
||||
auto check_todesk_process() -> bool;
|
||||
|
||||
//检测连连控进程
|
||||
auto check_asklink_process() -> bool;
|
||||
|
||||
//检测网易UU远程进程
|
||||
auto check_uu_remote_process() -> bool;
|
||||
|
||||
//检测远程软件进程
|
||||
auto check_remote_app_process() -> bool;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
#include "client_comm_shared.h"
|
||||
#include "private_funcion.h"
|
||||
#include "utils.h"
|
||||
#include "client_palpit.h"
|
||||
#include "driver_func.h"
|
||||
|
||||
HANDLE hMapHandle;
|
||||
PMAPPING_USER_MEMORY pMapping_Memory;
|
||||
|
||||
namespace client_shared_mapping
|
||||
{
|
||||
auto open_shared_mapping() -> HANDLE
|
||||
{
|
||||
//尝试打开管道建立通信
|
||||
//Anit-Server进程没有起来就就等死
|
||||
static int break_byte_count = 0;
|
||||
while (true)
|
||||
{
|
||||
if (break_byte_count > 10)
|
||||
break;
|
||||
|
||||
auto hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, SHARED_NAME);
|
||||
if (hMap)
|
||||
return hMap;
|
||||
|
||||
break_byte_count++;
|
||||
Sleep(1000);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auto mapping_shared_memory(HANDLE hMap) -> PMAPPING_USER_MEMORY
|
||||
{
|
||||
auto pData = (_MAPPING_USER_MEMORY*)MapViewOfFile(
|
||||
hMap,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0, 0,
|
||||
0
|
||||
);
|
||||
|
||||
return pData;
|
||||
}
|
||||
|
||||
auto StartServerProcess(CONST char* Path) -> BOOL
|
||||
{
|
||||
if (GetFileAttributesA(Path) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
char buf[256]{ 0 };
|
||||
sprintf_s(buf, "%s\\Anit-Seriver.exe", Path);
|
||||
|
||||
if (private_funcion::create_start_process(buf))
|
||||
{
|
||||
/*hMapHandle = client_shared_mapping::open_shared_mapping();
|
||||
if (hMapHandle)
|
||||
{
|
||||
pMapping_Memory = client_shared_mapping::mapping_shared_memory(hMapHandle);
|
||||
if (pMapping_Memory)
|
||||
{
|
||||
client_palpit::create_papit_thread(pMapping_Memory);
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto string = "[Anit-Cheat]系统运行发生致命错误,错误代码:" + to_string(GetLastError());
|
||||
MessageBoxA(NULL, string.c_str(), "您似乎遇到了一些问题", MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//auto anit_cheat_create_process() -> BOOL
|
||||
//{
|
||||
// BOOL bIsSrc;
|
||||
// CHAR* lastSlash;
|
||||
|
||||
// CONST char* path = "C:\\Program Files\\AnitCheatFile\\Anit-Seriver.exe";
|
||||
|
||||
// if (GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES)
|
||||
// {
|
||||
// DWORD size = 0;
|
||||
// auto filebuff = utils::ReadBinaryFile(path, &size);
|
||||
// if (!filebuff)
|
||||
// return FALSE;
|
||||
|
||||
// auto pNThander = reinterpret_cast<PIMAGE_NT_HEADERS>(filebuff + reinterpret_cast<PIMAGE_DOS_HEADER>(filebuff)->e_lfanew);
|
||||
// auto pFilehander = &pNThander->FileHeader;
|
||||
// if (!pFilehander->TimeDateStamp)
|
||||
// return FALSE;
|
||||
|
||||
// auto buff_doshander = reinterpret_cast<PIMAGE_DOS_HEADER>(Anit_Cheat_EXE);
|
||||
// auto buff_nthander = reinterpret_cast<PIMAGE_NT_HEADERS>((DWORD64)buff_doshander + buff_doshander->e_lfanew);
|
||||
// auto buff_FileHander = &buff_nthander->FileHeader;
|
||||
// if (!buff_FileHander->TimeDateStamp)
|
||||
// return FALSE;
|
||||
|
||||
// if (buff_FileHander->TimeDateStamp != pFilehander->TimeDateStamp)
|
||||
// goto create;
|
||||
|
||||
// goto run;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// create:
|
||||
// char dirPath[MAX_PATH];
|
||||
// strcpy_s(dirPath, path);
|
||||
|
||||
// lastSlash = strrchr(dirPath, '\\');
|
||||
// if (lastSlash) {
|
||||
// *lastSlash = '\0';
|
||||
|
||||
// // 2. 创建目录(如果不存在)
|
||||
// if (!utils::CreateDirectoryRecursive(dirPath)) {
|
||||
// return FALSE;
|
||||
// }
|
||||
// }
|
||||
|
||||
// bIsSrc = utils::WriteShellcodeToFile(path, Anit_Cheat_EXE, sizeof(Anit_Cheat_EXE));
|
||||
// if (bIsSrc)
|
||||
// {
|
||||
// run:
|
||||
// bIsSrc = private_funcion::create_start_process(path);
|
||||
// if (bIsSrc)
|
||||
// return TRUE;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return FALSE;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
#ifndef COMM_PIPE
|
||||
#define COMM_PIPE
|
||||
#include "Base.h"
|
||||
|
||||
#define SHARED_NAME "ServerMappingMmeory"
|
||||
|
||||
|
||||
typedef struct _MAPPING_USER_MEMORY
|
||||
{
|
||||
char str[256];
|
||||
|
||||
//驱动执行
|
||||
DWORD load_driver_code;
|
||||
//轮巡
|
||||
DWORD add_index_code;
|
||||
|
||||
DWORD server_pid;
|
||||
DWORD client_pid;
|
||||
|
||||
//轮巡返回数
|
||||
DWORD Index;
|
||||
|
||||
|
||||
//返回状态
|
||||
BOOL bIsSuc;
|
||||
}MAPPING_USER_MEMORY, * PMAPPING_USER_MEMORY;
|
||||
|
||||
|
||||
enum TYPE_COOM
|
||||
{
|
||||
BASE = 0x1000,
|
||||
KD_LOAD_DRIVER,
|
||||
ADD_INDEX_VAL,
|
||||
};
|
||||
|
||||
|
||||
namespace client_shared_mapping
|
||||
{
|
||||
//打开共享内存
|
||||
auto open_shared_mapping()->HANDLE;
|
||||
|
||||
//映射共享内存
|
||||
auto mapping_shared_memory(HANDLE hMap)->PMAPPING_USER_MEMORY;
|
||||
|
||||
//启动服务进程
|
||||
auto StartServerProcess(CONST char* Path)->BOOL;
|
||||
|
||||
//启动目标通信进程
|
||||
auto anit_cheat_create_process()->BOOL;
|
||||
|
||||
}
|
||||
|
||||
extern HANDLE hMapHandle;
|
||||
extern PMAPPING_USER_MEMORY pMapping_Memory;
|
||||
|
||||
#endif // !comm_pipe
|
||||
@@ -0,0 +1,141 @@
|
||||
#include "client_driver.h"
|
||||
#include "driver_func.h"
|
||||
#include "client_pipe.h"
|
||||
|
||||
|
||||
client_driver* client_driver::instance = nullptr;
|
||||
PMAPPING_USER_MEMORY client_driver::mapping_data = nullptr;
|
||||
|
||||
auto client_driver::fn_get_instance() -> client_driver*
|
||||
{
|
||||
if (instance == nullptr)
|
||||
{
|
||||
instance = new client_driver;
|
||||
}
|
||||
if (mapping_data == nullptr)
|
||||
{
|
||||
mapping_data = pMapping_Memory;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
auto client_driver::driver_map_load() -> BOOL
|
||||
{
|
||||
return HBClientLoadDriverW();
|
||||
}
|
||||
|
||||
auto client_driver::check_load_driver() -> BOOL
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
CMD_COMM data;
|
||||
data.CommID = DRIVER_COOM_TYPE::DRIVER_COMM_TEST;
|
||||
data.status = (DWORD64)&status;
|
||||
|
||||
driver_func::driver_comm_func(&data, sizeof(data));
|
||||
|
||||
return NT_SUCCESS(status);
|
||||
}
|
||||
|
||||
auto client_driver::add_process_protect(DWORD Pid) ->BOOL
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
CMD_COMM data;
|
||||
IOCTL_PROCESS process{ 0 };
|
||||
process.Pid = Pid;
|
||||
|
||||
data.CommID = DRIVER_COOM_TYPE::DRIVER_PROTECT_PROCESS;
|
||||
data.Buf = (DWORD64)&process;
|
||||
data.status = (DWORD64)&status;
|
||||
|
||||
driver_func::driver_comm_func(&data, sizeof(data));
|
||||
return NT_SUCCESS(status);
|
||||
}
|
||||
|
||||
auto client_driver::delete_process_protect(DWORD Pid)->BOOL
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
CMD_COMM data;
|
||||
IOCTL_PROCESS process{ 0 };
|
||||
process.Pid = Pid;
|
||||
|
||||
data.CommID = DRIVER_COOM_TYPE::DRIVER_CANCEL_PROTECT_PROCESS;
|
||||
data.Buf = (DWORD64)&process;
|
||||
data.status = (DWORD64)&status;
|
||||
|
||||
driver_func::driver_comm_func(&data, sizeof(data));
|
||||
return NT_SUCCESS(status);
|
||||
}
|
||||
|
||||
auto client_driver::window_anit_screen(HWND hwnd, UINT Flags) -> BOOL
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
CMD_COMM data;
|
||||
IOCTL_WINDOW window{ 0 };
|
||||
|
||||
window.HWND = (DWORD64)hwnd;
|
||||
window.Flags = Flags;
|
||||
|
||||
data.CommID = DRIVER_COOM_TYPE::WINDOW_ANIT_SCREEN;
|
||||
data.Buf = (DWORD64)&window;
|
||||
data.status = (DWORD64)&status;
|
||||
|
||||
driver_func::driver_comm_func(&data, sizeof(data));
|
||||
return status;
|
||||
}
|
||||
|
||||
auto client_driver::install_mouse_keyboard() -> BOOL
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
CMD_COMM data;
|
||||
data.CommID = DRIVER_COOM_TYPE::INSTALL_MOUSE_KEYBOARD;
|
||||
data.status = (DWORD64)&status;
|
||||
|
||||
driver_func::driver_comm_func(&data, sizeof(data));
|
||||
return status;
|
||||
}
|
||||
|
||||
auto client_driver::unload_mouse_keyboard()->BOOL
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
CMD_COMM data;
|
||||
data.CommID = DRIVER_COOM_TYPE::UNLOAD_MOUSE_KEYBOARD;
|
||||
data.status = (DWORD64)&status;
|
||||
driver_func::driver_comm_func(&data, sizeof(data));
|
||||
return status;
|
||||
}
|
||||
auto client_driver::add_white_mouse_keyoard_process(DWORD Pid) -> BOOL
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
IOCTL_PROCESS process{ 0 };
|
||||
process.Pid = Pid;
|
||||
|
||||
CMD_COMM data;
|
||||
data.CommID = DRIVER_COOM_TYPE::ADD_WHITE_PROCESS;
|
||||
data.Buf = (DWORD64)&process;
|
||||
data.status = (DWORD64)&status;
|
||||
|
||||
driver_func::driver_comm_func(&data, sizeof(data));
|
||||
return status;
|
||||
}
|
||||
|
||||
auto client_driver::enjoin_remote_thread(BOOL val) -> BOOL
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
IOCTL_PROCESS process{ 0 };
|
||||
process.is_no_create_remote_thread = val;
|
||||
|
||||
CMD_COMM data;
|
||||
data.CommID = DRIVER_COOM_TYPE::PROTECT_THREAD_CONTRL;
|
||||
data.Buf = (DWORD64)&process;
|
||||
data.status = (DWORD64)&status;
|
||||
|
||||
driver_func::driver_comm_func(&data, sizeof(data));
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#ifndef DRIVER_API_FUNC
|
||||
#define DRIVER_API_FUNC
|
||||
#include "Base.h"
|
||||
#include "client_comm_shared.h"
|
||||
|
||||
|
||||
class client_driver
|
||||
{
|
||||
public:
|
||||
static auto fn_get_instance()->client_driver*;
|
||||
|
||||
auto driver_map_load()->BOOL;
|
||||
|
||||
auto check_load_driver()->BOOL;
|
||||
|
||||
auto add_process_protect(DWORD Pid)->BOOL;
|
||||
|
||||
auto delete_process_protect(DWORD Pid)->BOOL;
|
||||
|
||||
auto window_anit_screen(HWND hwnd, UINT Flags)->BOOL;
|
||||
|
||||
auto install_mouse_keyboard()->BOOL;
|
||||
|
||||
auto unload_mouse_keyboard()->BOOL;
|
||||
|
||||
auto add_white_mouse_keyoard_process(DWORD Pid)->BOOL;
|
||||
|
||||
auto enjoin_remote_thread(BOOL val)->BOOL;
|
||||
|
||||
private:
|
||||
static client_driver* instance;
|
||||
|
||||
static PMAPPING_USER_MEMORY mapping_data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // !DRIVER_API_FUNC
|
||||
@@ -0,0 +1,87 @@
|
||||
#include "client_palpit.h"
|
||||
#include "client_comm_shared.h"
|
||||
|
||||
namespace client_palpit
|
||||
{
|
||||
DWORD WINAPI palpit_thread(LPVOID parmar)
|
||||
{
|
||||
static int break_count_fail = 0;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
auto mapping_data = reinterpret_cast<PMAPPING_USER_MEMORY>(parmar);
|
||||
|
||||
/*strcpy_s(mapping_data->str, "fail");
|
||||
mapping_data->add_index_code = TRUE;
|
||||
|
||||
auto val = 100;
|
||||
mapping_data->Index = val;
|
||||
|
||||
while (strcmp(mapping_data->str, "ok")) {
|
||||
|
||||
if (break_count_fail > 5) {
|
||||
MessageBoxA(NULL, "[client] 请求超时 错误代码:-502", NULL, NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
break_count_fail++;
|
||||
|
||||
Sleep(1000);
|
||||
|
||||
}
|
||||
|
||||
if ((val + 1) != mapping_data->Index)
|
||||
{
|
||||
MessageBoxA(NULL, "[client] 组件发生异常 错误代码:-501", NULL, NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
break_count_fail = 0;*/
|
||||
|
||||
//
|
||||
// 检测进程是否退出
|
||||
//
|
||||
if (!mapping_data->client_pid)
|
||||
mapping_data->client_pid = GetCurrentProcessId();
|
||||
|
||||
//static int fail_index = 0;
|
||||
//static HANDLE hProcess = 0;
|
||||
|
||||
//auto server_pid = mapping_data->server_pid;
|
||||
//if (hProcess == NULL)
|
||||
//{
|
||||
// if (fail_index > 3) {
|
||||
// exit(0);
|
||||
// }
|
||||
//
|
||||
|
||||
// hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, server_pid);
|
||||
// fail_index++;
|
||||
// continue;
|
||||
//}
|
||||
|
||||
////
|
||||
////监控客户端进程是否退出
|
||||
////
|
||||
//DWORD exitCode;
|
||||
//if (GetExitCodeProcess(hProcess, &exitCode)) {
|
||||
// if (exitCode != STILL_ACTIVE) {
|
||||
// exit(0);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
Sleep(1000);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
auto create_papit_thread(LPVOID parmar) -> void
|
||||
{
|
||||
CloseHandle(CreateThread(nullptr, 0, palpit_thread, parmar, 0, nullptr));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#ifndef CHLENT_PALPIT
|
||||
#define CHLENT_PALPIT
|
||||
#include "Base.h"
|
||||
|
||||
|
||||
namespace client_palpit
|
||||
{
|
||||
auto create_papit_thread(LPVOID parmar) -> void;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // !client_palpit
|
||||
@@ -0,0 +1,657 @@
|
||||
#include "client_pipe.h"
|
||||
|
||||
|
||||
static LONG g_started = 0;
|
||||
static HANDLE g_stop_event = nullptr;
|
||||
static HANDLE g_queue_event = nullptr;
|
||||
static HANDLE g_connected_event = nullptr;
|
||||
static HANDLE g_worker_thread = nullptr;
|
||||
static HANDLE g_pipe = INVALID_HANDLE_VALUE;
|
||||
static std::atomic<DWORD> g_client_id{ 0 };
|
||||
static std::atomic<uint64_t> g_session_id{ 0 };
|
||||
static std::atomic<uint64_t> g_next_request_id{ 1 };
|
||||
static std::mutex g_queue_mutex;
|
||||
static std::deque<std::shared_ptr<PendingCommand>> g_queue;
|
||||
|
||||
|
||||
static void LogA(const char* fmt, ...)
|
||||
{
|
||||
char buf[512]{};
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf_s(buf, sizeof(buf), _TRUNCATE, fmt, ap);
|
||||
va_end(ap);
|
||||
OutputDebugStringA(buf);
|
||||
}
|
||||
|
||||
static void ExitInjectedProcess(UINT exit_code)
|
||||
{
|
||||
LogA("[dll-client] ExitProcess code=%u\n", exit_code);
|
||||
ExitProcess(exit_code);
|
||||
}
|
||||
|
||||
static bool ReadExact(HANDLE pipe, void* buffer, DWORD size)
|
||||
{
|
||||
BYTE* ptr = static_cast<BYTE*>(buffer);
|
||||
DWORD total = 0;
|
||||
while (total < size)
|
||||
{
|
||||
DWORD got = 0;
|
||||
if (!ReadFile(pipe, ptr + total, size - total, &got, nullptr))
|
||||
return false;
|
||||
if (got == 0)
|
||||
return false;
|
||||
total += got;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool WriteExact(HANDLE pipe, const void* buffer, DWORD size)
|
||||
{
|
||||
const BYTE* ptr = static_cast<const BYTE*>(buffer);
|
||||
DWORD total = 0;
|
||||
while (total < size)
|
||||
{
|
||||
DWORD wrote = 0;
|
||||
if (!WriteFile(pipe, ptr + total, size - total, &wrote, nullptr))
|
||||
return false;
|
||||
if (wrote == 0)
|
||||
return false;
|
||||
total += wrote;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool WideToUtf8(const std::wstring& input, char* output, size_t output_size)
|
||||
{
|
||||
if (!output || output_size == 0)
|
||||
return false;
|
||||
|
||||
output[0] = '\0';
|
||||
if (input.empty())
|
||||
return true;
|
||||
|
||||
int written = WideCharToMultiByte(
|
||||
CP_UTF8,
|
||||
0,
|
||||
input.c_str(),
|
||||
static_cast<int>(input.size()),
|
||||
output,
|
||||
static_cast<int>(output_size - 1),
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
if (written <= 0)
|
||||
return false;
|
||||
|
||||
output[written] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
static void QueuePush(const std::shared_ptr<PendingCommand>& cmd)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_queue_mutex);
|
||||
g_queue.push_back(cmd);
|
||||
SetEvent(g_queue_event);
|
||||
}
|
||||
|
||||
static std::shared_ptr<PendingCommand> QueuePop()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_queue_mutex);
|
||||
if (g_queue.empty())
|
||||
{
|
||||
ResetEvent(g_queue_event);
|
||||
return {};
|
||||
}
|
||||
|
||||
auto cmd = g_queue.front();
|
||||
g_queue.pop_front();
|
||||
if (g_queue.empty())
|
||||
ResetEvent(g_queue_event);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
static void FailPendingCommands(DWORD status, const char* reply)
|
||||
{
|
||||
(void)reply;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
auto cmd = QueuePop();
|
||||
if (!cmd)
|
||||
break;
|
||||
|
||||
cmd->status = status;
|
||||
if (cmd->done_event)
|
||||
SetEvent(cmd->done_event);
|
||||
}
|
||||
}
|
||||
|
||||
static void RequestStopNoWait()
|
||||
{
|
||||
if (g_stop_event)
|
||||
SetEvent(g_stop_event);
|
||||
}
|
||||
|
||||
static void CleanupClientStateNoWait()
|
||||
{
|
||||
RequestStopNoWait();
|
||||
|
||||
if (g_worker_thread)
|
||||
{
|
||||
CloseHandle(g_worker_thread);
|
||||
g_worker_thread = nullptr;
|
||||
}
|
||||
|
||||
if (g_stop_event)
|
||||
{
|
||||
CloseHandle(g_stop_event);
|
||||
g_stop_event = nullptr;
|
||||
}
|
||||
|
||||
if (g_queue_event)
|
||||
{
|
||||
CloseHandle(g_queue_event);
|
||||
g_queue_event = nullptr;
|
||||
}
|
||||
|
||||
if (g_connected_event)
|
||||
{
|
||||
CloseHandle(g_connected_event);
|
||||
g_connected_event = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static bool ConnectToServer(HANDLE& pipe)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (WaitForSingleObject(g_stop_event, 0) == WAIT_OBJECT_0)
|
||||
return false;
|
||||
|
||||
pipe = CreateFileW(
|
||||
kPipeName,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
if (pipe != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD mode = PIPE_READMODE_MESSAGE;
|
||||
SetNamedPipeHandleState(pipe, &mode, nullptr, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD err = GetLastError();
|
||||
if (err == ERROR_PIPE_BUSY)
|
||||
{
|
||||
if (!WaitNamedPipeW(kPipeName, 1000))
|
||||
Sleep(250);
|
||||
continue;
|
||||
}
|
||||
|
||||
Sleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
static bool SendHello(HANDLE pipe)
|
||||
{
|
||||
Msg hello{};
|
||||
hello.type = static_cast<uint32_t>(MsgType::Hello);
|
||||
hello.pid = GetCurrentProcessId();
|
||||
hello.version = kProtocolVersion;
|
||||
hello.tick = static_cast<uint64_t>(NowMs());
|
||||
hello.session_id = 0;
|
||||
|
||||
if (!WriteExact(pipe, &hello, sizeof(hello)))
|
||||
{
|
||||
LogA("[dll-client] hello write failed: %lu\n", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
Msg ack{};
|
||||
if (!ReadExact(pipe, &ack, sizeof(ack)) || ack.type != static_cast<uint32_t>(MsgType::HelloAck))
|
||||
{
|
||||
LogA("[dll-client] hello ack failed: %lu\n", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
g_client_id.store(ack.client_id);
|
||||
g_session_id.store(ack.session_id);
|
||||
SetEvent(g_connected_event);
|
||||
|
||||
LogA("[dll-client] connected client_id=%lu session=%llu\n",
|
||||
g_client_id.load(),
|
||||
static_cast<unsigned long long>(g_session_id.load()));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SendHeartbeat(HANDLE pipe)
|
||||
{
|
||||
Msg heartbeat{};
|
||||
heartbeat.type = static_cast<uint32_t>(MsgType::Heartbeat);
|
||||
heartbeat.client_id = g_client_id.load();
|
||||
heartbeat.pid = GetCurrentProcessId();
|
||||
heartbeat.version = kProtocolVersion;
|
||||
heartbeat.session_id = g_session_id.load();
|
||||
heartbeat.tick = static_cast<uint64_t>(NowMs());
|
||||
|
||||
if (!WriteExact(pipe, &heartbeat, sizeof(heartbeat)))
|
||||
{
|
||||
LogA("[dll-client] heartbeat write failed: %lu\n", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool PumpServerMessages(HANDLE pipe)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
DWORD available = 0;
|
||||
if (!PeekNamedPipe(pipe, nullptr, 0, nullptr, &available, nullptr))
|
||||
{
|
||||
LogA("[dll-client] server disconnected: %lu\n", GetLastError());
|
||||
ExitInjectedProcess(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (available < sizeof(Msg))
|
||||
return true;
|
||||
|
||||
Msg msg{};
|
||||
if (!ReadExact(pipe, &msg, sizeof(msg)))
|
||||
return false;
|
||||
|
||||
if (msg.type == static_cast<uint32_t>(MsgType::Exit))
|
||||
{
|
||||
LogA("[dll-client] exit requested by server\n");
|
||||
SetEvent(g_stop_event);
|
||||
ExitInjectedProcess(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool SendCommand(HANDLE pipe, PendingCommand& cmd)
|
||||
{
|
||||
Msg req{};
|
||||
req.type = static_cast<uint32_t>(MsgType::CommandRequest);
|
||||
req.client_id = g_client_id.load();
|
||||
req.pid = GetCurrentProcessId();
|
||||
req.version = kProtocolVersion;
|
||||
req.command = cmd.command;
|
||||
req.status = 0;
|
||||
req.input_size = static_cast<uint32_t>(cmd.input.size());
|
||||
req.output_size = static_cast<uint32_t>(cmd.output.size());
|
||||
req.tick = static_cast<uint64_t>(NowMs());
|
||||
req.session_id = g_session_id.load();
|
||||
req.request_id = cmd.request_id;
|
||||
|
||||
if (cmd.input.size() > kPayloadBytes || cmd.output.size() > kPayloadBytes)
|
||||
return false;
|
||||
|
||||
if (!cmd.input.empty())
|
||||
memcpy(req.payload, cmd.input.data(), cmd.input.size());
|
||||
|
||||
if (!WriteExact(pipe, &req, sizeof(req)))
|
||||
return false;
|
||||
|
||||
Msg resp{};
|
||||
if (!ReadExact(pipe, &resp, sizeof(resp)))
|
||||
return false;
|
||||
|
||||
if (resp.type != static_cast<uint32_t>(MsgType::CommandReply))
|
||||
return false;
|
||||
|
||||
if (resp.request_id != cmd.request_id || resp.command != cmd.command)
|
||||
return false;
|
||||
|
||||
cmd.status = resp.status;
|
||||
if (resp.output_size && resp.output_size <= cmd.output.size())
|
||||
memcpy(cmd.output.data(), resp.payload, resp.output_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static DWORD WINAPI WorkerThreadProc(LPVOID)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (WaitForSingleObject(g_stop_event, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
HANDLE pipe = INVALID_HANDLE_VALUE;
|
||||
if (!ConnectToServer(pipe))
|
||||
break;
|
||||
|
||||
g_pipe = pipe;
|
||||
ResetEvent(g_connected_event);
|
||||
|
||||
if (!SendHello(pipe))
|
||||
{
|
||||
CloseHandle(pipe);
|
||||
g_pipe = INVALID_HANDLE_VALUE;
|
||||
Sleep(500);
|
||||
continue;
|
||||
}
|
||||
|
||||
DWORD last_heartbeat = static_cast<DWORD>(NowMs());
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (WaitForSingleObject(g_stop_event, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
if (WaitForSingleObject(g_queue_event, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
auto cmd = QueuePop();
|
||||
if (!cmd)
|
||||
break;
|
||||
|
||||
if (!SendCommand(pipe, *cmd))
|
||||
{
|
||||
cmd->status = GetLastError();
|
||||
}
|
||||
|
||||
if (cmd->done_event)
|
||||
SetEvent(cmd->done_event);
|
||||
|
||||
if (WaitForSingleObject(g_stop_event, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const DWORD now = static_cast<DWORD>(NowMs());
|
||||
if (now - last_heartbeat >= kHeartbeatIntervalMs)
|
||||
{
|
||||
if (!SendHeartbeat(pipe))
|
||||
{
|
||||
LogA("[dll-client] server heartbeat failed, exit process\n");
|
||||
ExitInjectedProcess(0);
|
||||
break;
|
||||
}
|
||||
|
||||
last_heartbeat = now;
|
||||
}
|
||||
|
||||
if (!PumpServerMessages(pipe))
|
||||
break;
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
ResetEvent(g_connected_event);
|
||||
|
||||
if (pipe != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(pipe);
|
||||
|
||||
g_pipe = INVALID_HANDLE_VALUE;
|
||||
|
||||
if (WaitForSingleObject(g_stop_event, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
Sleep(250);
|
||||
}
|
||||
|
||||
FailPendingCommands(ERROR_CANCELLED, "client stopped");
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL DllClientStart()
|
||||
{
|
||||
if (InterlockedCompareExchange(&g_started, 1, 0) != 0)
|
||||
return TRUE;
|
||||
|
||||
g_stop_event = CreateEventW(nullptr, TRUE, FALSE, nullptr);
|
||||
g_queue_event = CreateEventW(nullptr, TRUE, FALSE, nullptr);
|
||||
g_connected_event = CreateEventW(nullptr, TRUE, FALSE, nullptr);
|
||||
if (!g_stop_event || !g_queue_event || !g_connected_event)
|
||||
{
|
||||
CleanupClientStateNoWait();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_worker_thread = CreateThread(nullptr, 0, WorkerThreadProc, nullptr, 0, nullptr);
|
||||
if (!g_worker_thread)
|
||||
{
|
||||
CleanupClientStateNoWait();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL HBClientEnsureStarted()
|
||||
{
|
||||
return DllClientStart();
|
||||
}
|
||||
|
||||
BOOL HBClientCall(
|
||||
uint32_t command,
|
||||
const void* input,
|
||||
uint32_t input_size,
|
||||
void* output,
|
||||
uint32_t output_size,
|
||||
uint32_t* bytes_returned)
|
||||
{
|
||||
if (bytes_returned)
|
||||
*bytes_returned = 0;
|
||||
|
||||
if (input_size > kPayloadBytes || output_size > kPayloadBytes)
|
||||
return FALSE;
|
||||
|
||||
if (input_size && !input)
|
||||
return FALSE;
|
||||
|
||||
if (output_size && !output)
|
||||
return FALSE;
|
||||
|
||||
if (InterlockedCompareExchange(&g_started, 0, 0) == 0)
|
||||
{
|
||||
if (!DllClientStart())
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auto cmd = std::make_shared<PendingCommand>();
|
||||
cmd->command = command;
|
||||
cmd->request_id = g_next_request_id.fetch_add(1);
|
||||
cmd->done_event = CreateEventW(nullptr, TRUE, FALSE, nullptr);
|
||||
if (!cmd->done_event)
|
||||
return FALSE;
|
||||
|
||||
if (input_size)
|
||||
{
|
||||
const auto* ptr = static_cast<const uint8_t*>(input);
|
||||
cmd->input.assign(ptr, ptr + input_size);
|
||||
}
|
||||
|
||||
if (output_size)
|
||||
cmd->output.resize(output_size);
|
||||
|
||||
QueuePush(cmd);
|
||||
|
||||
HANDLE waits[2] = { cmd->done_event, g_stop_event };
|
||||
DWORD wait = WaitForMultipleObjects(2, waits, FALSE, 10000);
|
||||
BOOL ok = (wait == WAIT_OBJECT_0 && cmd->status == ERROR_SUCCESS);
|
||||
|
||||
if (ok && output && !cmd->output.empty())
|
||||
{
|
||||
memcpy(output, cmd->output.data(), cmd->output.size());
|
||||
if (bytes_returned)
|
||||
*bytes_returned = static_cast<uint32_t>(cmd->output.size());
|
||||
}
|
||||
|
||||
CloseHandle(cmd->done_event);
|
||||
return ok;
|
||||
}
|
||||
|
||||
BOOL HBClientSendPrintfW(const wchar_t* text)
|
||||
{
|
||||
return DllClientPrintfW(text);
|
||||
}
|
||||
|
||||
static bool PipeReadMsgTimeout(HANDLE pipe, Msg& msg, DWORD timeout_ms)
|
||||
{
|
||||
const DWORD begin = GetTickCount();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
DWORD available = 0;
|
||||
if (!PeekNamedPipe(pipe, nullptr, 0, nullptr, &available, nullptr))
|
||||
return false;
|
||||
|
||||
if (available >= sizeof(Msg))
|
||||
{
|
||||
DWORD got = 0;
|
||||
return ReadFile(pipe, &msg, sizeof(msg), &got, nullptr) && got == sizeof(msg);
|
||||
}
|
||||
|
||||
if (GetTickCount() - begin >= timeout_ms)
|
||||
return false;
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
static bool PipeWriteMsg(HANDLE pipe, const Msg& msg)
|
||||
{
|
||||
DWORD wrote = 0;
|
||||
return WriteFile(pipe, &msg, sizeof(msg), &wrote, nullptr) && wrote == sizeof(msg);
|
||||
}
|
||||
|
||||
BOOL QueryServerAlreadyOpen()
|
||||
{
|
||||
HANDLE pipe = CreateFileW(
|
||||
kPipeName,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
if (pipe == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
|
||||
DWORD mode = PIPE_READMODE_MESSAGE;
|
||||
SetNamedPipeHandleState(pipe, &mode, nullptr, nullptr);
|
||||
|
||||
Msg hello{};
|
||||
hello.type = static_cast<uint32_t>(MsgType::Hello);
|
||||
hello.pid = GetCurrentProcessId();
|
||||
hello.version = kProtocolVersion;
|
||||
hello.tick = static_cast<uint64_t>(NowMs());
|
||||
|
||||
Msg ack{};
|
||||
if (!PipeWriteMsg(pipe, hello) ||
|
||||
!PipeReadMsgTimeout(pipe, ack, 500) ||
|
||||
ack.type != static_cast<uint32_t>(MsgType::HelloAck))
|
||||
{
|
||||
CloseHandle(pipe);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Msg req{};
|
||||
req.type = static_cast<uint32_t>(MsgType::CommandRequest);
|
||||
req.client_id = ack.client_id;
|
||||
req.pid = GetCurrentProcessId();
|
||||
req.version = kProtocolVersion;
|
||||
req.command = static_cast<uint32_t>(CommandId::QueryStatus);
|
||||
req.session_id = ack.session_id;
|
||||
req.request_id = 1;
|
||||
req.tick = static_cast<uint64_t>(NowMs());
|
||||
|
||||
Msg resp{};
|
||||
BOOL already_open =
|
||||
PipeWriteMsg(pipe, req) &&
|
||||
PipeReadMsgTimeout(pipe, resp, 500) &&
|
||||
resp.type == static_cast<uint32_t>(MsgType::CommandReply) &&
|
||||
resp.command == static_cast<uint32_t>(CommandId::QueryStatus);
|
||||
|
||||
Msg bye{};
|
||||
bye.type = static_cast<uint32_t>(MsgType::Goodbye);
|
||||
bye.client_id = ack.client_id;
|
||||
bye.pid = GetCurrentProcessId();
|
||||
bye.version = kProtocolVersion;
|
||||
bye.session_id = ack.session_id;
|
||||
PipeWriteMsg(pipe, bye);
|
||||
|
||||
CloseHandle(pipe);
|
||||
return already_open;
|
||||
}
|
||||
|
||||
|
||||
BOOL HBClientLoadDriverW()
|
||||
{
|
||||
LoadDriverRequest req{};
|
||||
//wcsncpy_s(req.service_name, service_name, _TRUNCATE);
|
||||
//wcsncpy_s(req.driver_path, driver_path, _TRUNCATE);
|
||||
|
||||
return HBClientCall(
|
||||
static_cast<uint32_t>(CommandId::LoadDriver),
|
||||
&req,
|
||||
sizeof(req),
|
||||
nullptr,
|
||||
0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
BOOL HBClientUnloadDriverW(const wchar_t* service_name)
|
||||
{
|
||||
if (!service_name)
|
||||
return FALSE;
|
||||
|
||||
UnloadDriverRequest req{};
|
||||
wcsncpy_s(req.service_name, service_name, _TRUNCATE);
|
||||
|
||||
return HBClientCall(
|
||||
static_cast<uint32_t>(CommandId::UnloadDriver),
|
||||
&req,
|
||||
sizeof(req),
|
||||
nullptr,
|
||||
0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
BOOL HBClientNotifyBreakpointRemoved(uint32_t thread_id, uint64_t dr0, uint64_t dr7)
|
||||
{
|
||||
BreakpointRemovedRequest req{};
|
||||
req.thread_id = thread_id;
|
||||
req.dr0 = dr0;
|
||||
req.dr7 = dr7;
|
||||
|
||||
return HBClientCall(
|
||||
static_cast<uint32_t>(CommandId::BreakpointRemoved),
|
||||
&req,
|
||||
sizeof(req),
|
||||
nullptr,
|
||||
0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
BOOL DllClientPrintfW(const wchar_t* text)
|
||||
{
|
||||
if (!text)
|
||||
return FALSE;
|
||||
|
||||
PrintfRequest req{};
|
||||
if (!WideToUtf8(text, req.text, sizeof(req.text)))
|
||||
return FALSE;
|
||||
|
||||
return HBClientCall(
|
||||
static_cast<uint32_t>(CommandId::Printf),
|
||||
&req,
|
||||
sizeof(req),
|
||||
nullptr,
|
||||
0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
#include "Base.h"
|
||||
|
||||
static constexpr wchar_t kPipeName[] = L"\\\\.\\pipe\\HB_PIPE_DEMO";
|
||||
static constexpr DWORD kHeartbeatIntervalMs = 250;
|
||||
static constexpr DWORD kHeartbeatTimeoutMs = 2000;
|
||||
static constexpr uint32_t kProtocolVersion = 4;
|
||||
static constexpr size_t kPayloadBytes = 1024;
|
||||
|
||||
enum class MsgType : uint32_t
|
||||
{
|
||||
Hello = 1,
|
||||
HelloAck = 2,
|
||||
Heartbeat = 3,
|
||||
Exit = 4,
|
||||
Goodbye = 5,
|
||||
CommandRequest = 6,
|
||||
CommandReply = 7,
|
||||
};
|
||||
|
||||
enum class CommandId : uint32_t
|
||||
{
|
||||
None = 0,
|
||||
Printf = 1,
|
||||
LoadDriver = 2,
|
||||
UnloadDriver = 3,
|
||||
QueryStatus = 4,
|
||||
BreakpointRemoved = 5,
|
||||
};
|
||||
|
||||
#pragma pack(push, 8)
|
||||
struct Msg
|
||||
{
|
||||
uint32_t type;
|
||||
uint32_t client_id;
|
||||
uint32_t pid;
|
||||
uint32_t version;
|
||||
uint32_t command;
|
||||
uint32_t status;
|
||||
uint32_t input_size;
|
||||
uint32_t output_size;
|
||||
uint32_t reserved;
|
||||
uint64_t tick;
|
||||
uint64_t session_id;
|
||||
uint64_t request_id;
|
||||
uint8_t payload[kPayloadBytes];
|
||||
};
|
||||
|
||||
struct PrintfRequest
|
||||
{
|
||||
char text[512];
|
||||
};
|
||||
|
||||
struct LoadDriverRequest
|
||||
{
|
||||
wchar_t service_name[128];
|
||||
wchar_t driver_path[MAX_PATH];
|
||||
};
|
||||
|
||||
struct UnloadDriverRequest
|
||||
{
|
||||
wchar_t service_name[128];
|
||||
};
|
||||
|
||||
struct BreakpointRemovedRequest
|
||||
{
|
||||
uint32_t thread_id;
|
||||
uint32_t reserved;
|
||||
uint64_t dr0;
|
||||
uint64_t dr7;
|
||||
};
|
||||
struct QueryStatusReply
|
||||
{
|
||||
DWORD server_pid;
|
||||
DWORD already_open;
|
||||
char text[128];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
static_assert(sizeof(PrintfRequest) <= kPayloadBytes, "PrintfRequest too large");
|
||||
static_assert(sizeof(LoadDriverRequest) <= kPayloadBytes, "LoadDriverRequest too large");
|
||||
static_assert(sizeof(UnloadDriverRequest) <= kPayloadBytes, "UnloadDriverRequest too large");
|
||||
static_assert(sizeof(BreakpointRemovedRequest) <= kPayloadBytes, "BreakpointRemovedRequest too large");
|
||||
static_assert(sizeof(QueryStatusReply) <= kPayloadBytes, "QueryStatusReply too large");
|
||||
|
||||
inline LONG64 NowMs()
|
||||
{
|
||||
return static_cast<LONG64>(GetTickCount64());
|
||||
}
|
||||
|
||||
struct PendingCommand
|
||||
{
|
||||
uint32_t command = static_cast<uint32_t>(CommandId::None);
|
||||
DWORD status = ERROR_GEN_FAILURE;
|
||||
uint64_t request_id = 0;
|
||||
std::vector<uint8_t> input;
|
||||
std::vector<uint8_t> output;
|
||||
HANDLE done_event = nullptr;
|
||||
};
|
||||
|
||||
BOOL QueryServerAlreadyOpen(char* out_text, size_t out_text_size);
|
||||
|
||||
BOOL DllClientStart();
|
||||
|
||||
BOOL HBClientCall(
|
||||
uint32_t command,
|
||||
const void* input,
|
||||
uint32_t input_size,
|
||||
void* output,
|
||||
uint32_t output_size,
|
||||
uint32_t* bytes_returned);
|
||||
|
||||
bool WideToUtf8(const std::wstring& input, char* output, size_t output_size);
|
||||
|
||||
BOOL DllClientPrintfW(const wchar_t* text);
|
||||
|
||||
BOOL HBClientLoadDriverW();
|
||||
|
||||
BOOL QueryServerAlreadyOpen();
|
||||
@@ -0,0 +1,36 @@
|
||||
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
||||
#include "Base.h"
|
||||
#include "client_comm_shared.h"
|
||||
#include "driver_func.h"
|
||||
#include "client_pipe.h"
|
||||
|
||||
auto MainThread()->void
|
||||
{
|
||||
if (!driver_func::init())
|
||||
{
|
||||
auto string = "[Anit-Cheat]系统运行发生致命错误,错误代码:" + to_string(GetLastError());
|
||||
MessageBoxA(NULL, string.c_str(), "您似乎遇到了一些问题", MB_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
//AllocConsole();
|
||||
//freopen("CONOUT$", "w+", stdout);
|
||||
|
||||
DllClientStart();
|
||||
|
||||
MainThread();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#include "driver_func.h"
|
||||
|
||||
|
||||
typedef ULONG(WINAPI* NtConvertBetweenAuxiliaryCounterAndPerformanceCounterProc)(char a1, PVOID a2, PVOID a3, PVOID a4);
|
||||
NtConvertBetweenAuxiliaryCounterAndPerformanceCounterProc gNtConvertBetweenAuxiliary = NULL;
|
||||
|
||||
HANDLE null_device_handle;
|
||||
|
||||
OSVERSIONINFOW os{ 0 };
|
||||
|
||||
namespace driver_func
|
||||
{
|
||||
auto GetVersion() -> OSVERSIONINFOW
|
||||
{
|
||||
OSVERSIONINFOW os{ 0 };
|
||||
typedef NTSTATUS(WINAPI* PFNRtlGetVersion)(PRTL_OSVERSIONINFOW);
|
||||
static PFNRtlGetVersion RtlGetVersion = nullptr;
|
||||
if (RtlGetVersion == nullptr)
|
||||
{
|
||||
HMODULE hNtdll = GetModuleHandleW(L"ntdll.dll");
|
||||
if (hNtdll != NULL)
|
||||
{
|
||||
RtlGetVersion = (PFNRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion");
|
||||
}
|
||||
}
|
||||
|
||||
RtlGetVersion(&os);
|
||||
return os;
|
||||
}
|
||||
|
||||
auto init() -> BOOL
|
||||
{
|
||||
os = GetVersion();
|
||||
if (os.dwBuildNumber == 7600 || os.dwBuildNumber == 7601)
|
||||
{
|
||||
null_device_handle = CreateFileA("\\\\.\\Nul", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0);
|
||||
if (null_device_handle != NULL && null_device_handle != INVALID_HANDLE_VALUE)
|
||||
return TRUE;
|
||||
}
|
||||
else if (os.dwBuildNumber >= 14393)
|
||||
{
|
||||
HMODULE ntdll = GetModuleHandleA("ntdll.dll");
|
||||
if (ntdll)
|
||||
{
|
||||
if (gNtConvertBetweenAuxiliary == nullptr)
|
||||
{
|
||||
gNtConvertBetweenAuxiliary = (NtConvertBetweenAuxiliaryCounterAndPerformanceCounterProc)
|
||||
GetProcAddress(ntdll, "NtConvertBetweenAuxiliaryCounterAndPerformanceCounter");
|
||||
|
||||
return gNtConvertBetweenAuxiliary ? TRUE : FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auto driver_comm_func(LPVOID Buf, DWORD bufSize)->BOOL
|
||||
{
|
||||
if (os.dwBuildNumber == 7600 || os.dwBuildNumber == 7601)
|
||||
{
|
||||
DWORD retlen = 0;
|
||||
return DeviceIoControl(null_device_handle, 0x12345678, Buf, bufSize, Buf, bufSize, &retlen, NULL);
|
||||
}
|
||||
else if (os.dwBuildNumber >= 14393)
|
||||
{
|
||||
ULONG64 xxx = 0;
|
||||
auto data = (ULONG64)Buf;
|
||||
gNtConvertBetweenAuxiliary(1, &data, (PVOID)&xxx, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
#ifndef DRIVER_BULID_FUNC
|
||||
#define DRIVER_BULID_FUNC
|
||||
#include <Windows.h>
|
||||
|
||||
#define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L)
|
||||
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
|
||||
|
||||
struct CMD_COMM
|
||||
{
|
||||
DWORD64 CommID;
|
||||
DWORD64 Buf;
|
||||
DWORD64 status;
|
||||
};
|
||||
|
||||
struct IOCTL_PROCESS
|
||||
{
|
||||
DWORD64 Pid;
|
||||
BOOL is_no_create_remote_thread;
|
||||
};
|
||||
|
||||
struct IOCTL_WINDOW
|
||||
{
|
||||
DWORD64 HWND;
|
||||
DWORD64 Flags;
|
||||
};
|
||||
|
||||
enum DRIVER_COOM_TYPE
|
||||
{
|
||||
MSG_BASE = 0x10000,
|
||||
DRIVER_COMM_TEST,
|
||||
DRIVER_PROTECT_PROCESS,
|
||||
DRIVER_CANCEL_PROTECT_PROCESS,
|
||||
ADD_WHITE_PROCESS,
|
||||
WINDOW_ANIT_SCREEN,
|
||||
USER_EVENT_HANDLE,
|
||||
PROTECT_THREAD_CONTRL,
|
||||
INSTALL_MOUSE_KEYBOARD,
|
||||
UNLOAD_MOUSE_KEYBOARD,
|
||||
};
|
||||
|
||||
|
||||
namespace driver_func
|
||||
{
|
||||
auto init()->BOOL;
|
||||
|
||||
auto kdmaper_load_driver()->BOOL;
|
||||
|
||||
auto driver_comm_func(LPVOID Buf, DWORD bufSize)->BOOL;
|
||||
|
||||
}
|
||||
|
||||
#endif // !DRIVER_BULID_FUNC
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "exprots_api_func.h"
|
||||
#include "client_driver.h"
|
||||
#include "client_comm_shared.h"
|
||||
#include "active_check.h"
|
||||
#include "client_pipe.h"
|
||||
|
||||
MYAPI_API BOOL set_server_process_path(const char* Path)
|
||||
{
|
||||
return client_shared_mapping::StartServerProcess(Path);
|
||||
}
|
||||
|
||||
MYAPI_API BOOL check_server_process()
|
||||
{
|
||||
return QueryServerAlreadyOpen();
|
||||
}
|
||||
|
||||
MYAPI_API BOOL driver_install_load()
|
||||
{
|
||||
return client_driver::fn_get_instance()->driver_map_load();
|
||||
}
|
||||
|
||||
MYAPI_API BOOL check_install_status()
|
||||
{
|
||||
return client_driver::fn_get_instance()->check_load_driver();
|
||||
}
|
||||
|
||||
MYAPI_API BOOL add_process_protect(DWORD Pid)
|
||||
{
|
||||
return client_driver::fn_get_instance()->add_process_protect(Pid);
|
||||
}
|
||||
|
||||
MYAPI_API BOOL sub_process_protect(DWORD Pid)
|
||||
{
|
||||
return client_driver::fn_get_instance()->delete_process_protect(Pid);
|
||||
}
|
||||
|
||||
MYAPI_API BOOL enjoin_remote_thread(BOOL val)
|
||||
{
|
||||
return client_driver::fn_get_instance()->enjoin_remote_thread(val);
|
||||
}
|
||||
|
||||
MYAPI_API BOOL enable_reg_mouse_key()
|
||||
{
|
||||
return client_driver::fn_get_instance()->install_mouse_keyboard();
|
||||
}
|
||||
|
||||
MYAPI_API BOOL disable_reg_mouse_key()
|
||||
{
|
||||
return client_driver::fn_get_instance()->unload_mouse_keyboard();
|
||||
}
|
||||
|
||||
MYAPI_API BOOL add_mouse_key_white_process(DWORD Pid)
|
||||
{
|
||||
return client_driver::fn_get_instance()->add_white_mouse_keyoard_process(Pid);
|
||||
}
|
||||
|
||||
MYAPI_API BOOL anit_window_scrren(HWND hwnd,UINT Flags)
|
||||
{
|
||||
return client_driver::fn_get_instance()->window_anit_screen(hwnd, Flags);
|
||||
}
|
||||
|
||||
MYAPI_API BOOL check_remote_app_process()
|
||||
{
|
||||
return active_check::check_remote_app_process();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
|
||||
#ifndef EXPROTS_API_FUNC
|
||||
#define EXPROTS_API_FUNC
|
||||
|
||||
#ifdef EXPROTS_API_FUNC
|
||||
#define MYAPI_API __declspec(dllexport)
|
||||
#else
|
||||
#define MYAPI_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
//设置服务进程目录
|
||||
EXTERN_C MYAPI_API BOOL set_server_process_path(CONST char* Path);
|
||||
|
||||
//服务进程是否已加载
|
||||
EXTERN_C MYAPI_API BOOL check_server_process();
|
||||
|
||||
//驱动安装
|
||||
EXTERN_C MYAPI_API BOOL driver_install_load();
|
||||
|
||||
//驱动是否安装成功
|
||||
EXTERN_C MYAPI_API BOOL check_install_status();
|
||||
|
||||
//添加进程防护
|
||||
EXTERN_C MYAPI_API BOOL add_process_protect(DWORD Pid);
|
||||
|
||||
//移除进程防护
|
||||
EXTERN_C MYAPI_API BOOL sub_process_protect(DWORD Pid);
|
||||
|
||||
//是否启用禁止远程线程
|
||||
EXTERN_C MYAPI_API BOOL enjoin_remote_thread(BOOL val);
|
||||
|
||||
//启用键鼠保护回调
|
||||
EXTERN_C MYAPI_API BOOL enable_reg_mouse_key();
|
||||
|
||||
//禁用键鼠保护回调
|
||||
EXTERN_C MYAPI_API BOOL disable_reg_mouse_key();
|
||||
|
||||
//添加键鼠移动白名单进程
|
||||
EXTERN_C MYAPI_API BOOL add_mouse_key_white_process(DWORD Pid);
|
||||
|
||||
//设置窗口反截图
|
||||
EXTERN_C MYAPI_API BOOL anit_window_scrren(HWND hwnd, UINT Flags);
|
||||
|
||||
//检测远程软件进程
|
||||
EXTERN_C MYAPI_API BOOL check_remote_app_process();
|
||||
|
||||
#endif // !exprots_api_func
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "private_funcion.h"
|
||||
|
||||
namespace private_funcion
|
||||
{
|
||||
auto create_start_process(LPCSTR path) -> BOOL
|
||||
{
|
||||
STARTUPINFOA si = { sizeof(si) };
|
||||
PROCESS_INFORMATION pi;
|
||||
auto bOk = CreateProcessA(
|
||||
path,
|
||||
NULL, NULL, NULL, FALSE,
|
||||
CREATE_NEW_CONSOLE,
|
||||
NULL, NULL,
|
||||
&si, &pi
|
||||
);
|
||||
if (bOk)
|
||||
{
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#ifndef PRIVATE_FUNCTION
|
||||
#define PRIVATE_FUNCTION
|
||||
#include "Base.h"
|
||||
|
||||
namespace private_funcion
|
||||
{
|
||||
auto create_start_process(LPCSTR path)->BOOL;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // !PRIVATE_FUNCTION
|
||||
@@ -0,0 +1,151 @@
|
||||
#include "utils.h"
|
||||
|
||||
namespace utils
|
||||
{
|
||||
// 读取二进制文件到内存
|
||||
BYTE* ReadBinaryFile(const char* filePath, DWORD* outSize) {
|
||||
HANDLE hFile = CreateFileA(
|
||||
filePath,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
printf("打开文件失败: %s\n", filePath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD fileSize = GetFileSize(hFile, NULL);
|
||||
if (fileSize == INVALID_FILE_SIZE) {
|
||||
printf("获取文件大小失败\n");
|
||||
CloseHandle(hFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BYTE* buffer = (BYTE*)malloc(fileSize);
|
||||
if (!buffer) {
|
||||
printf("内存分配失败\n");
|
||||
CloseHandle(hFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD bytesRead = 0;
|
||||
BOOL result = ReadFile(hFile, buffer, fileSize, &bytesRead, NULL);
|
||||
CloseHandle(hFile);
|
||||
|
||||
if (!result || bytesRead != fileSize) {
|
||||
printf("读取文件失败\n");
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*outSize = bytesRead;
|
||||
return buffer;
|
||||
}
|
||||
BOOL WriteShellcodeToFile(const char* filePath, const BYTE* shellcode, SIZE_T shellcodeSize) {
|
||||
// 1. 创建文件
|
||||
HANDLE hFile = CreateFileA(
|
||||
filePath,
|
||||
GENERIC_WRITE,
|
||||
0, // 独占访问
|
||||
NULL,
|
||||
CREATE_ALWAYS, // 总是创建新文件
|
||||
FILE_ATTRIBUTE_NORMAL, // 普通文件
|
||||
NULL
|
||||
);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
//printf("CreateFile 失败: %d\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 2. 写入 shellcode
|
||||
DWORD bytesWritten = 0;
|
||||
BOOL result = WriteFile(hFile, shellcode, (DWORD)shellcodeSize, &bytesWritten, NULL);
|
||||
|
||||
if (!result || bytesWritten != shellcodeSize) {
|
||||
//printf("WriteFile 失败: %d\n", GetLastError());
|
||||
CloseHandle(hFile);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 3. 刷新缓冲区并关闭
|
||||
FlushFileBuffers(hFile);
|
||||
CloseHandle(hFile);
|
||||
|
||||
//printf("Shellcode 写入成功: %s (大小: %d 字节)\n", filePath, bytesWritten);
|
||||
return TRUE;
|
||||
}
|
||||
// 创建多级目录(递归创建)
|
||||
BOOL CreateDirectoryRecursive(const char* path) {
|
||||
char tempPath[MAX_PATH];
|
||||
strcpy_s(tempPath, path);
|
||||
|
||||
// 去掉末尾的反斜杠
|
||||
size_t len = strlen(tempPath);
|
||||
if (len > 0 && tempPath[len - 1] == '\\') {
|
||||
tempPath[len - 1] = '\0';
|
||||
}
|
||||
|
||||
// 检查目录是否已存在
|
||||
DWORD attrs = GetFileAttributesA(tempPath);
|
||||
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
return TRUE; // 目录已存在
|
||||
}
|
||||
|
||||
// 递归创建父目录
|
||||
char* lastSlash = strrchr(tempPath, '\\');
|
||||
if (lastSlash) {
|
||||
*lastSlash = '\0';
|
||||
if (!CreateDirectoryRecursive(tempPath)) {
|
||||
return FALSE;
|
||||
}
|
||||
*lastSlash = '\\';
|
||||
}
|
||||
|
||||
// 创建当前目录
|
||||
if (!CreateDirectoryA(tempPath, NULL)) {
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||
return TRUE;
|
||||
}
|
||||
//printf("创建目录失败: %s (错误: %d)\n", tempPath, GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//printf("创建目录成功: %s\n", tempPath);
|
||||
return TRUE;
|
||||
}
|
||||
auto GetProcessByName(CONST wchar_t* Name) -> DWORD
|
||||
{
|
||||
DWORD Pid = 0;
|
||||
|
||||
auto SnapshotHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (SnapshotHandle == INVALID_HANDLE_VALUE)
|
||||
return Pid;
|
||||
|
||||
PROCESSENTRY32 pe32{ 0 };
|
||||
pe32.dwSize = sizeof(pe32);
|
||||
|
||||
if (Process32First(SnapshotHandle, &pe32))
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!wcscmp(pe32.szExeFile, Name))
|
||||
{
|
||||
Pid = pe32.th32ProcessID;
|
||||
break;
|
||||
}
|
||||
|
||||
} while (Process32Next(SnapshotHandle, &pe32));
|
||||
}
|
||||
|
||||
CloseHandle(SnapshotHandle);
|
||||
|
||||
return Pid;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
#include "Base.h"
|
||||
|
||||
namespace utils
|
||||
{
|
||||
BYTE* ReadBinaryFile(const char* filePath, DWORD* outSize);
|
||||
|
||||
BOOL WriteShellcodeToFile(const char* filePath, const BYTE* shellcode, SIZE_T shellcodeSize);
|
||||
BOOL CreateDirectoryRecursive(const char* path);
|
||||
|
||||
auto GetProcessByName(CONST wchar_t* Name)->DWORD;
|
||||
}
|
||||
|
||||
#endif // !UTILS_h
|
||||
Reference in New Issue
Block a user