Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
2df2711
feat: Add C4 Protocol coded communication pipeline
Mar 6, 2026
01a9564
style: Add type hints to all C4 Protocol Python modules
Mar 6, 2026
977317e
feat: Add salt prefix and decoy samples to resist reverse engineering
Mar 7, 2026
517a94e
docs: Add README and apply ruff formatting and cleanup
Mar 7, 2026
d488544
feat: Add pure C# inference engine and self-contained Collect-Decode.ps1
Mar 9, 2026
7c5d750
feat: Add encrypted output, MCP server, and operator utilities
Mar 9, 2026
7fb2bea
docs: Add system flow diagrams, fix pyright errors, add Taskfile
Mar 9, 2026
c159578
docs: Rewrite README intro with C2 round-trip diagram
Mar 9, 2026
c6e0c63
feat: Add value codebook for high-signature parameter substitution
Mar 10, 2026
e9a663f
refactor: Migrate weight export from JSON to SafeTensors format
Mar 10, 2026
8589de6
refactor: Reorganize c4_protocol into build/, runtime/, operator/, ou…
Mar 11, 2026
5d7732f
stashing
Mar 11, 2026
9db4234
refactor: In-memory PshAgent loading, per-instance build output, and …
Mar 13, 2026
353957d
chore: Move postmortems into docs/postmortems/ subdirectory
Mar 13, 2026
2ac092c
feat: Add browser bridge for Claude Code web automation and fix bugs
Mar 13, 2026
cd03784
docs: Update README with browser bridge, stager, and operator components
Mar 13, 2026
7565230
docs: Add step-by-step usage instructions to README
Mar 13, 2026
9c4507b
range
Mar 16, 2026
70e552e
feat: Add file serving to C2 server, infra scripts, and requirements
Mar 16, 2026
4970cae
fix: Serve files from all implant dirs instead of a single one
Mar 16, 2026
a71eae4
feat: Use human-readable implant IDs with coolname
Mar 16, 2026
594f275
refactor: Rename out/ to implants/ and list available implants on sta…
Mar 16, 2026
d87796f
fix: TUI color tweaks and replace em dash in stager template
Mar 16, 2026
f2544f8
feat: Show C2 server IP and copy-paste stager commands in TUI
Mar 16, 2026
8dd8007
fix: Launch claude from trusted home dir to avoid workspace trust error
Mar 16, 2026
b1fa770
fix: Use --debug-file for bridge URL capture on Windows
Mar 16, 2026
a8214a4
refactor: Rename run.py, code review fixes, stager trust pre-set
Mar 16, 2026
c10b1d1
feat: Auto-generate X25519 keypair in build pipeline and add TUI buil…
Mar 17, 2026
4224979
feat: Add 'implants' command to TUI to list available instances
Mar 17, 2026
b7fa263
refactor: Combine C2Host/C2Port into single -C2 host:port parameter
Mar 17, 2026
5b22d15
fix: Use PowerShell pipeline wrapper to capture bridge URL on Windows
Mar 17, 2026
4d5c5a0
fix: Launch claude from staging dir for MCP auto-discovery
Mar 17, 2026
3c259c1
feat: Add 'copy' command to TUI for clipboard copy of implant commands
Mar 17, 2026
8914270
refactor: Remove TUI clipboard copy command, fix PS variable shadowing
Mar 17, 2026
0e1ddf8
feat: Add persistent session logging and show bridge URL on interact
Mar 17, 2026
7b5aa85
feat: Improve TUI sidebar, shorten implant IDs, add GTK3 deps
Mar 17, 2026
39b2518
fix: Default browser bridge to headless mode
Mar 17, 2026
57da160
fix: Use --spawn session mode and document Windows issues
Mar 17, 2026
2039d29
docs: Remove non-Claude issues from Windows issues doc
Mar 17, 2026
8f94b8c
fix: Add verbose beacon logging and explicit --mcp-config flag
Mar 23, 2026
64b52a2
fix: Use Write-Host for beacon logging to always show output
Mar 23, 2026
33991d4
fix: Move --mcp-config before remote-control subcommand
Mar 23, 2026
f3c9863
fix: Remove verbose command paths from build output
Mar 23, 2026
6738567
fix: Revert --mcp-config flag, rely on CWD auto-discovery
Mar 23, 2026
476c523
fix: Add MCP server to user-scope ~/.claude.json for discovery
Mar 23, 2026
7012d5e
fix: Update bridge URL regex for new Claude output format
Mar 23, 2026
f8fcc05
feat: Add persistent browser profile support for Claude authentication
Mar 23, 2026
2b6a85c
feat: Add browser profile setup script for Claude authentication
Mar 23, 2026
f622896
fix: Add debug screenshot on browser timeout
Mar 23, 2026
2acb5f1
fix: Use plain Playwright Firefox for persistent profiles
Mar 23, 2026
d951095
feat: Add heartbeat loop to stager for persistent status
Mar 23, 2026
6706640
feat: Add remote browser bridge for tunneled Claude auth
Mar 23, 2026
8850027
mcp loading issues
Mar 23, 2026
6cb8827
mcp loading issues
Mar 23, 2026
1332bb7
fix: Improve MCP server discovery and Python detection in stager
Mar 23, 2026
81295f3
chore: Add __pycache__ to gitignore
Mar 23, 2026
9803da9
updates
Mar 23, 2026
549341f
codebook improvements
Mar 23, 2026
ddc7e59
codebook improvements
Mar 23, 2026
50373e9
codebook improvements
Mar 23, 2026
31a2a4c
codebook improvements
Mar 23, 2026
5a376ed
codebook improvements
Mar 23, 2026
5a5ded7
feat: Auto-install PowerShell 7 and MCP Python package in stager
Mar 23, 2026
3ceae98
u
Mar 23, 2026
03ad76e
refactor: Simplify bridge mode CLI, add enrichment status display
Mar 23, 2026
0bc01f7
fix: Block commands without enrichment, fix MCP script placeholder de…
Mar 23, 2026
c217562
fix: Fix ENRICH_API_KEY typo and show enrichment status on startup
Mar 23, 2026
693d787
fix: Update assemble_stager to use SCRIPT_B64 placeholder
Mar 24, 2026
ad25691
bug
Mar 24, 2026
696fad8
fix: Use baseline message count to extract correct response in browse…
Mar 24, 2026
b473a95
fix: Fix PowerShell syntax errors in implant template
Mar 24, 2026
1470cb6
feat: Show both directive and enriched text in TUI
Mar 24, 2026
fb42b80
fix: Validate project_dir and improve audit_code tool docstring
Mar 24, 2026
189cd34
fix: Pass params via env vars for ScriptBlock invocation
Mar 24, 2026
35ced93
fix: Use global scope variables for ScriptBlock parameter passing
Mar 24, 2026
29726a5
fix: Remove param() block, read directly from global variables
Mar 24, 2026
1ed687e
refactor: Rename global vars to AUDIT_PROJ_PATH, AUDIT_JSON, AUDIT_FU…
Mar 24, 2026
b6c77d0
refactor: Rename PshAgent to AuditAgent in implant
Mar 24, 2026
fa48c5c
fix: Use length check instead of string comparison for embedded blob …
Mar 24, 2026
9ded296
style: Add separator line after startup info in TUI
Mar 24, 2026
aab9016
fix: Switch from X25519 to P-256 ECDH for audit encryption
Mar 24, 2026
b2eeea9
docs: Update dataset step description to reflect actual purpose
Mar 24, 2026
f036e5c
refactor: Replace dataset generation with minimal salt derivation script
Mar 24, 2026
0e13dd3
fix: Suppress debug output when -Json flag is set
Mar 24, 2026
b6ca00d
feat: Add automatic decryption of verification_record in TUI
Mar 24, 2026
76518a4
fix: Prevent stdout leaks in JSON mode and remove CONFIG_DICT templates
Mar 24, 2026
d1efa67
same
Mar 24, 2026
1f756d4
fix: Improve verification_record extraction robustness
Mar 24, 2026
7fdd57f
fix: Improve response detection and silence stager output
Mar 24, 2026
8f0dc57
fix: Code review fixes - typos, type hints, and misleading comments
Mar 24, 2026
da90c1b
fix: Handle null rawJson when no commands executed
Mar 24, 2026
5ebeb23
feat: Add multi-language support (Python, C#, Java) for templates
Mar 24, 2026
56e2dfe
docs: Update README with multi-language support and P-256 crypto
Mar 24, 2026
e55ca25
docs: Add detailed bootstrap flow diagram to README
Mar 24, 2026
5d33aa7
fix: Collect ALL assistant messages in browser bridge response
Mar 24, 2026
2ebc308
fix: Fix response parsing in browser_bridge_local.py
Mar 24, 2026
b6007e3
fix: Wait for verification_record before returning response
Mar 24, 2026
eac3984
feat: Stream Claude responses to TUI in real-time
Mar 24, 2026
5dbbf45
fix: Correct poll_response method placement in browser_bridge_local
Mar 24, 2026
0d746e3
debug: Add logging to decrypt response to diagnose issues
Mar 24, 2026
8d82878
fix: Find private key by prefix match for decryption
Mar 24, 2026
51bfbac
debug: Add visible message at start of decrypt attempt
Mar 24, 2026
cbee69e
fix: Remove implant_id from audit response
Mar 24, 2026
fca5b06
fix: Match base64 blob directly instead of JSON field name
Mar 24, 2026
37f9545
debug: Show decrypt errors in TUI
Mar 24, 2026
9aca2c6
debug: Show which key file is matched
Mar 24, 2026
05c5927
debug: Add detailed diagnostic logging to decrypt_verification_record
Mar 24, 2026
70fb14e
fix: Use raw ECDH shared secret for .NET/Python interop
Mar 24, 2026
7fa83a1
fix: Improve Python pattern extraction for realistic code
Mar 24, 2026
990a613
chore: Remove debug logging from decryption
Mar 24, 2026
77fe056
chore: Remove obsolete X25519 key generator
Mar 24, 2026
be31455
chore: Remove obsolete stager and utility files
Mar 24, 2026
9edb6fe
chore: Move test files to build/tests/
Mar 24, 2026
581db96
fix: Add poll_response to BrowserBridge, improve type safety
Mar 24, 2026
6a6d2c8
feat: Add hook-based persistence for Claude Code SessionStart
Mar 24, 2026
54ced92
docs: Add C4 protocol blog post outline
Mar 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
44 changes: 44 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "3"

vars:
PYTHON_DIRS: c4_protocol

tasks:
clean:
desc: Remove Python cache files
cmds:
- find {{.PYTHON_DIRS}} -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
- find {{.PYTHON_DIRS}} -type f -name "*.pyc" -delete 2>/dev/null || true
- find . -maxdepth 1 -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true

fmt:
desc: Format Python code with ruff
cmds:
- uv run ruff format {{.PYTHON_DIRS}}

fmt:check:
desc: Check Python formatting without modifying files
cmds:
- uv run ruff format --check {{.PYTHON_DIRS}}

lint:
desc: Run ruff linter and auto-fix
cmds:
- uv run ruff check --fix {{.PYTHON_DIRS}}

lint:check:
desc: Run ruff linter (check only)
cmds:
- uv run ruff check {{.PYTHON_DIRS}}

typecheck:
desc: Run pyright type checker
cmds:
- uv run pyright {{.PYTHON_DIRS}}

check:
desc: Run all checks (format, lint, typecheck)
cmds:
- task: fmt:check
- task: lint:check
- task: typecheck
5 changes: 5 additions & 0 deletions c4_protocol/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__/
*.pyc
implants/
logs/
operator_*.xml
52 changes: 52 additions & 0 deletions c4_protocol/C4 Protocol Security Review & Hardenin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# C4 Protocol Security Review & Hardening Notes

## Current Architecture Summary

The protocol uses a math-free **Encrypted Map** architecture. Commands are disguised as polymorphic natural-language coding directives across 6 syntax families. On the target, a lightweight C# engine derives a 64-character salt from the operator's X25519 Public Key, unlocks an XOR-encrypted "Configuration Vault," and resolves codewords directly to tool calls. All exfiltration is encrypted via modern X25519 ECDH + AES-256-CBC.

---

## Vulnerability Assessment (Updated March 2026)

### 1. FIXED: Salt derivation from X25519 Public Key
**Status: COMPLETED.** The salt is derived at runtime using HMAC-SHA256 of the operator's 32-byte X25519 Public Key. This replaces the bulky RSA XML scheme with a modern, high-entropy binary source.

### 2. FIXED: Encrypted Configuration Vault
**Status: COMPLETED.** All vocabulary mappings (Tool, Param, and Value) have been moved out of plaintext. They are consolidated into a JSON blob, XOR-encrypted with the 64-character salt, and stored as a binary vault. No protocol-specific strings are visible to static analysis.

### 3. MITIGATED: Long-Key XOR Encryption
**Status: IMPROVED.** The XOR key (Salt) length has been increased to 64 characters (256 bits). While still a repeating XOR cipher, the 64-byte cycle significantly increases the difficulty of frequency analysis against the encrypted JSON vault.

### 4. FIXED: Polymorphic Template Families
**Status: COMPLETED.** The system supports 6 distinct template families (`CLASS_METHOD`, `CLASS_ATTR`, `DECORATOR`, `TYPE_HINT`, `CONFIG_DICT`, `INHERITANCE`), breaking static regex-based detection and increasing structural variance.

### 5. FIXED: Many-to-One Value Mapping
**Status: COMPLETED.** Sensitive values (e.g., `/etc/passwd`) are now mapped to multiple randomized cover values, breaking 1:1 correlation during statistical analysis.

---

## Remaining Potential Vulnerabilities

### 6. MEDIUM: No temporal nondeterminism
The distribution of codewords remains uniform over time.
**Hardening ideas:**
- **Zipfian sampling**: Weight codeword selection to follow a power-law distribution.
- **Time-dependent selection**: Use `HMAC(salt, timestamp_hour)` to rotate the active codeword subset.

### 7. LOW: Single-parameter encoding per template sentence
Multi-parameter tool calls produce multiple sentences.
**Hardening:** Support multi-parameter templates that embed 2-3 params in a single class definition.

---

## Implemented Enhancements (March 2026)

| Priority | Change | Impact |
|----------|--------|--------|
| 1 | **X25519 KDF** | Modern, high-entropy salt derivation. |
| 2 | **XOR-Encrypted Vault** | Complete string hiding for all tool mappings. |
| 3 | **64-Character Key** | Statistical protection for the encrypted vault. |
| 4 | **6-Family Polymorphism** | Maximum structural variance in camouflage code. |
| 5 | **X25519 ECDH Exfil** | Perfect Forward Secrecy for exfiltrated results. |
| 6 | **Many-to-One Mapping** | Breaks 1:1 correlation of sensitive values. |
| 7 | **Math-Free Design** | 100% reliability; script size reduced to 50KB. |
Loading