当前位置:网站首页>Easyanticheat uses to inject unsigned code into a protected process (2)
Easyanticheat uses to inject unsigned code into a protected process (2)
2022-06-24 04:11:00 【franket】
If you can't tell from the code , This is just a standard manual mapper . It tries to hide by allocating additional memory around its memory , Hopefully the reverser won't see that this is actually dynamic code ! You should also pay attention to , As long as one part contains the original data , We can map its content into the game . This means that an attacker can intentionally attach an extra part ( Or maybe hijack an existing part ) also EasyAntiCheat.sys Carelessly mapping this code without any form of validation .
Code execution
Getting code execution is very simple .EAC Use APC Delivery is performed in user mode shellcode, The shellcode Mapped by :
PVOID MapShellcode(ModuleMapInstance* Instance)
{
SIZE_T ShellcodeSize = PAGE_SIZE; // 0x1000
PVOID ShellcodeBase = nullptr;
BOOLEAN VirtualApiResult =
NT_SUCCESS( NtAllocateVirtualMemory( NtCurrentProcess(), &ShellcodeBase, 0, &ShellcodeSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );
if ( !VirtualApiResult || !ShellcodeBase )
return nullptr;
if ( Instance->ImageType == ImageType::Image64 )
{
UINT8 ShellcodeBuffer[] =
{
0x48, 0x83, 0xEC, 0x28, // SUB RSP, 0x28
0x4D, 0x31, 0xC0, // XOR R8, R8
0x48, 0x31, 0xD2, // XOR RDX, RDX
0x48, 0xFF, 0xC2, // INC RDX
0x48, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // MOV RAX, 0
0xFF, 0xD0, // CALL RAX
0x48, 0x83, 0xC4, 0x28, // ADD RSP, 0x28
0xC3 // RETN
};
memcpy( &ShellcodeBuffer[15], Instance->DllEntryPoint, sizeof( Instance->DllEntryPoint ) );
memcpy( ShellcodeBase, ShellcodeBuffer, sizeof( ShellcodeBuffer ) );
}
else
{
UINT8 ShellcodeBuffer[] =
{
0x6A, 0x00, // PUSH 0
0x6A, 0x01, // PUSH 1
0xFF, 0x74, 0xE4, 0x0C, // PUSH [RSP+0xC]
0xB8, 0x00, 0x00, 0x00, 0x00, // MOV EAX, 0
0xFF, 0xD0, // CALL EAX
0xC2, 0x04, 0x00 // RETN 4
};
memcpy( &ShellcodeBuffer[9], Instance->DllEntryPoint, sizeof( Instance->DllEntryPoint ) / 2 );
memcpy( ShellcodeBase, ShellcodeBuffer, sizeof( ShellcodeBuffer ) );
}
return ShellcodeBase;
} Once this module is EP Be performed , Its head will be erased , This ensures that reverse engineers cannot access it . contrary ,EasyAntiCheat.dll Meeting HANDLE In this unused space EasyAntiCheat.sys Driver and other specific data . This manual mapper has more functions , For example, the parsing module IAT. Since this information is not a prerequisite for understanding this section , We can skip the introductory content .
A quick look at EasyAntiCheat.dll
Before we start exploiting vulnerabilities , Let's take a look at the actual EasyAntiCheat.dll modular , Look at the impact of hijacking this payload . as everyone knows , Manual mapping is a popular code injection mechanism shared by cheating developers . To make sure EasyAntiCheat Detection data will not be collected from legitimate memory areas , It builds the internal white list system of the system module , And manually mapped image ranges . We can see an example of how to use it in the following function :
BOOLEAN IsInValidMemory( EACGlobal* GlobalContext, ULONG64 VirtualAddress )
{
if ( !VirtualAddress )
return FALSE;
ModuleListEntry* ModuleList = &GlobalContext->ModuleList;
RtlEnterCriticalSection( ModuleList ); // Wait until the list is available....
ModuleListEntry* CurrentEntry = ModuleList->Flink;
for ( i = ModuleList->Flink; CurrentEntry != i; CurrentEntry = CurrentEntry->Flink; )
{
if ( CurrentEntry->Unk0 && CurrentEntry->Unk1 &&
VirtualAddress >= CurrentEntry->ImageBase && VirtualAddress < CurrentEntry->ImageBase + CurrentEntry->SizeOfImage )
{
break;
}
}
RtlLeaveCriticalSection(ModuleList);
InternalModuleBase = GlobalContext->MappedImageBase;
// If it landed inside a legit module or within EasyAntiCheat.dll, return TRUE.
if ( i != ModuleList || VirtualAddress >= StartAddress && VirtualAddress < GlobalContext->MappedImageSize + StartAddress )
return TRUE;
// Other regions like dynamically allocated shellcode below....
return FALSE;
}This function is in EasyAntiCheat.dll Regular execution of , To determine whether the address exists in legal memory . As you know , If the address is in the internal module , Then return to TRUE.EAC Many things that protect games from ( Illegal thread creation 、 Inline hook, etc ) Can be passed in EasyAntiCheat.dll Map your image in to avoid . deadly , Right ?
Be careful :EAC This function is not always used , And performs inline checks quite frequently to detect whether the address exists in its memory .
Development
Now we know how the image is mapped to the process , We can develop our own payloads to hijack user mode execution , Attach our image to EAC In the existing image of . The layout of this exploit is as follows :
In more detail , You need to put a DLL Injection into eac_launcher.exe in , To do the following :
SetupEasyAntiCheatModuleRecursively scan the function for patterns .- Once we find a hit , Hook the function and pull the existing image .
- Use Decrypt the image
DecryptModule, Then modify the existing part to map the new code . - Change some properties to include
PAGE_EXECUTE_READWRITEattribute . - to update ImageSize Parameters ( and
IMAGE_OPTIONAL_HEADERThe structure of the SizeOfImage ) And callEncryptModuleRepackage the module . - Repair the original DllEntryPoint With
REL32 JMPTo your DllEntryPoint perform a . - Once we call EP, Recover these patches and call EasyAntiCheat.dll Entrance point .
- complete !
To avoid handling x86 Calling convention , I decided it was best to put one int3 Instruction to cause an interrupt after the function is executed . And then I use VEH( Vector exception handler ) To execute our hook procedure , Last , Restore the original operation code with the modified parameters .
We should also pay attention to , You must put the PE Header information is attached to EasyAntiCheat.dll In the head of . This is because information such as relocating and importing data will not be parsed , So another form of solution is needed to load your module correctly or to anticipate a crash . For the sake of simplicity , I avoided completely solving these problems . If you like , You can map your PE Header and read it out and resolve all problems within your entry point .
You should also know EasyAntiCheat.dll stay EasyAntiCheat.sys Run integrity check in ; So don't try to fix non writable parts without bypassing them ! PS: This also means that you can deliberately create multiple parts in a binary file , And force the driver to protect specific parts of the code for you .
demonstration
The following video demonstrates the practical application of this technology ,DbgView.exe adopt OutputDebugStringA Call inside the game to display the internal log .
Conclusion
EasyAntiCheat.sys Inadvertently created an ideal condition for code execution in the game , It allows you to dynamically run in-process code from user mode , And allows you to hook and execute any code , And will not conflict with anti cheating . You can even associate this project with enabling secure boot + HVCI( Manage program code integrity ) Machine pairing for . Further application , You can turn this project into a local process injection vulnerability , Used by BattlEye And other alternative solutions to protect the game . Of course , There are ways to completely detect and prevent this condition .
For clarity , stay EasyAntiCheat Some ways to prevent such exploits in the game include :
- Change the user mode dll Embed the driver and inject it directly into the game ...... I don't know why it hasn't been finished yet ?
- Yes EasyAntiCheat.dll The module is signed and verified EasyAntiCheat.sys Signature in
- Check the section title to ensure that each section has the correct number of permissions
- Protection after service operation eac_launcher.exe To prevent placing hooks .
- monitor DLL And analyze it , To ensure that it detects some outliers that are hijacking this module .
without doubt ,EasyAntiCheat Can achieve more ( If they haven't ) To prevent this type of attack . Even though EasyAntiCheat In recent years, we have done a good job in catching up with kernel vulnerabilities and even the recent hypervisor technology , But it's also a good idea to review old design models and make sure they work as expected without any warning .
边栏推荐
- Diskpart San policy is not onlineall, which affects automatic disk hanging
- Kubernetes 资源拓扑感知调度优化
- 英特尔 XTU 官方超频工具已支持 Win11 22H2 和 13 代酷睿 Raptor Lake 处理器
- Jointly build Euler community and share Euler ecology | join hands with Kirin software to create a digital intelligence future
- How to be a web server and what are the advantages of a web server
- High availability architecture design to deal with network failure of operators
- mysql - sql执行过程
- How to spell the iframe address of the video channel in easycvr?
- Application practice | Apache Doris integrates iceberg + Flink CDC to build a real-time federated query and analysis architecture integrating lake and warehouse
- What is FTP? What is the FTP address of the ECS?
猜你喜欢

openGauss 3.0版本源码编译安装指南

Black hat SEO actual combat search engine snapshot hijacking

Clickhouse (02) Clickhouse architecture design introduction overview and Clickhouse data slicing design
![[Numpy] Numpy对于NaN值的判断](/img/aa/dc75a86bbb9f5a235b1baf5f3495ff.png)
[Numpy] Numpy对于NaN值的判断

The results of the 2022 open source summer were announced, and 449 college students will contribute to open source projects

Pine Script脚本常用内容

博士申请 | 香港科技大学(广州)刘浩老师招收数据挖掘方向全奖博士/硕士

微博国际版更名为微博轻享版

15+城市道路要素分割应用,用这一个分割模型就够了

web技术分享| 【地图】实现自定义的轨迹回放
随机推荐
Browser rendering mechanism
Tencent ECS installs the Minio object storage tool
Exploration of web application component automatic discovery
Cloud development CMS Enterprise Edition demand survey
由浅入深的混合精度训练教程
C language in DSP (2) -- definition of structure
Pine Script脚本常用内容
What is FTP? What is the FTP address of the ECS?
Demonstration of the processing of divisor 0 in SQL
From virtual to real, digital technology makes rural funds "live"
What should I pay attention to when choosing a data center?
Analysis of grafana SSO authentication process based on keyloak
我与物联有个约定
脚本之美│VBS 入门交互实战
LeetCode 1281. Difference of sum of bit product of integer
Student information management system user manual
In the post epidemic era, "cloud live broadcast" saves "cloud cultural tourism"?
Easyplayer consumes traffic but does not play video and reports an error libdecoder Wasm404 troubleshooting
API real-time signature scheme based on Yapi
Why is on-line monitoring of equipment more and more valued by people?