19 Commits

Author SHA1 Message Date
Simone Licitra 53db225f03 docs: update for Initialize export, evasion fixes, and in-memory loading model
- TOOLCHAIN.md §3c: crystal-loader now ~42 KB, exports Initialize, RW→RX,
  -s + --gc-sections flags, no identifying strings
- TOOLCHAIN.md §3d: crystal-exec now ~75 KB, gen_pico_header.py replaces xxd,
  XOR-encrypted embedded PICO, same evasion properties as §3c
- RUNBOOK.md §1.1: correct DLL sizes (42/75 KB)
- RUNBOOK.md §3: add Defender surface note — DLLs load in-memory via Sliver,
  PICO file from upload IS on disk and visible to scanner
- RUNBOOK.md §4: note crystal-exec DLL is in-memory, PICO XOR-encrypted at build
- README.md: fix RWX→RW+RX description, update verified table sizes/export,
  fix default-jdk → openjdk-17-jdk in quick build

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 09:35:19 -04:00
Simone Licitra f908321ebf fix: evade Win64/MeterBof.A — rename go export, strip BOF strings, fix RWX
- Rename exported symbol go → Initialize in both crystal-loader.c and
  crystal-exec.c; update extension.json entrypoint accordingly.
  The go(char*, uint32_t, callback) export is the primary MeterBof.A
  static signature — renaming it removes the match.
- Remove all [crystal-loader] / [crystal-exec] / PICO-identifying string
  literals from both DLLs; replace with short generic error strings.
- Fix crystal-loader.c VirtualAlloc(PAGE_EXECUTE_READWRITE) → VirtualAlloc(RW)
  + VirtualProtect(RX); no RWX mapping ever held (same fix applied to
  crystal-exec.c in previous commit).
- Add -s / -ffunction-sections / -fdata-sections / --gc-sections to
  wrapper/Makefile; crystal-loader.x64.dll shrinks from ~232 KB to 42 KB.
2026-06-12 09:23:27 -04:00
Simone Licitra 17c62ecceb fix: crystal-exec evasion — XOR-encrypted PICO, RW→RX, strip symbols
- Replace VirtualAlloc(PAGE_EXECUTE_READWRITE) with VirtualAlloc(RW) +
  VirtualProtect(RX) after XOR decryption — no RWX mapping ever held
- Add gen_pico_header.py: XOR-encrypts the embedded PICO with a fresh
  256-byte random key each build, replacing plain xxd output. Crystal Palace
  byte patterns in .data are now obfuscated; each build is unique.
- Add -s (strip symbols), -ffunction-sections/-fdata-sections, --gc-sections
  to Makefile — DLL shrinks from ~328 KB to ~76 KB
2026-06-12 09:17:06 -04:00
Simone Licitra 12d6eccd9d docs: fix Java version requirement — openjdk-17-jdk, warn about Java 21
- Change all apt install commands from default-jdk to openjdk-17-jdk;
  default-jdk on current Kali/Ubuntu pulls Java 21 which breaks
  crystalpalace.jar with NoSuchMethodError
- Fix RUNBOOK.md verify step: ">= 11" → "must be 17"
- TOOLCHAIN.md tools table: mark Java 17 as exact requirement
- TOOLCHAIN.md section 7: add Java version gotcha with fix command
2026-06-12 08:44:23 -04:00
Simone Licitra c12e286db5 docs: fix stale sizes, add missing crystal-exec build step
- Add `make -C crystal-exec all` to README quick build, RUNBOOK Phase 1.1
  build steps, and quick smoke test — without it pack-extension.sh fails
  because crystal-exec.x64.dll is missing from the tarball
- Update crystal-loader.x64.dll verified size: 114 KB → ~232 KB (grew after
  post-ex ExitThread and loader fixes were merged)
- Add crystal-exec.x64.dll verified size: ~328 KB (was undocumented)
- Fix stager "~60 KB" placeholder in bundle-stager.sh and stager/Makefile:
  actual built size is ~17 KB
- RUNBOOK Phase 1.1: add explicit note that both DLLs must exist before
  running pack-extension.sh
2026-06-12 08:37:02 -04:00
Simone Licitra 74b0d2ed1b feat: two-file stager with AES-256-CBC evasion (bypasses Wacatac.B!ml + ZomBytes.B)
- Redesign stager as two-file delivery: csvchelper.exe (~17 KB) + payload.dat
  (AES-256-CBC encrypted PICO). Removes the 36 MB high-entropy .data blob that
  triggered VirTool:Win64/ZomBytes.B static detection.
- Replace XOR+NtCreateSection approach with BCryptDecrypt (AES-256-CBC) +
  VirtualAlloc(RW)/VirtualProtect(RX). No Nt* strings in .rdata, no
  PAGE_EXECUTE_READWRITE mapping, no GetProcAddress/ntdll pattern.
- Add manifest.xml (asInvoker, RT_MANIFEST resource ID 1) to suppress UAC
  auto-elevation triggered by "Update"/"Service" keywords in FileDescription.
- Update FileDescription in resource.rc to avoid UAC heuristic trigger words.
- gen_payload.py now calls openssl for AES encryption; produces payload.dat +
  payload_key.h (key+IV, compiled in, never committed via .gitignore).
- Makefile: add -s (strip symbols), -ffunction-sections/-fdata-sections,
  --gc-sections to keep binary clean and small.
- Update all docs (RUNBOOK, TOOLCHAIN, README, crystal-kit-sliver/README)
  to reflect two-file delivery, new evasion profile, and UAC fix.
2026-06-11 16:46:46 -04:00
Simone Licitra e29d8abbc8 feat: RoguePlanet-inspired stager evasion (NtSection + XOR + Poseidon)
Three techniques from RoguePlanet research applied to the stager:

1. NtCreateSection + NtMapViewOfSection instead of VirtualAlloc
   - VirtualAlloc absent from IAT entirely
   - Nt* resolved at runtime via GetProcAddress (not in IAT)
   - RW view written/decrypted, then unmapped
   - Separate RX view mapped for execution — no mapping is ever RWX

2. XOR-encrypted PICO (gen_payload.py, 256-byte random key per build)
   - Crystal Palace byte patterns invisible to static scanner
   - Fresh key every build: unique .data section per compile
   - Decrypted in the RW section view before RX remap

3. Poseidon I/O noise (BCryptGenRandom write to temp file)
   - Writes 4KB of random data to a temp file, deletes on close
   - Adds bcrypt.dll to IAT (legitimate app pattern)
   - Creates file I/O activity before execution, disrupts
     timing-based behavioural scanners

IAT: ADVAPI32, bcrypt, KERNEL32 — VirtualAlloc gone.
2026-06-11 16:12:25 -04:00
Simone Licitra 9f6124015a feat: custom stager with embedded PICO (RW→RX, no run.x64.exe)
Replaces the Crystal Palace demo run.x64.exe stager which triggers
Defender Wacatac.B!ml. Root cause: run.x64.exe does a naked
ReadFile+VirtualAlloc(RWX)+execute — the pattern with highest ML
feature weight in Defender's loader heuristic.

New stager (stager/stager.c):
- PICO embedded as byte array at compile time via xxd (no ReadFile)
- VirtualAlloc(RW) → RtlMoveMemory → VirtualProtect(RX): no RWX
- WinMain entry: GUI subsystem, no console window
- RegOpenKeyExW/RegCloseKey: adds advapi32 to import table, widening
  it beyond the naked kernel32-only set typical of shellcode launchers
- Version info resource (resource.rc): plausible PE identity, customize
  CompanyName/FileDescription/OriginalFilename before delivery
- Single file on disk: deliver stager.exe, nothing else

Build:
  ./bundle-stager.sh build/sliver.crystal.bin build/csvchelper.exe

Verified: clean compile, Windows GUI subsystem, import table has
ADVAPI32 + KERNEL32, no PAGE_EXECUTE_READWRITE in any section.

pico_payload.h and crystalexec_pico.h added to .gitignore — generated
build artifacts (xxd output), never commit.
2026-06-11 16:04:49 -04:00
Simone Licitra b2fb507097 fix: sed multi-line continuation inside single quotes breaks on shell
The backslash at the end of the sed pattern line was inside single
quotes. The shell treats it as a literal backslash, not a line
continuation; sed then sees \<newline> as an unterminated address
regex. Collapse both substitutions onto one sed invocation.
2026-06-11 15:56:26 -04:00
Simone Licitra 43e8370953 Merge pull request #2 from licitrasimone/feature-post-ex
feat: Crystal Palace post-ex evasion for Sliver (Use case B + crystal-exec)
2026-06-11 21:52:50 +02:00
Simone Licitra cb59516ddf feat: add crystal-exec command and update all docs
- crystal-exec: new Sliver extension command that runs shell commands
  through Crystal Palace evasion (Draugr, AMSI bypass, XOR mask,
  cleanup). The post-ex DLL (crystalexec.c) is CRT-free / kernel32-only
  and embedded as a byte array inside crystal-exec.x64.dll — no PICO
  file to upload.

- crystal-exec uses a single callback model: all output accumulated into
  a 4MB heap buffer, exactly one callback() call at the end. Sliver only
  displays the first callback invocation; multiple calls are silently
  dropped.

- Output channel: anonymous pipe (no disk artifact). 30-second PICO
  timeout, 10-second reader drain.

- Extension manifest updated with crystal-exec command entry.
  pack-extension.sh updated to include crystal-exec.x64.dll.

- Docs: RUNBOOK Phase 3 rewritten (correct --payload syntax, | runtime
  args, postex.sh workflow); Phase 4 added for crystal-exec. TOOLCHAIN
  section 3d documents 4-step build pipeline and CRT-free constraint.
  Both READMEs updated with Use case C, new layout entries, and verified
  table.
2026-06-11 15:45:01 -04:00
Simone Licitra c273333845 Merge pull request #1 from licitrasimone/feature-post-ex
Improve post-ex functionality and fix sliver bug
2026-06-11 11:16:45 +02:00
Simone Licitra 178e468bdc Merge branch 'main' into feature-post-ex 2026-06-11 11:16:26 +02:00
Simone Licitra b5b72df378 fix: Delete 2026-06-11 11:12:26 +02:00
Simone Licitra 4086ae3e68 fix: some bug with sliver 2026-06-11 04:18:32 -04:00
licitrasimone 4da921b69a feat: trying to do post-ex better 2026-06-10 21:42:42 +02:00
Simone Licitra 4f169ce0cf fix: Update README to mark task 6d as completed 2026-06-02 17:43:51 +02:00
licitrasimone 1ea15255e6 feat: rystal Palace evasion kit ported to Sliver C2 2026-05-14 08:50:51 +02:00
licitrasimone d528fecf9d first commit 2026-05-12 14:34:28 +02:00