Skip to content

Commit 48f6618

Browse files
author
HackTricks News Bot
committed
Add content from: Sleeping Beauty: Putting Adaptix to Bed with Crystal Palace
1 parent 34da1da commit 48f6618

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

src/windows-hardening/av-bypass.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
{{#include ../banners/hacktricks-training.md}}
44

5+
- [Sleeping Beauty: Putting Adaptix to Bed with Crystal Palace](https://maorsabag.github.io/posts/adaptix-stealthpalace/sleeping-beauty/)
6+
- [Ekko sleep obfuscation](https://github.com/Cracked5pider/Ekko)
7+
8+
9+
510
**This page was written by** [**@m2rc_p**](https://twitter.com/m2rc_p)**!**
611

712
## Stop Defender
@@ -1061,6 +1066,43 @@ Related building blocks and examples
10611066
- Memory masking hooks (e.g., simplehook) and stack‑cutting PIC (stackcutting)
10621067
- PIC call‑stack spoofing stubs (e.g., Draugr)
10631068

1069+
1070+
## Import-Time IAT Hooking + Sleep Obfuscation (Crystal Palace/PICO)
1071+
1072+
### Import-time IAT hooks via a resident PICO
1073+
1074+
If you control a reflective loader, you can hook imports **during** `ProcessImports()` by replacing the loader's `GetProcAddress` pointer with a custom resolver that checks hooks first:
1075+
1076+
- Build a **resident PICO** (persistent PIC object) that survives after the transient loader PIC frees itself.
1077+
- Export a `setup_hooks()` function that overwrites the loader's import resolver (e.g., `funcs.GetProcAddress = _GetProcAddress`).
1078+
- In `_GetProcAddress`, skip ordinal imports and use a hash-based hook lookup like `__resolve_hook(ror13hash(name))`. If a hook exists, return it; otherwise delegate to the real `GetProcAddress`.
1079+
- Register hook targets at link time with Crystal Palace `addhook "MODULE$Func" "hook"` entries. The hook stays valid because it lives inside the resident PICO.
1080+
1081+
This yields **import-time IAT redirection** without patching the loaded DLL's code section post-load.
1082+
1083+
### Forcing hookable imports when the target uses PEB-walking
1084+
1085+
Import-time hooks only trigger if the function is actually in the target's IAT. If a module resolves APIs via a PEB-walk + hash (no import entry), force a real import so the loader's `ProcessImports()` path sees it:
1086+
1087+
- Replace hashed export resolution (e.g., `GetSymbolAddress(..., HASH_FUNC_WAIT_FOR_SINGLE_OBJECT)`) with a direct reference like `&WaitForSingleObject`.
1088+
- The compiler emits an IAT entry, enabling interception when the reflective loader resolves imports.
1089+
1090+
### Ekko-style sleep/idle obfuscation without patching `Sleep()`
1091+
1092+
Instead of patching `Sleep`, hook the **actual wait/IPC primitives** the implant uses (`WaitForSingleObject(Ex)`, `WaitForMultipleObjects`, `ConnectNamedPipe`). For long waits, wrap the call in an Ekko-style obfuscation chain that encrypts the in-memory image during idle:
1093+
1094+
- Use `CreateTimerQueueTimer` to schedule a sequence of callbacks that call `NtContinue` with crafted `CONTEXT` frames.
1095+
- Typical chain (x64): set image to `PAGE_READWRITE` → RC4 encrypt via `advapi32!SystemFunction032` over the full mapped image → perform the blocking wait → RC4 decrypt → **restore per-section permissions** by walking PE sections → signal completion.
1096+
- `RtlCaptureContext` provides a template `CONTEXT`; clone it into multiple frames and set registers (`Rip/Rcx/Rdx/R8/R9`) to invoke each step.
1097+
1098+
Operational detail: return “success” for long waits (e.g., `WAIT_OBJECT_0`) so the caller continues while the image is masked. This pattern hides the module from scanners during idle windows and avoids the classic “patched `Sleep()`” signature.
1099+
1100+
Detection ideas (telemetry-based)
1101+
- Bursts of `CreateTimerQueueTimer` callbacks pointing to `NtContinue`.
1102+
- `advapi32!SystemFunction032` used on large contiguous image-sized buffers.
1103+
- Large-range `VirtualProtect` followed by custom per-section permission restoration.
1104+
1105+
10641106
## SantaStealer Tradecraft for Fileless Evasion and Credential Theft
10651107

10661108
SantaStealer (aka BluelineStealer) illustrates how modern info-stealers blend AV bypass, anti-analysis and credential access in a single workflow.
@@ -1128,4 +1170,7 @@ Sleep(exec_delay_seconds * 1000); // config-controlled delay to outlive sandboxe
11281170
- [ChromElevator – Chrome App Bound Encryption Decryption](https://github.com/xaitax/Chrome-App-Bound-Encryption-Decryption)
11291171
- [Check Point Research – GachiLoader: Defeating Node.js Malware with API Tracing](https://research.checkpoint.com/2025/gachiloader-node-js-malware-with-api-tracing/)
11301172
1173+
- [Sleeping Beauty: Putting Adaptix to Bed with Crystal Palace](https://maorsabag.github.io/posts/adaptix-stealthpalace/sleeping-beauty/)
1174+
- [Ekko sleep obfuscation](https://github.com/Cracked5pider/Ekko)
1175+
11311176
{{#include ../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)