• Stars
    star
    156
  • Rank 239,589 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bypass for CS:GO's LoadLibrary injection prevention mechanism, achieved by patching one byte of game memory.

OneByteLdr

Bypass for CS:GO's LoadLibrary injection prevention mechanism, achieved by patching one byte of game memory.

How it works

The game hooks NtOpenFile function from ntdll.dll. The disassembly of the replacement function is listed below:

push    ebp
mov     ebp, esp
push    esi
mov     esi, [ebp+arg_8]
mov     eax, [esi+8]
mov     eax, [eax+4]
test    eax, eax ; is ObjectAttributes->ObjectName->Buffer not null
jz      short loc_4095BB ; we patch this with 'jmp' to skip loc_4095A1

loc_4095A1:

test    byte ptr [ebp+arg_4], 20h ; check if DesiredAccess has FILE_EXECUTE flag set (whether we're loading a dll)
jz      short loc_4095BB ; if it's not a dll, call original
push    eax ; ObjectAttributes->ObjectName->Buffer
call    sub_40D460 ; verify the dll
test    al, al ; check if dll is allowed to load
jnz     short loc_4095BB ; if the dll passed verification call original
mov     eax, 0C0000034h ; return STATUS_OBJECT_NAME_NOT_FOUND
pop     esi
pop     ebp
retn    18h

loc_4095BB:

push    [ebp+arg_14]
push    [ebp+arg_10]
push    [ebp+arg_C]
push    esi
push    [ebp+arg_4]
push    [ebp+arg_0]
call    originalNtOpenFile
pop     esi
pop     ebp
retn    18h

Alternative approach

An alternative approach which also bypasses anti-loadlibrary protection is to restore 5 first bytes of original NtOpenFile. Below is an example of that coded in C:

// Restore original NtOpenFile from external process
LPVOID ntOpenFile = GetProcAddress(LoadLibraryW(L"ntdll"), "NtOpenFile");
if (ntOpenFile) {
    char originalBytes[5];
    memcpy(originalBytes, ntOpenFile, 5);
    WriteProcessMemory(csgoProcessHandle, ntOpenFile, originalBytes, 5, NULL);
}

For increased safety you can backup the patched first five bytes of NtOpenFile and restore them after injection.

Thread creation detection

Many Manual Mapping dll injectors create thread in target process to load dll or perform initialization. This is what CS:GO devs target in addition to LoadLibrary detection. Thread detection doesn't affect LoadLibrary injectors.

DllMain function of client.dll contains code that on DLL_THREAD_ATTACH calls NtQueryInformationThread function from ntdll.dll to get start address of newly created thread:

push    ebp
mov     ebp, esp
mov     eax, [ebp+fdwReason]
sub     esp, 20h
cmp     eax, 1
jz      loc_106390D3 ; if fdwReason is DLL_PROCESS_ATTACH, skip
test    eax, eax
jz      loc_106390D3 ; if fdwReason is DLL_PROCESS_DETACH, skip
cmp     eax, 2
jnz     loc_106390D3 ; if fdwReason is not DLL_THREAD_ATTACH, skip
push    esi
push    edi
mov     [ebp+phModule], 0
call    ds:GetCurrentThreadId
push    offset aNtqueryinforma ; "NtQueryInformationThread"
push    offset aNtdllDll ; "ntdll.dll"
mov     edi, eax
call    ds:GetModuleHandleA
push    eax
call    ds:GetProcAddress
mov     esi, eax
test    esi, esi
jz      short loc_106390C6 ; we patch this with 'jmp' to skip loc_106390B2
push    0
push    4
lea     eax, [ebp+fdwReason]
push    eax
push    9 ; ThreadQuerySetWin32StartAddress
call    ds:GetCurrentThread
push    eax
call    esi ; get thread start address from NtQueryInformationThread
test    eax, eax
jnz     short loc_106390C6
push    1Ch
lea     eax, [ebp+Buffer]
push    eax
push    [ebp+fdwReason]
call    ds:VirtualQuery
lea     eax, [ebp+phModule]
push    eax
push    [ebp+fdwReason]
push    6
call    ds:GetModuleHandleExA
mov     ecx, [ebp+Buffer.Protect]
test    eax, eax ; check if the address leads to a valid module
jz      short loc_106390B2 ; if the code's been manually mapped save thread's characteristics
cmp     ecx, 40h
jnz     short loc_106390C6

loc_106390B2:
mov     eax, [ebp+fdwReason]
mov     dword_1528625C, eax ; save thread start address
mov     dword_15286260, edi ; save thread id
mov     dword_15286264, ecx ; save protection of memory at thread start address

loc_106390C6:
pop     edi
mov     eax, 1
pop     esi
mov     esp, ebp
pop     ebp
retn    0Ch

loc_106390D3:
mov     eax, 1
mov     esp, ebp
pop     ebp
retn    0Ch

More Repositories

1

Osiris

Free and open-source game hack for Counter-Strike 2, written in modern C++. For Windows and Linux.
C++
3,198
star
2

VAC

Source code of Valve Anti-Cheat obtained from disassembly of compiled modules
C
678
star
3

VAC-Bypass

Valve Anti-Cheat bypass written in C.
C
526
star
4

VAC-Bypass-Loader

Loader for VAC Bypass written in C.
C
459
star
5

MemJect

Simple Dll injector loading from memory. Supports PE header and entry point erasure. Written in C99.
C
435
star
6

GOESP

Cross-platform streamproof ESP hack for Counter-Strike: Global Offensive, written in modern C++. Rendering and GUI powered by Dear ImGui + FreeType.
C++
432
star
7

Anubis

Free open-source training software / cheat for Counter-Strike: Global Offensive, written in C.
C
177
star
8

OneByteWallhack

CS:GO wallhack achieved by patching one byte of game memory. Written in Python 3.
Python
161
star
9

x86RetSpoof

Invoke functions with a spoofed return address. For 32-bit Windows binaries. Supports __fastcall, __thiscall, __stdcall and __cdecl calling conventions. Written in C++17.
C++
160
star
10

vac-hooks

Hook WinAPI functions used by Valve Anti-Cheat. Log calls and intercept arguments & return values. DLL written in C.
C
157
star
11

cs2-anticheat

Anticheat code found in Counter-Strike 2 binaries.
139
star
12

OneByteRadar

CS:GO radar hack achieved by patching one byte of game memory. Written in Python 3.
Python
102
star
13

Inflame

User-mode Windows DLL injector written in Assembly language (FASM syntax) with WinAPI.
Assembly
84
star
14

StringPool

A performant and memory efficient storage for immutable strings with C++17. Supports all standard char types: char, wchar_t, char16_t, char32_t and C++20's char8_t.
C++
49
star
15

KernelProcessList

Example Windows Kernel-mode Driver which enumerates running processes.
C
47
star
16

OsirisInventory

Inventory Changer for CS:GO
C++
36
star
17

Caesar

Open source cheat for Steam version of Counter-Strike 1.6.
C
29
star
18

OneByteMoney

CS:GO hack displaying enemies' money, achieved by patching one byte of game memory. Written in Python 3.
Python
26
star
19

PE2HEX

PE executable to array of bytes converter
Python
21
star
20

KernelPID

Example Windows Kernel-mode Driver which finds process ID by executable file name.
C
16
star
21

mars

An open source Counter-Strike: Global Offensive cheat for Linux.
C
16
star
22

csgo-champion

Champion - external CS:GO cheat for Linux
C++
16
star
23

KernelThread

C
13
star
24

helloworld-driver

C
11
star
25

OneByteQuickDuck

CS:GO quick duck achieved by patching one byte of game memory. Written in Python 3.
Python
9
star
26

fnv-cpp

C++
7
star
27

rusty-csgo

Attempts at internal game hacking (CS;GO) with Rust
Rust
6
star
28

windows-account-creator

Batch script to create user accounts in Windows.
Batchfile
6
star
29

FASM-DLL

Assembly
5
star
30

curiumcheat-cuphead

Curium is an open source cheat for Cuphead game.
C++
4
star
31

no-CRT

C++
4
star
32

winapi-calculator-cpp

WinAPI Calculator written in C++
C++
3
star
33

Feb

Assembly
3
star
34

lennox-engine

Lennox Game Engine
C++
3
star
35

Jector

Assembly
3
star
36

Fet

Assembly
3
star
37

cmake-demo

A collection of CMake scripts for C and C++ projects.
CMake
3
star
38

cpp-playground

C++
3
star
39

helloworld-DLL

Hello world! - DLL
C
3
star
40

helloworld-rust

Rust
2
star
41

helloworld-fasm

Hello world! - FASM
Assembly
2
star
42

zxvnme.github.io

zxvnme's site
CSS
2
star
43

RGBEngine

C
2
star
44

fnv-c

C
2
star
45

php-playground

PHP
2
star
46

ArchiveX

C++
2
star
47

opengl-base

Base OpenGL 4.6 application written in C.
C
2
star
48

snake-cpp

C++
2
star
49

cpp98-playground

C++
1
star
50

BSOD

Assembly
1
star
51

Feg

Assembly
1
star
52

curiumcheat-maxpayne

Curium is an open source cheat for Max Payne game.
C++
1
star
53

colormix-cpp

C++
1
star
54

coinflip-cpp

Coin flip simulation program.
C++
1
star
55

cout-vs-printf

Cout vs printf benchmark
C++
1
star
56

js-playground

HTML
1
star
57

binary-cpp

Binary - decimal calculator
C++
1
star