|
2 | 2 |
|
3 | 3 | {{#include ../banners/hacktricks-training.md}} |
4 | 4 |
|
| 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 | + |
5 | 10 | **This page was written by** [**@m2rc_p**](https://twitter.com/m2rc_p)**!** |
6 | 11 |
|
7 | 12 | ## Stop Defender |
@@ -1061,6 +1066,43 @@ Related building blocks and examples |
1061 | 1066 | - Memory masking hooks (e.g., simplehook) and stack‑cutting PIC (stackcutting) |
1062 | 1067 | - PIC call‑stack spoofing stubs (e.g., Draugr) |
1063 | 1068 |
|
| 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 | + |
1064 | 1106 | ## SantaStealer Tradecraft for Fileless Evasion and Credential Theft |
1065 | 1107 |
|
1066 | 1108 | 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 |
1128 | 1170 | - [ChromElevator – Chrome App Bound Encryption Decryption](https://github.com/xaitax/Chrome-App-Bound-Encryption-Decryption) |
1129 | 1171 | - [Check Point Research – GachiLoader: Defeating Node.js Malware with API Tracing](https://research.checkpoint.com/2025/gachiloader-node-js-malware-with-api-tracing/) |
1130 | 1172 |
|
| 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 | +
|
1131 | 1176 | {{#include ../banners/hacktricks-training.md}} |
0 commit comments