A Python source-to-source hardening tool for Windows C programs. It implements the adaptive, multi-indicator dynamic-analysis detection framework from:
K. E. Sabri, "Advanced Adaptive Techniques for Securing Applications Against Dynamic Reverse Engineering Attacks," Engineering, Technology & Applied Science Research, vol. 16, no. 3, pp. 35999-36005, 2026. https://doi.org/10.48084/etasr.18160
Reference C implementation: https://github.com/sabrikm/Dynamic_Analysis_Detection
Given a .c file, dad_hardener injects the paper's eight runtime
indicators (anti-debugging + anti-instrumentation), a weighted
confidence-score aggregator (the paper's Eq. 1), and a three-tier adaptive
response (low / medium / high), then writes out a hardened .c file you
compile normally (on Windows, or cross-compiled with MinGW-w64, since the
indicators use the Win32 API — windows.h, tlhelp32.h, psapi.h).
The paper's point is that a single anti-debugging or anti-instrumentation
check is brittle, an attacker who identifies it can bypass it trivially.
Instead, each indicator contributes a weight to a running score; the
program's response scales with how much independent evidence of analysis
has accumulated, which is harder to defeat than tripping one if. This tool
automates applying that model to an arbitrary C program instead of
hand-wiring the checks into each project.
python3 -m pip install -e .or just run it in place with python3 -m dad_hardener.harden ... from the
repo root (no install needed).
python -m dad_hardener examples\calc.c -o calc.hardened.c --verboseList the indicators and their paper-matched weights:
python3 -m dad_hardener.harden --list-indicatorskey label category weight
----------------------------------------------------------------------
api_debugger IsDebuggerPresent debug 5
debug_registers Debug registers debug 4
debugger_process Debugger process detected debug 4
parent_process Parent process debug 4
timing Time debug 2
inline_hook Inline hook instrumentation 5
frida_process Frida process detected instrumentation 4
frida_module Frida module loaded instrumentation 5
- Indicator functions — direct ports of the reference implementation
(debugger presence, debug-register inspection, debugger/Frida process
enumeration, parent-process check, inline-hook detection via jump-target
resolution against
kernel32.dll/kernelbase.dll, and a timing check). dad_compute_confidence_score()— runs every selected indicator and sumsweight * triggered(paper's Eq. 1).dad_init_and_score()— called once, automatically inserted as the first statement inside yourmain(). Computes the score, classifies it into the paper's three tiers, and applies the response you configured for the HIGH tier (--on-high) and MEDIUM tier (--on-medium).- Per-block responses — anywhere in your source you can mark a region
with
DAD_PROTECT/DAD_PROTECT_ENDcomments (see below) to make that specific code behave differently depending on the score, rather than only the program-wide default.
| Score | Tier | Paper's description |
|---|---|---|
< 5 |
low | no strong indicator present; runs normally |
5 – 9 |
medium | possible analysis; may limit sensitive features |
>= 10 |
high | strong evidence of active analysis |
/* DAD_PROTECT level=high action=terminate */
result = validate_license(key);
apply_unlock(result);
/* DAD_PROTECT_END */level=low|high— which threshold triggers the response (defaulthigh).action=terminate|skip|decoy(defaultskip):terminate— print a notice to stderr andexit(1)instead of running the block.skip— silently skip the block.decoy=my_fn— callmy_fn()instead of the real block; definemy_fnyourself (e.g. return a plausible-looking but wrong result). Omitdecoy=to use the built-indad_default_decoy()stub.
The tool rewrites this into:
if (g_dad_confidence_score >= DAD_THRESHOLD_HIGH) {
fprintf(stderr, "Blocked under analysis conditions.\n");
exit(1);
} else {
result = validate_license(key);
apply_unlock(result);
}If a program has no DAD_PROTECT markers at all, the tool still injects
the indicators and the program-wide --on-high / --on-medium response at
the top of main().
--indicators KEYS comma list or "all" (default: all)
--disable KEYS comma list to exclude
--timing-threshold-ms N default 60 (paper's value)
--hook-target NAME imported API the inline-hook check watches
(default CreateFileW ..for now will ask about it during our next meeting)
--on-high {none,log,terminate} default terminate
--on-medium {none,log} default log
--verbose turn on dad_log() diagnostic printing
decoy=my_fn — call my_fn() instead of running the real block, and
return its result. my_fn must be callable with no arguments.
To make the decoy see the real call's parameters, define it as a zero-argument function-like macro that expands using the enclosing function's own parameter names:
#define subtract_decoy() add(a, b)
int subtract(int a, int b) {
/* DAD_PROTECT level=low action=decoy decoy=subtract_decoy */
return a - b;
/* DAD_PROTECT_END */
}
Under analysis, subtract(a, b) transparently returns add(a, b)
instead of a - b — a plausible-looking but wrong result, without
subtract() needing to know anything about add() itself.
Omit decoy= to use the built-in dad_default_decoy() stub instead.
Bluwark/
dad_hardener/
detectors.py # the 8 indicator definitions (Table I)
harden.py # injection engine + CLI
examples/
calc.c # sample target program with a DAD_PROTECT block
Some parts of this ReadMe file were written with the help of AI.