Skip to content

Commit 81a6fc6

Browse files
authored
Merge pull request #2004 from HackTricks-wiki/update_Sleeping_Beauty__Putting_Adaptix_to_Bed_with_Cryst_20260314_184049
Sleeping Beauty Putting Adaptix to Bed with Crystal Palace
2 parents a5786c0 + feb312f commit 81a6fc6

1 file changed

Lines changed: 40 additions & 3 deletions

File tree

src/windows-hardening/av-bypass.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
**This page was written by** [**@m2rc_p**](https://twitter.com/m2rc_p)**!**
5+
**This page was initially written by** [**@m2rc_p**](https://twitter.com/m2rc_p)**!**
66

77
## Stop Defender
88

@@ -1088,6 +1088,43 @@ Related building blocks and examples
10881088
- Memory masking hooks (e.g., simplehook) and stack‑cutting PIC (stackcutting)
10891089
- PIC call‑stack spoofing stubs (e.g., Draugr)
10901090

1091+
1092+
## Import-Time IAT Hooking + Sleep Obfuscation (Crystal Palace/PICO)
1093+
1094+
### Import-time IAT hooks via a resident PICO
1095+
1096+
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:
1097+
1098+
- Build a **resident PICO** (persistent PIC object) that survives after the transient loader PIC frees itself.
1099+
- Export a `setup_hooks()` function that overwrites the loader's import resolver (e.g., `funcs.GetProcAddress = _GetProcAddress`).
1100+
- 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`.
1101+
- 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.
1102+
1103+
This yields **import-time IAT redirection** without patching the loaded DLL's code section post-load.
1104+
1105+
### Forcing hookable imports when the target uses PEB-walking
1106+
1107+
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:
1108+
1109+
- Replace hashed export resolution (e.g., `GetSymbolAddress(..., HASH_FUNC_WAIT_FOR_SINGLE_OBJECT)`) with a direct reference like `&WaitForSingleObject`.
1110+
- The compiler emits an IAT entry, enabling interception when the reflective loader resolves imports.
1111+
1112+
### Ekko-style sleep/idle obfuscation without patching `Sleep()`
1113+
1114+
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:
1115+
1116+
- Use `CreateTimerQueueTimer` to schedule a sequence of callbacks that call `NtContinue` with crafted `CONTEXT` frames.
1117+
- 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.
1118+
- `RtlCaptureContext` provides a template `CONTEXT`; clone it into multiple frames and set registers (`Rip/Rcx/Rdx/R8/R9`) to invoke each step.
1119+
1120+
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.
1121+
1122+
Detection ideas (telemetry-based)
1123+
- Bursts of `CreateTimerQueueTimer` callbacks pointing to `NtContinue`.
1124+
- `advapi32!SystemFunction032` used on large contiguous image-sized buffers.
1125+
- Large-range `VirtualProtect` followed by custom per-section permission restoration.
1126+
1127+
10911128
## SantaStealer Tradecraft for Fileless Evasion and Credential Theft
10921129

10931130
SantaStealer (aka BluelineStealer) illustrates how modern info-stealers blend AV bypass, anti-analysis and credential access in a single workflow.
@@ -1135,7 +1172,6 @@ Sleep(exec_delay_seconds * 1000); // config-controlled delay to outlive sandboxe
11351172
- [simplehook – sample](https://tradecraftgarden.org/simplehook.html)
11361173
- [stackcutting – sample](https://tradecraftgarden.org/stackcutting.html)
11371174
- [Draugr – call-stack spoofing PIC](https://github.com/NtDallas/Draugr)
1138-
11391175
- [Unit42 – New Infection Chain and ConfuserEx-Based Obfuscation for DarkCloud Stealer](https://unit42.paloaltonetworks.com/new-darkcloud-stealer-infection-chain/)
11401176
- [Synacktiv – Should you trust your zero trust? Bypassing Zscaler posture checks](https://www.synacktiv.com/en/publications/should-you-trust-your-zero-trust-bypassing-zscaler-posture-checks.html)
11411177
- [Check Point Research – Before ToolShell: Exploring Storm-2603’s Previous Ransomware Operations](https://research.checkpoint.com/2025/before-toolshell-exploring-storm-2603s-previous-ransomware-operations/)
@@ -1149,11 +1185,12 @@ Sleep(exec_delay_seconds * 1000); // config-controlled delay to outlive sandboxe
11491185
- [Zero Salarium – Countering EDRs With The Backing Of Protected Process Light (PPL)](https://www.zerosalarium.com/2025/08/countering-edrs-with-backing-of-ppl-protection.html)
11501186
- [Zero Salarium – Break The Protective Shell Of Windows Defender With The Folder Redirect Technique](https://www.zerosalarium.com/2025/09/Break-Protective-Shell-Windows-Defender-Folder-Redirect-Technique-Symlink.html)
11511187
- [Microsoft – mklink command reference](https://learn.microsoft.com/windows-server/administration/windows-commands/mklink)
1152-
11531188
- [Check Point Research – Under the Pure Curtain: From RAT to Builder to Coder](https://research.checkpoint.com/2025/under-the-pure-curtain-from-rat-to-builder-to-coder/)
11541189
- [Rapid7 – SantaStealer is Coming to Town: A New, Ambitious Infostealer](https://www.rapid7.com/blog/post/tr-santastealer-is-coming-to-town-a-new-ambitious-infostealer-advertised-on-underground-forums)
11551190
- [ChromElevator – Chrome App Bound Encryption Decryption](https://github.com/xaitax/Chrome-App-Bound-Encryption-Decryption)
11561191
- [Check Point Research – GachiLoader: Defeating Node.js Malware with API Tracing](https://research.checkpoint.com/2025/gachiloader-node-js-malware-with-api-tracing/)
1192+
- [Sleeping Beauty: Putting Adaptix to Bed with Crystal Palace](https://maorsabag.github.io/posts/adaptix-stealthpalace/sleeping-beauty/)
1193+
- [Ekko sleep obfuscation](https://github.com/Cracked5pider/Ekko)
11571194
- [SysWhispers4 – GitHub](https://github.com/JoasASantos/SysWhispers4)
11581195
11591196

0 commit comments

Comments
 (0)