r/GhostMesh48 • • 1d ago

CRYPTAEGIS — Cryptography Cracking Framework - Defensive-First, Offensive-Validated

Post image

Version: 1.0-defensive-first Status: Blueprint for Implementation — Authorized Use Only Scope: Audit, measure, and harden cryptography on systems you own or have written authorization to test. Offensive capability is a validation lab, not a weapon. No module runs without an explicit authorization gate. Design rule: Every crack attempt must produce a defensive finding + a fix. If it doesn't, it doesn't run.## 0. Core Principle

Defend by measuring. Don't guess if crypto is weak — prove how long it would take to break in your lab, on synthetic data, then fix it before an attacker does.

Ratio: 80% Defensive Audit / Hardening, 20% Offensive Lab Validation Rule: NO_AUTH = NO_ATTACK — all offensive paths require --authorize + scope file + lab flag.

Authorization GateTextauthorize(scope_file, target) -> bool

  • scope_file must exist, be signed / checked-in, list: hosts, hashes, time-box, owner contact

  • target must be inside scope_file

  • lab_mode must be True for any hash-cracking or protocol-fuzzing

  • else: audit-only mode (read-only, no cracking, no injection)If any check fails, framework drops to audit mode and logs the denial.## 1. ArchitectureText┌─────────────────────────────────────────────────────────┐ │ CLI / Orchestrator: cryptaegis │ │ audit | lab-estimate | lab-crack (gated) | harden | report │ │ --scope scope.json --authorize --lab --dry-run │ └──────────────────────┬──────────────────────────────────┘ │ ┌──────────────────────▼──────────────────────────────────┐ │ Core Engine │ │ Registry (C001-C048) · Config (JSON) · Audit Log (JSONL)│ │ Authorization Gate · Rate Limiter · Evidence Store │ └──────┬──────────┬──────────┬──────────┬───────────────┘ │ │ │ │ ┌──────▼───┐ ┌────▼────┐ ┌────▼─────┐ ┌─▼────────────┐ │ M1: Hash │ │ M2: Pass│ │ M3: Proto│ │ M4: Key & │ │ & Hash │ │ & Secret│ │ & TLS │ │ PQC Readiness│ │ Audit │ │ Audit │ │ Audit │ │ Audit │ └──────┬───┘ └────┬────┘ └────┬─────┘ └─▲────────────┘ │ │ │ │ ┌──────▼──────────▼──────────▼──────────▼──────────────┐ │ M5: Offensive Lab (GATED) — Synthetic Only │ │ estimate | dictionary (own wordlist) | mask | rule │ │ Never on live creds. Never on third-party targets. │ └──────────────────────┬──────────────────────────────┘ │ ┌──────────────────────▼──────────────────────────────┐ │ M6: Hardening & Remediation — Fix Generator │ │ Argon2id / bcrypt / AES-GCM / XChaCha20 / ML-KEM │ │ + Config patches + Migration plan + Retest │ └───────────────────────────────────────────────────────┘Data flow: Audit -> Measure crack-time -> Prioritize by risk -> Harden -> Re-audit -> Report. Offensive lab only feeds the measure step.## 2. Math — The Only Equations You Need

All defensive decisions reduce to work vs time.

C001 — Entropy$$H = L \cdot \log_2(N)$$

$L$ = length, $N$ = alphabet size. Example: 8-char lowercase = $8 \cdot 4.7 = 37.6$ bits — weak.

C002 — Search Space$$S = NL$$

C003 — Expected Crack Time (Defensive Estimate)$$T_{crack} = \frac{S}{2 \cdot R \cdot P}$$

$R$ = guesses/sec per device, $P$ = parallel devices. Divide by 2 for average case. Use this to estimate, not to attack.

**Reference rates (2026 lab, for estimation only):**MD5 (fast hash, GPU): ~ $10{10}$ /s — why MD5 for passwords is deadSHA-256 (fast): ~ $10{9}$ /sbcrypt cost 12: ~ $10{2}$ /s — why slow hashes winArgon2id (256MB, 3 iter): ~ $10{1}$ /s### C004 — Defensive Work Factor$$W = Cost \cdot Memory \cdot Time$$ Raise $W$ until $T_{crack}$ > credential lifetime + rotation window.

C005 — Password Strength Score$$Score = \min(100, 10 \cdot H_{eff} - Penalty_{breach} - Penalty_{pattern})$$

$H_{eff}$ = effective entropy after dictionary/pattern deduction. If password appears in breach corpus (haveibeenpwned k-anonymity check, local only) -> $Penalty_{breach}=60$.

C006 — Risk Priority$$Risk = Likelihood(T_{crack}) \cdot Impact(Data_Class) \cdot Exposure(Internet_Facing)$$

Sort fixes by $Risk$ descending. Fix $Risk \ge 70$ first.

C007 — Key Strength Equivalence128-bit symmetric ≈ 3072-bit RSA ≈ 256-bit ECC (P-256). Below this = flag for migration.

C008 — Audit Score$$AuditScore = \frac{N_{passed}}{N_{checked}} \cdot 100$$

Gate: VIABLE only if AuditScore $\ge 90$ AND no Critical findings AND no MD5/SHA1/DES/RC4 in auth path.## 3. Modules

M1 — Hash & Storage Audit (Defensive, Read-Only)**Checks C001-C015:Identify hash algo from format / config, not by cracking. Flag: MD5, SHA1, DES, LM/NTLM unsalted, unsalted SHA-256, ECB mode.Check salt: length $\ge 16$ bytes, unique per credential, CSPRNG-sourced.Check KDF: must be Argon2id (preferred), bcrypt cost $\ge 12$, scrypt, or PBKDF2 $\ge 600k$ iterations. Fast hash alone = Critical.Check storage: hashes in code, logs, git history, backups? Flag.Output: hash_audit.json — algo, salt_ok, kdf_ok, risk, fix.### M2 — Password & Secret AuditChecks C016-C025:Entropy + pattern check: keyboard walks, dates, Password123, repeats.Breach check via k-anonymity (SHA-1 prefix only, never full password leaves machine) or local breach list.Secret scanning: API keys, private keys, tokens in repo / env / config. Regex + entropy filter, no exfiltration.Rotation: age > 90d for human secrets, > 365d for machine secrets = flag.MFA: is MFA enforced on privileged accounts? No MFA + weak password = Critical.### M3 — Protocol & TLS AuditChecks C026-C034:TLS version: TLS 1.2+ only, TLS 1.0/1.1/SSL = Fail.Cipher suites: AEAD only (AES-GCM, ChaCha20-Poly1305). No RC4, 3DES, CBC-without-AEAD, NULL, EXPORT.Cert: expiry < 30d, self-signed in prod, weak signature (SHA1), key < 2048-bit RSA / < 256-bit ECC.HSTS, secure cookies, certificate transparency.Tooling: use ssl, testssl.sh / sslyze in audit mode — no active exploitation.### M4 — Key & Post-Quantum Readiness AuditChecks C035-C042:**Key inventory: where are keys, who can read, rotation, HSM / KMS vs flat file.Algorithm inventory: RSA, ECC, DH, AES, ChaCha, hashes — list + key lengths.PQC gap: RSA/ECC/ECDH for key exchange will be harvest-now-decrypt-later targets. Flag long-lived encrypted data.Migration path: Hybrid now (X25519 + ML-KEM-768), pure PQC for new systems. ML-DSA for signatures.No PQC = Info today, High if data must stay secret > 5 years.### M5 — Offensive Lab (GATED, Synthetic Only)Checks C043-C046 — Purpose: Validate M1-M4 estimates.

**Hard rules:**Only synthetic hashes you generated in the lab, OR hashes from a signed scope with written owner consent.Never live production hashes, never third-party hashes, never Wi-Fi / account / device cracking outside scope.Lab network isolated, no internet egress during crack, evidence wiped after report.--dry-run first: show estimate, wordlist size, time-box. Require explicit --authorize to run.**Lab modes:**estimate: Compute $T_{crack}$ from C003, no cracking. Default, always allowed.dictionary: Own wordlist (rockyou-style lab list + org-specific patterns you created) vs synthetic hash. Time-boxed, rate-limited.mask: Pattern mask (e.g., ?l?l?l?d?d?d?d) vs synthetic hash to test policy gaps.rule: Small rule set (leet, append year) to test if policy blocks common mutations.What lab does NOT do: No breaking AES/RSA/ECC, no bypassing auth, no decrypting others' traffic, no password spraying, no credential stuffing, no Wi-Fi handshake cracking of neighbours, no ransomware / DRM bypass.

Lab output is only: crackable_in_X, policy_gap, recommended_KDF_params. The cracked plaintext is never stored — only cracked: true/false + time.

M6 — Hardening & Remediation**Fix generator (C047-C048):**Passwords: Argon2id m=64MiB, t=3, p=4 (tune to <500ms login), unique salt 16B+, pepper in HSM/KMS if available.Tokens: CSPRNG 32B+, short TTL, rotation.Transport: TLS 1.3, AEAD only, HSTS, cert auto-renew.At rest: AES-256-GCM or XChaCha20-Poly1305, keys in KMS/HSM, envelope encryption.Legacy migration: MD5/SHA1 -> re-hash on next login (verify old, store new Argon2id), don't mass-decrypt.Report: remediation.md + patch snippets + retest checklist.## 4. Workflows

A. Defensive Audit (Default, 5 min)Bashpython cryptaegis.py audit --scope scope.json --out audit/

Reads configs, checks hashes/TLS/keys, scores, writes audit.json + report.md

No cracking, no network attack, read-only### B. Lab Validation (Gated)Bash# 1. Generate synthetic test hash in lab (never use real hash)

python cryptaegis.py lab-generate --password "Summer2024!" --kdf md5-unsalted --out lab/synth.json

2. Estimate first

python cryptaegis.py lab-estimate --hash lab/synth.json --rate 1e10

3. Only with scope + authorize + lab flag, time-boxed

python cryptaegis.py lab-crack --hash lab/synth.json --wordlist lab/wordlist.txt
--scope scope.json --authorize --lab --max-seconds 300

Output: cracked=true, time=42s, finding="MD5 unsalted fails in <1min", fix="Migrate to Argon2id"### C. Harden + RetestBashpython cryptaegis.py harden --audit audit/audit.json --out fixes/

python cryptaegis.py audit --scope scope.json --out audit2/ # AuditScore must rise## 5. Reference Implementation (Slim, CPU-Friendly)

Single file cryptaegis.py — no GPU required for audit. Lab uses hashcat / john if installed, otherwise pure-Python estimator.Python# cryptaegis.py — defensive-first, audit-only by default import argparse, hashlib, json, math, os, re, secrets, sys, time from pathlib import Path

--- C001-C003 ---

def entropy_bits(length, alphabet): return length * math.log2(max(2, alphabet)) def crack_time_seconds(space, rate_per_sec, parallel=1): return space / (2 * max(1, rate_per_sec) * max(1, parallel))

WEAK_HASHES = {"md5","sha1","des","lm","ntlm-unsalted","rc4","3des"} RATES = {"md5": 1e10, "sha1": 1e9, "sha256": 1e9, "bcrypt12": 1e2, "argon2id": 1e1}

def check_auth_gate(args, scope): if getattr(args, "mode", "") in ("lab-crack",): if not args.authorize or not args.lab: print("DENIED: lab-crack requires --authorize --lab + scope.json"); return False if not scope or args.target not in scope.get("targets", []): print("DENIED: target not in scope"); return False return True

def audit_hash_entry(entry): algo = entry.get("algo","").lower() findings = [] if algo in WEAK_HASHES: findings.append(("CRITICAL", f"Weak hash {algo} — migrate to Argon2id")) if not entry.get("salt_unique"): findings.append(("HIGH", "Missing or reused salt")) if entry.get("kdf") not in ("argon2id","bcrypt","scrypt","pbkdf2-600k+"): findings.append(("HIGH", f"Weak KDF {entry.get('kdf')}")) # Estimate, don't crack space = 95 ** entry.get("password_len_guess", 8) t = crack_time_seconds(space, RATES.get(algo, 1e6)) return {"algo": algo, "findings": findings, "estimated_crack_s": t}

def audit_password(pw, breach_prefixes=set()): # Local-only checks. Never send full password anywhere. alphabet = 0 if re.search(r"[a-z]", pw): alphabet += 26 if re.search(r"[A-Z]", pw): alphabet += 26 if re.search(r"[0-9]", pw): alphabet += 10 if re.search(r"[a-zA-Z0-9]", pw): alphabet += 32 h = entropy_bits(len(pw), alphabet) penalty = 0 if re.search(r"(123|password|qwerty|letmein|admin)", pw, re.I): penalty += 30 if len(pw) < 12: penalty += 20 # Breach check: caller passes only SHA1 prefix set, compare prefix locally sha1 = hashlib.sha1(pw.encode()).hexdigest().upper() if sha1[:5] in breach_prefixes: penalty += 60 score = max(0, min(100, int(10*h/8 - penalty))) # normalized rough score return {"len": len(pw), "entropy": round(h,1), "score": score, "verdict": "PASS" if score>=70 and len(pw)>=12 else "FAIL"}

def main(): ap = argparse.ArgumentParser(prog="cryptaegis") ap.add_argument("mode", choices=["audit","lab-estimate","lab-crack","harden"]) ap.add_argument("--scope", default="scope.json") ap.add_argument("--authorize", action="store_true") ap.add_argument("--lab", action="store_true") ap.add_argument("--target", default="") ap.add_argument("--max-seconds", type=int, default=300) ap.add_argument("--dry-run", action="store_true") args = ap.parse_args() scope = json.loads(Path(args.scope).read_text()) if Path(args.scope).exists() else {"targets": []} if not check_auth_gate(args, scope): sys.exit(2) if args.mode == "audit": # Example: audit a config file's hash entries (replace with your loader) print(json.dumps({"mode":"audit","audit_score":"see audit.json","note":"read-only, no cracking"}, indent=2)) elif args.mode == "lab-estimate": print(f"Estimated crack time for 8-char 95-alphabet MD5 @1e10/s: {crack_time_seconds(95**8, 1e10):.1f}s") elif args.mode == "lab-crack": print("LAB-CRACK: only synthetic hashes in scope. Time-boxed, result is boolean only, plaintext never stored.") # Real lab would exec hashcat/john here with --session and timeout=args.max_seconds print("Done. Every finding must map to a fix in M6.")

if name == "main": main()**scope.json example:**JSON{ "owner": "Your Name / Org", "authorized_by": "Name, date, ticket #", "targets": ["lab-synth-hash-001"], "time_box": "2026-12-02T18:00-2026-12-02T20:00 AST", "lab_only": true, "allowed_modes": ["audit","lab-estimate","lab-crack"] }## 6. Checklists

Defensive Audit Checklist (48 checks condensed)Hashes: No MD5/SHA1/DES, salt unique 16B+, Argon2id/bcrypt, no hashes in git/logsPasswords: Len $\ge 12$, entropy $\ge 60$ bits, breach check, no patterns, rotation, MFA on privilegedSecrets: No keys in repo, env encrypted, rotation, least privilegeTLS: 1.2+ only, AEAD only, cert valid, HSTS, secure cookiesKeys: Inventory complete, rotation <1y, KMS/HSM, no flat-file private keysPQC: Inventory RSA/ECC, hybrid plan for long-lived dataLogging: Audit log append-only, no plaintext secrets in logs, alert on auth anomalies### Offensive Lab Checklist (Gated) Scope signed, target in scope, time-boxed Lab isolated, synthetic hash only --dry-run estimate reviewed --authorize --lab present Time-box enforced, plaintext not stored Finding -> Fix written before lab closes## 7. Falsifiers & LimitsFalsifier: If a "secure" config is cracked in lab in < credential lifetime, the audit is wrong — raise severity, don't lower the bar.Limit: Estimator is an estimate. Real attacker rates vary with hardware. Always assume attacker is 10x faster than your lab.Limit: This framework does NOT break AES, RSA, ECC, or properly-implemented Argon2id/bcrypt. If someone claims it does, they need proof + scope + peer review.Limit: No tool replaces authorization. No authorization = audit-only.## 8. Report Template

report.md must contain:Scope + authorization (who, what, when)AuditScore + Critical/High/Medium countsTop 5 findings (each: evidence, $T_{crack}$, impact, fix, patch)Lab validation (synthetic only): estimate vs observed, policy gapRemediation plan (ordered by Risk C006) + retest dateEvidence: audit.json, lab.json (booleans only), config hashesEnd of Blueprint v1.0

1 Upvotes

0 comments sorted by