C-Integrity-Library
C# Exports
[DllImport("Exports.dll")]
public static extern bool DebuggerPresent_1();
[DllImport("Exports.dll")]
public static extern bool DebuggerPresent_2();
[DllImport("Exports.dll")]
public static extern bool DebuggerPresent_3();
[DllImport("Exports.dll")]
public static extern bool DebuggerPresent_4();
[DllImport("Exports.dll")]
public static extern int GetProcessIntegrityHash();
[DllImport("Exports.dll")]
public static extern void OverwriteLoadLibraries(bool TerminateOnInjection);
[DllImport("Exports.dll")]
public static extern void DebuggerBreaker();
[DllImport("Exports.dll")]
public static extern void AttatchDebugger(UInt32 ProcessID);
[DllImport("Exports.dll")]
public static extern void DetatchDebugger(UInt32 ProcessID);
C++ Functions
DebuggerPresent_1
DebuggerPresent_2
DebuggerPresent_3
DebuggerPresent_4
GetProcessIntegrityHash
OverwriteLoadLibraries
DebuggerBreaker
GetHandlesCount
Usage Pseudocode
print(DebuggerPresent_1()) -- true/false
print(DebuggerPresent_2()) -- true/false
print(DebuggerPresent_3()) -- true/false
print(DebuggerPresent_4()) -- true/false
OverwriteLoadLibraries(true) -- overwrites LoadLibraryExW and LoadLibraryExA
while true do
DebuggerBreaker() -- sets looping annoying breakpoint
integrityHash = GetProcessIntegrityHash() -- set integrity hash
handleCount = GetHandlesCount(); -- set handlecount
Sleep(1000) -- 100-1000ms works well
if integrityHash != GetProcessIntegrityHash() then -- verify integrity hash 1 second ago matches current integrity hash
print("Tamper Detected")
end
if handleCount != GetHandlesCount() then -- verifies no new handles have been opened to the process
print("Tamper Detected")
end
-- please note that checking the handle count in a faster loop would be better but this is psuedocode
end
Todo
- Add More Debugger Present Checks
- Detail The C++ Code
- DLL Integrity Check
- Find More Debug Detection Methods
- Find New Ways To Break Debuggers
- Function Integrity Checks
- VirtualProtect attack protections
- Fix Termination Assembly
- VM Detection