What it does
- Compile-time encrypted strings, with a key per string
- Obfuscated values in memory (<code>CProtectedValue</code>)
- Imports resolved by hash (Windows)
- Image integrity: patched bytes and inline hooks
- Environment observation: debugger, timing, virtual machine
- Secure memory: <code>SecureZero</code>, guard pages, encrypted regions
- Findings accumulator, with no plaintext total
- Per-customer diversity from a seed
Measured
- MSVC. Obfuscated value: 17.6x a direct access (declared range of 10x to 50x)
- Decrypting a 32-byte string: about 69 ns
Known limits
- The absence of plaintext in the binary was measured on MSVC only
- Code virtualization and control-flow flattening are out of scope
Hardening primitives for legitimate software sold to third parties. It detects, measures and protects. It never decides. It does not terminate processes, does not crash, does not phone home, and does not ban anyone. Composing these primitives into a real defense is the integrator's job. In our portfolio, that is Praetor's job.
namespace Ethereal::Guard. Tier 1. It does not link anything to Platform: it consumes Platform's introspection through seams (EnumModulesSelf, EnumExportNames, ResolveExport, EnumMemoryRegions, Crc32c).
---
The first thing to know: everything is off by default
Ethereal is a library sold to developers. They will debug their own code through it, run profilers, collect memory dumps from their users, and pass the binary through enterprise antivirus. All of those paths break with aggressive obfuscation.
That is why a normal build has no obfuscation at all, no debugger tests, no integrity checks, and no timing traps. Anyone who turns nothing on gets a completely normal library, debuggable and profiler-friendly.
And each piece has its own flag. Never a single switch:
| CMake flag | Turns on | Macro |
|---|---|---|
ETHEREAL_GUARD | the module (capabilities, accumulator, C ABI) | ETL_GUARD |
ETHEREAL_GUARD_STRINGS | encrypted strings | ETL_GUARD_STRING_ENCRYPTION |
ETHEREAL_GUARD_VALUES | obfuscated values | ETL_GUARD_PROTECTED_VALUES |
ETHEREAL_GUARD_IMPORTS | resolution by hash | ETL_GUARD_IMPORT_HASHING |
ETHEREAL_GUARD_INTEGRITY | image integrity | ETL_GUARD_INTEGRITY |
ETHEREAL_GUARD_ANTIDEBUG | environment observation | ETL_GUARD_ANTI_DEBUG |
ETHEREAL_GUARD_SECURE_MEMORY | wiping, guard pages, encrypted region | ETL_GUARD_SECURE_MEMORY |
ETHEREAL_GUARD_MBA | mixed transformation on values | ETL_GUARD_MBA |
ETHEREAL_GUARD_ALL | everything, turning on each piece individually | (none) |
A piece that is turned off costs exactly zero. Its source stays out of the build, with no if in the code. See the note in the next section, which is where this almost went wrong.
---
The threat model, stated honestly
The spec requires this to be written literally, because selling more than is delivered is a support and reputation liability.
| Technique | What it buys | Against someone who knows reverse engineering |
|---|---|---|
| Compile-time encrypted strings | removes the strings output, kills casual grep | hours: emulation dumps them all |
| Imports by hash | empties the IAT, removes the first artifact an analyst reads | hours |
| Obfuscated values | defeats the naive scan for a known constant | hours to days |
| Integrity | catches a patched binary and inline hooks | days, and only with a delayed response |
| Flag-based anti-debug | stops nothing | minutes: there are public bypasses |
| Timing-based anti-debug | real friction in single-stepping | days |
| Delayed response | breaks the patch-and-retry cycle entirely | weeks, the only item here of a different order of magnitude |
Obfuscation buys time. What buys security is server-side authority, per-customer build diversity, and acting on findings in batches, far from the point of detection.
---
The most valuable piece: the findings accumulator (findings.hpp)
It is the most valuable piece and the one nobody builds alone. Never fail at the point of detection.
A check that terminates the process the moment it detects something tells the attacker where it is: they attach the debugger, see where the process died, patch one instruction, and move on. Forty checks like that are two hours of tedious work.
The right way: the detection calls Report and returns normally, with no observable effect. Findings accumulate in storage spread across several shards, combined on read. The accumulator is queried somewhere else, minutes later. The consequence is subtle degradation or telemetry, and the real action happens on the server side, in batches.
This inverts the economics: the attacker can no longer run the observe, patch and retry cycle in minutes, because they do not know which of the forty checks fired or when. Everything else buys hours. This buys weeks. CTimeDelayedGate makes the delayed read easy to write.
The test proves that the total does not live in the clear in any byte of the object, because a counter at an address is a target.
---
The pieces, one by one
- **
secmem.hpp**:SecureZero, which the optimizer cannot remove (dead store elimination leaves passwords on the stack, a class of defect shipped to production more often than anyone admits).ConstantTimeEquals. Guard pages with a sentinel, which catch the one-byte overflow that a guard page alone lets through.CEncryptedRegion, encrypted at rest, with the key derived from transient state instead of stored next to the plaintext.
- **
values.hpp**:CProtectedValue<T>, with a per-instance key derived from the address, so that two equal logical values have different bytes. No implicit conversion, on purpose: the user writes.Get(), because making the cost invisible is how these values end up in loops. Measured: 10× to 50× a raw access. Use only in cold decision state, never in data.
- **
strings.hpp**: encrypted strings, with a per-string key (__COUNTER__+ line + seed) and no shared stub. The plaintext does not exist in the binary, and the test proves it by searching for the text in the linked artifact. In Debug it does not encrypt, so the debugger stays useful.
- **
imports.hpp**: resolution by the hash of the name, with noGetProcAddressand no name in the binary. It is composed on top of Platform, without walking the PEB or parsing PE: that is Platform's job, already tested. Windows only, by design (the IAT is PE). On ELF the capability sayseNotSupported, honestly.
- **
integrity.hpp: a snapshot taken at initialization, without reading from disk. Comparing memory with disk requires undoing relocations and normalizing the IAT, and that is what makes the homemade checker produce false positives all the time. It detects a patched byte and an inline hook on a tracked export. It reports and does not judge:** legitimate hooks are common (overlays, profilers).
- **
environment.hpp: each signal with its real strength. The strong one is timing skew (single-stepping distorts it in a way that is expensive to hide). A virtual machine is reported as a fact and does not add confidence**: many legitimate users run in a VM.
---
What caught one of our own defects, here
Compiled() answers whether the code exists, and the sources enter CMake behind each piece's flag. If a source were always included and only the flag controlled the capability, Compiled() would say that the piece does not exist while its code is in the binary, and anyone who branched on the query would never call a function that works.
That was exactly the defect the Platform audit found in the signature capability, fixed only halfway inside an #if defined( ETL_PLATFORM_WINDOWS ). We did not want to repeat it in the first hour of the new module.
---
Explicitly out of scope
- Code virtualization (VMProtect, Themida): years of specialized work. Buy it, do not build it.
- Control flow flattening, opaque predicates: compiler pass work, which cannot be done by hand-written code. Apply an LLVM pass to the Praetor binary on output, function by function.
- Packing, self-modifying code, drivers, injection: none of that belongs in a library sold to third parties.
- Any technique whose purpose is evading security software. This module hardens legitimate software against reverse engineering. It is not a packer and cannot become one, as a matter of principle and because that is how a commercial SDK ends up on a detection list.
---
What really protects, in order
- Server-side authority. The client is a sensor. The server is the judge.
- Per-customer build diversity (
ETL_GUARD_SEED). A crack does not transfer. - Delayed, batched response.
- Everything else in this module, which buys time.
---
C ABI
The complete surface, except the template wrappers. Strings cross as an encrypted blob plus a function that decrypts into a buffer. Obfuscated values stay on the C++ side. The accumulator, integrity, environment and secure memory cross cleanly, with static_assert mirrors pinning the numbers. The status codes are the common ones from ethereal/c/etlc_status.h (since 2026-10-16). Every function that depends on a piece answers ETLC_ERR_NOT_COMPILED when that piece was not built in, never a link error.
---
How this was verified
tests/guard.cpp (91 checks) and tests/guard_c_abi.c (26, in C11 and C17). The oracles are all external to what they measure:
- the plaintext is searched for in the linked artifact (Release), not in memory.
- the per-string key is proven by comparing two ciphertexts, without decrypting either.
- value obfuscation is proven by comparing the bytes of two equal instances.
- the integrity patch is measured by actually writing a byte of code and requiring the check to catch it, and to become clean again when the byte is restored.
---
What is missing
- Absence of the plaintext on GCC/Clang, measured. The test runs on MSVC. The spec asks for the check on all three compilers, in Debug and Release. It still has to run on Linux.
- The per-platform cost table in the README, with measured numbers from both sides. Today there are only the MSVC numbers (obfuscated value 17.6×, decrypting 32 bytes ~69 ns).
- **The
ETL_GUARD_AV_FRIENDLYprofile** that the spec asks for, and testing the artifacts against the major scanners. - The post-build verification tool that greps the artifact for each protected literal, as an automated release step.