Skip to content

About

LLVM Obfuscation Pass For Integrity Checks Against Inline Hooks/Debuggers Attacking Your Code

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Integrity Checks

Built for LLVM 19.1 - Windows x64

Unlike more conventional integrity check systems you find in things like VMProtect, we want to actually have active protections against debuggers.

  • What we do is find all the constants in a function
  • Assess the size between them
  • We then write a constant encryption that is using the blake3 hash of the code between the constants.
  • Therefore if any up and coming breakpoints or hooks are found, we actively break upstream as the constant will be incorrect.
  • Unlike commercial solutions, we get instant relief as we aren't scanning the entire application against a CRC table, we just read about 256bytes of data and decrypt against it.
  • This allows us to get realtime results.

Since we are LLVM based, we can't get the blake3 hash immediately, and we also can't easily just import a blake3 function as link time passing.
You have to include the runtime in your codebase, then use the patcher afterwards to patch the actual blake3 hashes into the function.

image
sub_140001000 Is the blake3 hash, as you can see, knownhash xor blake3(start, length(start-end)) xor balance.
As you can see they do overlap one another too so you can't patch one out to place a hook, You would need to patch all of them in the function, per function inlining sub_140001000 and placing integrity checks on itself would also be a good idea.

How to use

Move Runtime/B3Runtime.cpp into your code base. Build with the pass.
Build Patcher/Patcher.cpp and pass it the exe. It will then fix up the blake3 hashes used for integrity, then cleans up the indicators.
I must make this clear, The integrity checks verify one another in function but not out of function, you could xor to other integrities to make sure they are valid too. Interfunctionally they check eachother though.

Annotations

__attribute__((annotate("integrity")))
  • Encrypts Constants With Hashes

How To Build

  • Download LLVM 19.1
  • Download VCPKG
  • VCPKG install asmjit
  • Open build.bat in a text editor.
  • Find the LLVM 19.1 references in the command line, Change them to your file path.
  • Find the VCPKG references in the command line, Change them to your file path.
  • Run the build script
  • Build your application with the -load-pass-plugin Param to the FunctionPass.dll

About

LLVM Obfuscation Pass For Integrity Checks Against Inline Hooks/Debuggers Attacking Your Code

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages