All Projects → revsic → Antidebugging

revsic / Antidebugging

Licence: mit
AntiDebugging sample sources written in C++

Programming Languages

cpp
1120 projects

Labels

Projects that are alternatives of or similar to Antidebugging

Meow hash
Official version of the Meow hash, an extremely fast level 3 hash
Stars: ✭ 1,204 (+956.14%)
Mutual labels:  hash
Gokangarootwelve
Implementation of KangarooTwelve in Go
Stars: ✭ 90 (-21.05%)
Mutual labels:  hash
Xxhash cpp
Port of the xxhash library to C++17.
Stars: ✭ 106 (-7.02%)
Mutual labels:  hash
Pictogrify
🎭 Generate unique pictograms from any text
Stars: ✭ 80 (-29.82%)
Mutual labels:  hash
Dash
Scalable Hashing on Persistent Memory
Stars: ✭ 86 (-24.56%)
Mutual labels:  hash
Eternal
A C++14 compile-time/constexpr map and hash map with minimal binary footprint
Stars: ✭ 93 (-18.42%)
Mutual labels:  hash
Digestif
Simple hash algorithms in OCaml
Stars: ✭ 69 (-39.47%)
Mutual labels:  hash
Node Sha3
SHA3 for JavaScript - The Keccak family of hash algorithms
Stars: ✭ 112 (-1.75%)
Mutual labels:  hash
Lexicon
A data package containing lexicons and dictionaries for text analysis
Stars: ✭ 87 (-23.68%)
Mutual labels:  hash
Blake3
BLAKE3 hashing for JavaScript: native Node bindings (where available) and WebAssembly
Stars: ✭ 100 (-12.28%)
Mutual labels:  hash
Birdseed
🐦 🎲 Use Twitter's Search API to get random numbers
Stars: ✭ 81 (-28.95%)
Mutual labels:  hash
Pluck all
A more efficient way to get data from database. Like #pluck method but return array of hashes instead.
Stars: ✭ 83 (-27.19%)
Mutual labels:  hash
Hashcobra
HashCobra Hash Cracking tool.
Stars: ✭ 96 (-15.79%)
Mutual labels:  hash
Signature Base
Signature base for my scanner tools
Stars: ✭ 1,212 (+963.16%)
Mutual labels:  hash
Minperf
A Minimal Perfect Hash Function Library
Stars: ✭ 107 (-6.14%)
Mutual labels:  hash
Active enumerable
ActiveRecord like query methods for Ruby enumerable collections.
Stars: ✭ 73 (-35.96%)
Mutual labels:  hash
Siphash Js
A Javascript implementation of SipHash-2-4
Stars: ✭ 90 (-21.05%)
Mutual labels:  hash
Node Webcrypto Ossl
A WebCrypto Polyfill for Node in TypeScript built on OpenSSL.
Stars: ✭ 113 (-0.88%)
Mutual labels:  hash
Stata Gtools
Faster implementation of Stata's collapse, reshape, xtile, egen, isid, and more using C plugins
Stars: ✭ 108 (-5.26%)
Mutual labels:  hash
Opensubtitles Api
nodejs opensubtitles.org api wrapper for downloading and uploading subtitles in multiple langs
Stars: ✭ 96 (-15.79%)
Mutual labels:  hash

Anti Debugging

Anti debugging techniques written in C++.

Anti Attach, Anti Anti Attach

Debugger attach process with DebugActiveProcess api.

DebugActiveProcess(pid);

DEBUG_EVENT dbgEvent;
BOOL dbgContinue = True;

while (dbgContinue) {
    if (FALSE == WaitForDebugEvent(&dbgEvent, 100)) {
        continue;
    }

    ...
}

It creates a thread in debuggee, then it calls DbgUiRemoteBreakin() to debug process.

//AntiAttach
__declspec(naked) void AntiAttach() {
    __asm {
		jmp ExitProcess
	}
}

//main
HANDLE hProcess = GetCurrentProcess();

HMODULE hMod = GetModuleHandleW(L"ntdll.dll");
FARPROC func_DbgUiRemoteBreakin = GetProcAddress(hMod, "DbgUiRemoteBreakin");

WriteProcessMemory(hProcess, func_DbgUiRemoteBreakin, AntiAttach, 6, NULL);

Anti-Attacher hooks DbgUiRemoteBreakin and redirects it to ExitProcess. AntiAnti-Attacher releases the hooked function.

Text Section Hashing

Debugger sets a software breakpoint by overwriting the int 3 instruction.

It hashes text section and periodically checks that the text section has been changed.

while (1) {
	Sleep(1000);

	DWORD64 dwCurrentHash = HashSection(lpVirtualAddress, dwSizeOfRawData);
	if (dwRealHash != dwCurrentHash) {
		MessageBoxW(NULL, L"DebugAttached", L"WARN", MB_OK);
		exit(1);
	}

	if (bTerminateThread) {
		return;
	}
}

VEH Checker, DR Register Resetter

VEH Debugger use Vectored Exception Handler.

It checks the fourth bit(ProcessUsingVEH) of the PEB's CrossProcessFlags(+0x50). If ProcessUsingVEH bit is set, then VEH is being used.

NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi, sizeof(pbi), &ReturnLength);
PPEB pPEB = (PPEB)pbi.PebBaseAddress;

SIZE_T Written;
DWORD64 CrossProcessFlags = -1;
ReadProcessMemory(hProcess, (PBYTE)pPEB + 0x50, (LPVOID)&CrossProcessFlags, sizeof(DWORD64), &Written);

printf("[*] CrossProcessFlags : %p\n", CrossProcessFlags);
if (CrossProcessFlags & 0x4) {
	printf("[*] veh set\n");
}
else {
	printf("[*] veh unset\n");
}

VEH Debugger usually uses Hardware breakpoint. Verify hardware bp is set

HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, tid);

CONTEXT ctx;
memset(&ctx, 0, sizeof(CONTEXT));
ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;

ctx.Dr0 = 0;
ctx.Dr1 = 0;
ctx.Dr2 = 0;
ctx.Dr3 = 0;
ctx.Dr7 &= (0xffffffffffffffff ^ (0x1 | 0x4 | 0x10 | 0x40));

SetThreadContext(hThread, &ctx);
CloseHandle(hThread);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].