• Stars
    star
    330
  • Rank 127,657 (Top 3 %)
  • Language
    C++
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 6 years ago

Reviews

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

Repository Details

AntiDebugging sample sources written in C++

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);

More Repositories

1

torch-nansypp

NANSY++: Unified Voice Synthesis with Neural Analysis and Synthesis
Python
139
star
2

cpp-obfuscator

C++ implementation of compile time obfuscator
C++
132
star
3

torch-nansy

Torch implementation of NANSY, Neural Analysis and Synthesis, arXiv:2110.14513
Jupyter Notebook
62
star
4

torch-whisper-guided-vc

Torch implementation of Whisper-guided DDPM based Voice Conversion
Python
49
star
5

numpy-rnn

numpy implementation of Recurrent Neural Network
Jupyter Notebook
41
star
6

tf-diffwave

Tensorflow implementation of DiffWave: A Versatile Diffusion Model for Audio Synthesis
Jupyter Notebook
40
star
7

jax-variational-diffwave

Jax/Flax implementation of Variational-DiffWave.
Python
40
star
8

torch-styleddpm-vc

Torch implementation of UNIT-DDPM for voice conversion
Python
33
star
9

CodeInjection

Code Injection technique written in cpp language
C++
32
star
10

BranchTracer

Branch based windows debugger
C++
21
star
11

AlphaZero-Connect6

AlphaZero training framework for game Connect6 written in Rust with C++, Python interface.
Rust
17
star
12

cpp-concurrency

cpp implementation of golang style concurrency
C++
15
star
13

cpp-veh-dbi

C++ Implementation of VEH based windows dynamic binary instrumentation
C++
15
star
14

torch-diffusion-wavegan

Parallel waveform generation with DiffusionGAN
Python
15
star
15

PacketInjector

Detect HTTP packet and inject redirect packet
C++
13
star
16

np-gaussian-process

Numpy implementation of Gaussian Process Regression
Jupyter Notebook
11
star
17

tf-alae

(Unofficial) Tensorflow implementation of Adversarial Latent Autoencoder (ALAE, Pidhorskyi et al., 2020)
Jupyter Notebook
10
star
18

torch-retriever-vc

PyTorch implementation of Retriever: Learning Content-Style Representation
Python
10
star
19

torch-tacospawn

PyTorch implementation of TacoSpawn, Speaker Generation
Python
10
star
20

speechset

Numpy-librosa implementation of Speech dataset pipeline
Python
9
star
21

HYU-ELE3021

Hanyang Univ. 2020 Operating Systems (Prof. Hyungsoo Jung)
C
7
star
22

HYU-ITE2038

Database Systems and Applications in Hanyang University
C++
7
star
23

speechaug

PyTorch implementation of speech augmentation toolkit
Python
6
star
24

tf-mlptts

Tensorflow implementation of MLP-Mixer based TTS
Python
6
star
25

tf-neural-process

Tensorflow implementation of Neural Process family
Jupyter Notebook
6
star
26

tf-glow-tts

Tensorflow implementation of Glow-TTS
Python
6
star
27

FineDustPrediction

Tensorflow implementation of fine-dust forecaster
Python
6
star
28

TopMost

Make window always topmost
C++
5
star
29

revsic.github.io

HTML
4
star
30

torch-guided-tts

Torch implementation of Guided-TTS
3
star
31

Rewriting-A-Deep-Generative-Models

Experiments for paper "Rewriting a deep generative models"
Jupyter Notebook
3
star
32

tf-survae-flows

Tensorflow implementation of SurVAE Flows, Nielsen et al., 2020.
Jupyter Notebook
2
star
33

HYU-CSE4007

Artificial Intelligence lecture in Hanyang University.
Java
2
star
34

HYU-ELE4029

Hanyang Univ. 2020 Compilers
C
2
star
35

HYU-ITE4052

Hanyang Univ. 2020. Computer Vision (Prof. Taehyun Kim)
Jupyter Notebook
2
star
36

tf-branch-malware

Behavior based malware detection using branch data
Jupyter Notebook
2
star
37

HYU-ITE1015

ITE1015 - Creative Software Design in Hanyang University
C++
1
star
38

jax-istts

Jax/flax implementation of implicit self-supervision of TTS
1
star
39

HYU-CSE2010

Data Structures in Hanyang University
C
1
star
40

go-interpreter

Writing an interpreter in Go, Thorsten Ball
Go
1
star
41

tf-vanilla-gan

Tensorflow implementation of Vanilla GANs
Python
1
star
42

torch-tacotron

PyTorch implementation of Tacotron, 2017.
Python
1
star
43

revsic

Profile
1
star