You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Note that This technique does not provide privilege escalation by itself; it requires admin rights.
977
977
978
+
## API/IAT Hooking + Call-Stack Spoofing with PIC (Crystal Kit-style)
979
+
980
+
Red teams can move runtime evasion out of the C2 implant and into the target module itself by hooking its Import Address Table (IAT) and routing selected APIs through attacker-controlled, position‑independent code (PIC). This generalises evasion beyond the small API surface many kits expose (e.g., CreateProcessA), and extends the same protections to BOFs and post‑exploitation DLLs.
981
+
982
+
High-level approach
983
+
- Stage a PIC blob alongside the target module using a reflective loader (prepended or companion). The PIC must be self‑contained and position‑independent.
984
+
- As the host DLL loads, walk its IMAGE_IMPORT_DESCRIPTOR and patch the IAT entries for targeted imports (e.g., CreateProcessA/W, CreateThread, LoadLibraryA/W, VirtualAlloc) to point at thin PIC wrappers.
985
+
- Each PIC wrapper executes evasions before tail‑calling the real API address. Typical evasions include:
986
+
- Memory mask/unmask around the call (e.g., encrypt beacon regions, RWX→RX, change page names/permissions) then restore post‑call.
987
+
- Call‑stack spoofing: construct a benign stack and transition into the target API so call‑stack analysis resolves to expected frames.
988
+
- For compatibility, export an interface so an Aggressor script (or equivalent) can register which APIs to hook for Beacon, BOFs and post‑ex DLLs.
989
+
990
+
Why IAT hooking here
991
+
- Works for any code that uses the hooked import, without modifying tool code or relying on Beacon to proxy specific APIs.
992
+
- Covers post‑ex DLLs: hooking LoadLibrary* lets you intercept module loads (e.g., System.Management.Automation.dll, clr.dll) and apply the same masking/stack evasion to their API calls.
993
+
- Restores reliable use of process‑spawning post‑ex commands against call‑stack–based detections by wrapping CreateProcessA/W.
- Apply the patch after relocations/ASLR and before first use of the import. Reflective loaders like TitanLdr/AceLdr demonstrate hooking during DllMain of the loaded module.
1005
+
- Keep wrappers tiny and PIC-safe; resolve the true API via the original IAT value you captured before patching or via LdrGetProcedureAddress.
1006
+
- Use RW → RX transitions for PIC and avoid leaving writable+executable pages.
1007
+
1008
+
Call‑stack spoofing stub
1009
+
- Draugr‑style PIC stubs build a fake call chain (return addresses into benign modules) and then pivot into the real API.
1010
+
- This defeats detections that expect canonical stacks from Beacon/BOFs to sensitive APIs.
1011
+
- Pair with stack cutting/stack stitching techniques to land inside expected frames before the API prologue.
1012
+
1013
+
Operational integration
1014
+
- Prepend the reflective loader to post‑ex DLLs so the PIC and hooks initialise automatically when the DLL is loaded.
1015
+
- Use an Aggressor script to register target APIs so Beacon and BOFs transparently benefit from the same evasion path without code changes.
1016
+
1017
+
Detection/DFIR considerations
1018
+
- IAT integrity: entries that resolve to non‑image (heap/anon) addresses; periodic verification of import pointers.
1019
+
- Stack anomalies: return addresses not belonging to loaded images; abrupt transitions to non‑image PIC; inconsistent RtlUserThreadStart ancestry.
1020
+
- Loader telemetry: in‑process writes to IAT, early DllMain activity that modifies import thunks, unexpected RX regions created at load.
1021
+
- Image‑load evasion: if hooking LoadLibrary*, monitor suspicious loads of automation/clr assemblies correlated with memory masking events.
1022
+
1023
+
Related building blocks and examples
1024
+
- Reflective loaders that perform IAT patching during load (e.g., TitanLdr, AceLdr)
1025
+
- Memory masking hooks (e.g., simplehook) and stack‑cutting PIC (stackcutting)
-[Unit42 – New Infection Chain and ConfuserEx-Based Obfuscation for DarkCloud Stealer](https://unit42.paloaltonetworks.com/new-darkcloud-stealer-infection-chain/)
981
1039
-[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)
982
1040
-[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/)
0 commit comments