Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ A secure P2P chat application with dual-layer encryption (Tripolar masking + AES
- Automatic visual camouflage when surveillance detected
- Three states: SAFE (green), UNCERTAIN (yellow), ALERT (red)
- ⚠️ **Note**: When enabled, may block chat during suspicious activity detection
- **ScorpioSync Cover Traffic (Optional)**: Traffic camouflage and pattern obfuscation addon
- Periodic cover traffic to hide communication patterns
- HTTP mimicry for better blending
- Zero-width steganography (disabled by default)
- **QR Code Support**: Easy parameter sharing between peers
- **Real-time Messaging**: Instant P2P message delivery
- **Message History**: Full conversation history during session
Expand Down Expand Up @@ -126,6 +130,32 @@ Crypto Password: my_super_secret_password_2024 (same as Alice)
- Alice connects to Bob: IP = Bob's IP, Port = 55556
- Bob connects to Alice: IP = Alice's IP, Port = 55555

## 🎭 ScorpioSync Cover Traffic (Optional Addon)

**NEW**: Optional addon for traffic-level camouflage and cover traffic generation.

### Features
- **Cover Traffic Generation**: Periodic dummy packets to obfuscate communication patterns
- **HTTP Mimicry**: Format traffic to resemble normal API requests
- **Zero-Width Steganography**: Optional data hiding in Unicode characters (disabled by default)

### Configuration

Enable in `config.py`:
```python
ENABLE_COVER_TRAFFIC = True
COVER_MIN_INTERVAL_S = 20
COVER_MAX_INTERVAL_S = 45
ENABLE_HTTP_MIMICRY = True
ENABLE_ZW_STEGANO = False # Disabled by default
```

### Documentation

See [docs/ADDON_SCORPIOSYNC.md](docs/ADDON_SCORPIOSYNC.md) for complete API reference, usage examples, and integration guide.

**⚠️ Note**: All cover traffic is still encrypted through the standard crypto layer. Steganography is disabled by default for responsible use.

## 🛡️ AngelCore Surveillance Detection (Optional)

**NEW**: AngelCore is now optional and can be enabled/disabled via checkbox in the Settings tab.
Expand Down Expand Up @@ -159,6 +189,7 @@ When in ALERT mode:
5. **angelcore_spectralwatch.py**: Surveillance detection system
6. **qr_utils.py**: QR code generation and parsing
7. **neccrit_pyqt6.py**: Production PyQt6 GUI application
8. **addons/scorpiosync_***: Optional cover traffic and traffic camouflage (see docs/ADDON_SCORPIOSYNC.md)

### Security Layers

Expand Down Expand Up @@ -200,7 +231,20 @@ neccrit/
├── angelcore_spectralwatch.py # Surveillance detection
├── qr_utils.py # QR code utilities
├── entropy_seed.py # Entropy generation
├── config.py # Configuration for optional addons
├── example_cover_traffic_integration.py # Usage example
├── addons/ # Optional addons
│ ├── scorpiosync_generators_complete.py # Cover traffic generators
│ └── scorpiosync_adapter.py # Transport layer adapter
├── docs/ # Documentation
│ └── ADDON_SCORPIOSYNC.md # ScorpioSync addon guide
├── tests/ # Test suite
│ ├── test_crypto.py
│ ├── test_network_guards.py
│ ├── test_addons_generators.py # Addon generator tests
│ └── test_cover_traffic.py # Cover traffic integration tests
├── requirements.txt # Python dependencies
├── requirements-dev.txt # Development dependencies
├── README.md # This file
└── QUICKSTART.md # Quick start guide
```
Expand Down
3 changes: 3 additions & 0 deletions addons/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Addons package for n'éccrit - Optional extensions for traffic camouflage.
"""
111 changes: 111 additions & 0 deletions addons/scorpiosync_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
"""
Adapter for integrating scorpiosync generators with n'éccrit transport layer.

This module provides a bridge between the cover traffic generators and the
existing spectralship_engine_duallayer transport mechanisms.
"""
import json, random, threading, time
from typing import Optional
from .scorpiosync_generators_complete import fake_api_request_generator, http_builder_transformer, steganography_transformer


# Global state for session tracking (to be set by the application)
_active_node = None
_peer_config = None


def set_active_node(node, peer_ip: str, peer_port: int, peer_name: str):
"""
Configure the active node and peer for cover traffic transmission.

Args:
node: SpectralNode instance
peer_ip: Peer IP address
peer_port: Peer port
peer_name: Peer name
"""
global _active_node, _peer_config
_active_node = node
_peer_config = {"ip": peer_ip, "port": peer_port, "name": peer_name}


def is_session_ready() -> bool:
"""Check if a session is ready for cover traffic transmission."""
return _active_node is not None and _peer_config is not None and _active_node.running


def send_encrypted_json(frame: dict):
"""
Send a cover traffic frame via the active session.

The frame is sent as a regular spectralship message with type='cover'.
This maintains compatibility with the existing transport layer.
"""
if not is_session_ready():
raise RuntimeError("No active session available for cover traffic")

# Convert the cover frame to a message that can be sent via spectralship
# We use a minimal signal to encode just the type information
cover_msg = f"[COVER:{frame.get('type', 'cover')}]"
_active_node.send_fragment(
cover_msg,
_peer_config["ip"],
Comment on lines +49 to +52

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep cover traffic out of the chat stream

The adapter converts every cover frame to the string "[COVER:…]" and forwards it with send_fragment. On the receiving side, SpectralNode.start_listening treats any incoming fragment as a normal chat message and prints/appends it, so enabling cover traffic will spam peers with visible [COVER:cover] messages instead of silently camouflaging traffic. This defeats the purpose of the addon and advertises that cover traffic is being generated. Either embed a distinguishable frame type that the receiver can ignore or add filtering on receive so cover packets are not surfaced to users.

Useful? React with 👍 / 👎.

_peer_config["port"],
_peer_config["name"]
)


def maybe_transform_plaintext(plaintext: str, use_stegano: bool) -> str:
"""
Optionally apply steganographic transformation to plaintext.

Args:
plaintext: Input text
use_stegano: Whether to apply zero-width steganography

Returns:
Transformed or original plaintext
"""
return steganography_transformer(plaintext) if use_stegano else plaintext


def send_cover_once(use_http_mimicry: bool):
"""
Send a single cover traffic packet.

Args:
use_http_mimicry: Whether to format as HTTP request
"""
payload = fake_api_request_generator()
frame = {"type": "cover", "payload": payload, "ts": int(time.time())}
if use_http_mimicry:
# Generate HTTP-formatted bytes (for potential future use/logging)
_ = http_builder_transformer(payload, include_length_prefix=False)
send_encrypted_json(frame)


def start_cover_traffic(min_s: int, max_s: int, use_http_mimicry: bool, stop_flag: threading.Event) -> threading.Thread:
"""
Start a background thread that sends periodic cover traffic.

Args:
min_s: Minimum interval between cover packets (seconds)
max_s: Maximum interval between cover packets (seconds)
use_http_mimicry: Whether to use HTTP-mimicking format
stop_flag: Threading event to signal stop

Returns:
Thread handle for the cover traffic generator
"""
def _loop():
while not stop_flag.is_set():
if is_session_ready():
try:
send_cover_once(use_http_mimicry)
except Exception:
pass # Silently ignore errors to avoid disrupting main communication
time.sleep(random.randint(min_s, max_s))

t = threading.Thread(target=_loop, daemon=True)
t.start()
return t
39 changes: 39 additions & 0 deletions addons/scorpiosync_generators_complete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from __future__ import annotations
import json, random, secrets, string, time
from typing import Any, Dict, Optional

def _rand_string(length: int = 8) -> str:
return "".join(secrets.choice(string.ascii_letters + string.digits) for _ in range(length))

def _now_iso() -> str:
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())

def fake_api_request_generator(seed: Optional[int] = None) -> Dict[str, Any]:
if seed is not None:
random.seed(seed)
endpoints = ["/v1/users/login","/v1/items/search","/api/v2/metrics/submit"]
methods = ["POST","GET","PUT"]
endpoint = random.choice(endpoints)
method = random.choice(methods)
body = {"sample": _rand_string(6), "ts": _now_iso()}
headers = {"Host": "api.example.com", "User-Agent": "neccrit/1.0"}
return {"method": method, "endpoint": endpoint, "headers": headers, "body": body, "generated_at": _now_iso()}

def http_builder_transformer(payload: Any, host="api.example.com", include_length_prefix=True) -> bytes:
body = json.dumps(payload, separators=(",", ":"), ensure_ascii=False).encode()
header = f"POST {payload.get('endpoint','/')} HTTP/1.1\r\nHost: {host}\r\nContent-Type: application/json\r\nContent-Length: {len(body)}\r\n\r\n".encode()
req = header + body
return len(req).to_bytes(4,"big") + req if include_length_prefix else req

_ZERO_WIDTH_ONE, _ZERO_WIDTH_ZERO = "\u200B", "\u200C"
def steganography_transformer(payload: Any) -> str:
data = json.dumps(payload,separators=(",",":"),ensure_ascii=False).encode()
bits = "".join(f"{b:08b}" for b in data)
return "".join(_ZERO_WIDTH_ONE if bit=="1" else _ZERO_WIDTH_ZERO for bit in bits)

def steganography_decode(zws: str) -> str:
bits = ["1" if c==_ZERO_WIDTH_ONE else "0" for c in zws if c in (_ZERO_WIDTH_ONE,_ZERO_WIDTH_ZERO)]
bytes_out = [int("".join(bits[i:i+8]),2) for i in range(0,len(bits),8)]
return bytes(bytes_out).decode("utf-8")

__all__ = ["fake_api_request_generator","http_builder_transformer","steganography_transformer","steganography_decode"]
33 changes: 33 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Configuration file for n'éccrit optional addons.

This file contains configuration flags for optional features like
cover traffic generation, HTTP mimicry, and steganography.

⚠️ SECURITY NOTE:
- Cover traffic generation can help obfuscate communication patterns
- Zero-width steganography is DISABLED by default for responsible use
- All cover traffic is still encrypted through the standard crypto layer
"""

# Cover Traffic Configuration
# ---------------------------
# Enable periodic cover traffic to obfuscate communication patterns
ENABLE_COVER_TRAFFIC = True

# Minimum interval between cover traffic packets (seconds)
COVER_MIN_INTERVAL_S = 20

# Maximum interval between cover traffic packets (seconds)
COVER_MAX_INTERVAL_S = 45

# HTTP Mimicry
# ------------
# Format cover traffic as HTTP-like requests for better camouflage
ENABLE_HTTP_MIMICRY = True

# Zero-Width Steganography
# ------------------------
# ⚠️ DISABLED BY DEFAULT - Use responsibly for legitimate research only
# This feature embeds data in zero-width unicode characters
ENABLE_ZW_STEGANO = False
Loading
Loading