sleep-masking-dev
Auth/lab dev: sleep-state research; timers/APC/waitable timers, memory-at-rest, permission transitions, key lifecycle, reliability checks.
v2026.11.13-21cd5683 installs+3 in 7 days39 StarsMITsynced 11 hours ago
Install
No NotHoly CLI yet? Install it first.
$ curl -fsSL https://notholy.com/install.sh | sh$ notholy skills install aeondave/sleep-masking-devWrites to ~/.notholy/skills after checking the signature and the SHA-256.
SignatureSigned, ed25519
Package210e8b80…7ab9d436
210e8b80e0f4…778e7ab9d4364 files · 6.4 KBScanLow1 finding
- Links to outside domains
Sourcegithub.com/AeonDave/malskill/tree/main/offensive-coding/sleep-masking-dev@21cd568
On this page
Goal: keep dormant code/data minimally observable during idle windows while preserving execution stability across repeated cycles.
When to activate
- You need encrypt-at-sleep behavior for an in-memory agent or loader.
- You are choosing among timer-queue/APC/waitable-timer/hook-based sleep orchestration.
- Your current sleep cycle is unstable (races, crashes, deadlocks) or noisy (easy telemetry signatures).
- You need mitigation-aware design for modern Windows hardening (CET/CFG) and stronger timer/APC hunting.
Core flow model
Treat sleep masking as a state machine:
- Pre-sleep prep: optional thread gating/suspend strategy, context capture, key selection.
- Permission shift: executable -> writable (or no-access depending on pattern).
- In-memory transform: encrypt payload/critical heaps with symmetric transform.
- Dormant interval: sleep/wait primitive executes while transformed memory is non-executable.
- Restore phase: decrypt, restore permissions, restore contexts/threads.
- Post-sleep hygiene: rotate keys, wipe transient material, verify invariants.
If any transition fails, fail closed with deterministic rollback (restore permissions/context before continuing).
Sleep orchestration patterns
Timer-queue chain (Ekko-style)
- Queue staged callbacks to perform: protect RW -> encrypt -> delay -> decrypt -> protect RX.
- Strength: composable chain with clear phase boundaries.
- Risk: timer object/callback telemetry and worker-thread artifacts.
APC/context chain (Foliage-style)
- Queue context-driven callbacks (often via NtContinue/SetThreadContext pathways) for phase execution.
- Strength: flexible sequencing and context-level control.
- Risk: suspicious APC/context manipulation patterns in modern detection pipelines.
Waitable timer + ROP/context chain (Cronos-style)
- Use waitable-timer/APC completion sequencing with context or ROP-like dispatch.
- Strength: precise phase timing and chained transitions.
- Risk: fragile stack/context correctness and higher crash risk under mitigation changes.
Hooked sleep surface
- Intercept sleep entry point and route through custom encrypt-sleep-decrypt pipeline.
- Strength: easy integration in existing loops.
- Risk: hook visibility and call-path anomalies.
Memory masking patterns
- Region masking: transform code region only (lower blast radius, easier reliability).
- Heap-assisted masking: additionally mask selected heap buffers with strict tracking/untracking lifecycle.
- Memory bouncing / ghosting: encrypted backup -> free original region during sleep -> reallocate/restore/decrypt after wake. See the ghosting subsection below.
- Protection strategy: RW/RX flips are common; NOACCESS windows can reduce readable exposure but increase fault risk.
Ghosting variants
The decommit pattern is community-established (no single canonical publication — treated as no-public-lineage): NtFreeVirtualMemory(MEM_DECOMMIT) returns the pages to RESERVED, so committed-memory scanners (PE-Sieve, Moneta) see nothing where the code was; recommit on wake (NtFreeVirtualMemory semantics).
Stronger variant (field-reported, project evidence: evasion framework chrysalis/strategy.go, "Chrysalis Mode 2"):
- Encrypt the code region + tracked heap buffers in place (MBA-obfuscated XOR).
NtFreeVirtualMemory(MEM_RELEASE)— the region does not exist during sleep (stronger than decommit; nothing for a scanner to classify).- Suspend every other thread (enumerate via
NtQuerySystemInformation(SystemProcessInformation)), so no thread walks a freed mapping mid-sleep. - Sleep via
NtWaitForSingleObjectwith a relative timeout — zero timer objects, zero APCs, zero ROP chains; orchestration lives in plain code. - Reallocate (same base, any-base fallback), restore ciphertext, decrypt, re-protect RX, resume threads.
- Rotate a 16-byte key per sleep cycle; GC/runtime threads get a skip-suspension flag to avoid deadlocks (Go hosts).
Trade-offs: heavier orchestration than Ekko-style, wrong key or missing exclusion policy = hard crash; keys must come from a CSPRNG (a math/rand-seeded key is the known weakness of a real implementation).
Trampoline placement and key hygiene (2026)
- Place mask trampolines in executable image-backed sections, not private RWX (evidence: gengar
sleep_trampoline.rs— trampoline lives in a seed-named PE image section; scratch RW holds only ciphertext). A private RWX trampoline is the single loudest residual artifact of most masks. - Keys in registers: hold the cycle key in
XMM6/XMM7for the duration — never write it to memory the mask is protecting. - Integrity-checked masking (project-reported pattern, no linked qualification record): compute a MAC over the ciphertext and the masked caller stack; derive the restore key as
key XOR mac32(ciphertext). Any tamper with code or stack fails the restore → zero keys and terminate that thread instead of executing corrupted state. Turns the mask into a fail-closed tripwire rather than only concealment.
Ekko reduced (timer-as-wake-only)
Full Ekko/ROP chains are heavy and telemetry-rich (note: the original Ekko PoC restores RWX, not RX — Cracked5pider/Ekko). A reduced shape (evidence: gengar ekko.rs): use the timer queue only as the wake primitive (CreateTimerQueueTimer with WT_EXECUTEONLYONCE|WT_EXECUTEINTIMERTHREAD), perform mask/restore inline in the same thread from a seed-named image section, and resolve timer APIs from the already-mapped KernelBase — no new imports, no ROP.
Reliability-first guardrails
- Pin critical transitions to predictable thread context where needed.
- Do not suspend control/runtime-critical threads blindly; maintain exclusion policy.
- Keep per-cycle checks: base pointer validity, region size consistency, permission restoration success.
- Use bounded retries for allocation/restore paths; avoid unbounded loops in sleep pipeline.
- Keep sleep cycle idempotent: running it twice should not corrupt state.
2024-2026 landscape
- Thread-pool-timer orchestration superseded raw timer-queue chains:
CreateThreadpoolTimer/SetThreadpoolTimer,TpSetWait,RtlCreateTimer— see GhostTimer (2026, Ekko-derived, addresses Hunt-Sleeping-Beacons timer callbacks), hypnus (2025, Rust, Zilean-variant viaTpSetWait), Havoc DemonSLEEPOBF_EKKO/ZILEAN/FOLIAGE. - Sleeping Beauty II (StealthPalace, Jun 2026): CFG bypass via
NtSetInformationVirtualMemory(VmCfgCallTargetInformation)to register ROP gadgets as valid call targets, plus CET-compatible stack spoofing (preserves RIP, mirrors RSP/TIB bounds) around the sleep — the current reference for mitigation-aware masks. - Shelter (Kudaes, 2024): weaponized ROP-based mask; DeathSleep (2022): thread-termination variant, a mode the taxonomy above misses.
- Detector landscape to test against: WithSecure TickTock (timer-queue enumeration), thefLink/Hunt-Sleeping-Beacons, Moneta, pe-sieve.
Key lifecycle and anti-forensics
- Generate per-run seed and rotate per sleep cycle when feasible.
- Separate key storage from transformed region; avoid static long-lived key bytes.
- Wipe transient key material and context copies after successful restore.
- Design rollback for failed rotation (continue with last-good key only if integrity checks pass).
Mitigation-aware constraints (2026-focused)
- CET shadow stack: return-address or context-redirection assumptions can break; design flows that remain valid under stricter control-flow checks.
- CFG and call-target policies: indirect transitions must remain policy-compatible.
- Timer/APC hunting maturity: defenders increasingly correlate repeated timer/APC/context patterns with long-lived sleepers.
- Telemetry minimization: reduce repetitive, highly regular phase cadence; prefer operational jitter and bounded variability over fixed intervals.
Validation workflow
- Verify one complete cycle in debugger with explicit phase checkpoints.
- Run repeated-cycle stress (e.g., 50+ cycles) and record failures by phase.
- Validate restoration invariants after each cycle (permissions, entry pointer, key state, tracked heaps).
- Compare behavior under different sleep durations and jitter bands.
- Re-test after OS/mitigation baseline changes.
Anti-patterns
- Encrypt/decrypt without strict permission restoration checks.
- Suspending every thread without exclusion policy.
- Static keys reused indefinitely across cycles.
- Fixed phase timing with no jitter and highly repeatable API cadence.
- Treating sleep masking as “set once and forget”; it must be continuously regression-tested.
Resources
- references/flows-and-modes.md — Load when choosing the sleep pipeline shape, phase ordering, and orchestration mode.
- references/reliability-and-safety.md — Load when debugging crashes, rollback failures, race conditions, or unsafe transition order.
- references/patterns.md — Load for concrete masking patterns, permission-transition designs, and thread-handling trade-offs.
- ../linux-internals-dev/references/syscall-dispatch-linux.md — Cross-reference for Linux syscall gate patterns when adapting ideas across platforms.
Files in this version
references/34.5 KB
- flows-and-modes.md1.6 KB
- patterns.md1.4 KB
- reliability-and-safety.md1.5 KB
- SKILL.md10.1 KB
Permissions
| Permission | Declared | Found by the scan |
|---|---|---|
| Reads files | No | No |
| Writes files | No | No |
| Runs shell commands | No | No |
| Uses the network | Yes | Yes |
| Uses connectors | No | No |
| Drives a browser | No | No |
Scan findings
Reviewed on Nov 13, 2026
- InfoLink · Links to outside domains
A clean scan lowers the risk but does not prove a package is safe. Read what you install.
| Version | Published | Commit | SHA-256 | Signature | Permission change |
|---|---|---|---|---|---|
| v2026.11.13-21cd568 | Nov 13, 2026 | 21cd568 | 210e8b80 | Signed | – |
More from AeonDave
All from this publisherMore in Reporting and compliance
See the category- skillduty1g/skill5
- rea-ci-tests-auditmorluto/rea-ci-tests-audit4
- tracking-threat-actor-infrastructuremukul975/tracking-threat-actor-infrastructure4
- performing-authenticated-scan-with-openvasmukul975/performing-authenticated-scan-with-openvas4
- slicing-code-contexttrailofbits/slicing-code-context4
- 1337aeondave/13374
Ask anything your scope allows.
Create an account, add credits and ask the first question in the chat or the terminal.
- 1/3
Create the account
Individual or company. You can switch to a company later without losing balance or keys.
IndividualCompany - 2/3
Add credits
By card. Pay per token, no subscription.
$5.00minimum deposit - 3/3
Ask
In the chat, or install the CLI and run notholy login in your terminal.
$ notholy login