当前位置:网站首页>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 .
边栏推荐
- 脚本之美│VBS 入门交互实战
- [new light weight first purchase special] 1-core 2g5m light weight application server costs 50 yuan in the first year. It is cost-effective and helps you get on the cloud easily!
- Configuration process of easygbs access to law enforcement recorder
- Two edges are applied by default, one of which is a solid color icon. How to delete that solid color icon?
- 黑帽SEO实战搜索引擎快照劫持
- The first 2021 Western cloud security summit is coming! See you in Xi'an on September 26!
- API real-time signature scheme based on Yapi
- Maintain the visibility of data automation: logging, auditing and error handling of the bridge of knowledge and action
- Live broadcast Reservation: Micro build practice - quickly build a catering reservation applet
- How to monitor multiple platforms simultaneously when easydss/easygbs platform runs real-time monitoring?
猜你喜欢

多任务视频推荐方案,百度工程师实战经验分享
![Web technology sharing | [map] to realize customized track playback](/img/b2/25677ca08d1fb83290dd825a242f06.png)
Web technology sharing | [map] to realize customized track playback

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

Brief ideas and simple cases of JVM tuning - how to tune

Jointly build Euler community and share Euler ecology | join hands with Kirin software to create a digital intelligence future

What is etcd and its application scenarios

开源之夏2022中选结果公示,449名高校生将投入开源项目贡献

Black hat SEO actual combat search engine snapshot hijacking

openEuler社区理事长江大勇:共推欧拉开源新模式 共建开源新体系

Multi task video recommendation scheme, baidu engineers' actual combat experience sharing
随机推荐
Discussion on the introduction principle and practice of fuzzy testing
Easyplayer consumes traffic but does not play video and reports an error libdecoder Wasm404 troubleshooting
博士申请 | 香港科技大学(广州)刘浩老师招收数据挖掘方向全奖博士/硕士
Protect your system with fail2ban and firewalld blacklists
Clickhouse (02) Clickhouse architecture design introduction overview and Clickhouse data slicing design
C language linked list points to the next structure pointer, structure and its many small details
Brief ideas and simple cases of JVM tuning - how to tune
讲讲我的不丰富的远程办公经验和推荐一些办公利器 | 社区征文
How to spell the iframe address of the video channel in easycvr?
Backup method of mysqldump
Received status code 502 from server: Bad Gateway
Two edges are applied by default, one of which is a solid color icon. How to delete that solid color icon?
What should I pay attention to when choosing a data center?
黑帽SEO实战搜索引擎快照劫持
近两周ACM之DP总结
Difference and efficiency between get winevent and get eventlog
Application practice | Apache Doris integrates iceberg + Flink CDC to build a real-time federated query and analysis architecture integrating lake and warehouse
华为云GaussDB(for Redis)揭秘第19期:GaussDB(for Redis)全面对比Codis
openGauss 3.0版本源码编译安装指南
Mac CentOS installation phpredis