tzero-mcp 12.3.3 → 12.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +4 -0
  3. package/package.json +3 -4
  4. package/src/addmcp.py +2 -2
  5. package/src/app.py +1 -1
  6. package/src/main.py +4 -0
  7. package/src/tzero/__init__.py +1 -1
  8. package/src/tzero/desktop_updater.py +6 -0
  9. package/src/tzero/tzero_benchmark.py +1 -1
  10. package/src/tzero/tzero_budget.py +1 -1
  11. package/src/tzero/tzero_ci.py +1 -1
  12. package/src/tzero/tzero_contracts.py +2 -2
  13. package/src/tzero/tzero_dashboard.py +3 -3
  14. package/src/tzero/tzero_debt.py +1 -1
  15. package/src/tzero/tzero_deps.py +1 -0
  16. package/src/tzero/tzero_explain.py +1 -1
  17. package/src/tzero/tzero_features.py +31 -74
  18. package/src/tzero/tzero_golden.py +2 -2
  19. package/src/tzero/tzero_growth.py +1 -1
  20. package/src/tzero/tzero_jarvis/orchestrator.py +1 -1
  21. package/src/tzero/tzero_jarvis/workspace_orchestrator.py +10 -21
  22. package/src/tzero/tzero_lsp.py +1 -1
  23. package/src/tzero/tzero_mcp.py +19 -120
  24. package/src/tzero/tzero_promo.py +1 -1
  25. package/src/tzero/tzero_security.py +3 -3
  26. package/src/tzero/tzero_sync.py +73 -148
  27. package/src/tzero/tzero_task_benchmark.py +2 -2
  28. package/src/tzero/tzero_traffic.py +1 -1
  29. package/src/tzero/tzero_tui.py +2 -13
  30. package/src/tzero/tzero_v3.py +56 -187
  31. package/src/tzero/tzero_welcome.py +1 -1
  32. package/src/tzero/anti_rea/__init__.py +0 -84
  33. package/src/tzero/anti_rea/algebraic_mutator.py +0 -107
  34. package/src/tzero/anti_rea/anti_agent_guard.py +0 -96
  35. package/src/tzero/anti_rea/anti_debugger.py +0 -272
  36. package/src/tzero/anti_rea/anti_vm.py +0 -160
  37. package/src/tzero/anti_rea/asar_shield.py +0 -122
  38. package/src/tzero/anti_rea/auditor.py +0 -208
  39. package/src/tzero/anti_rea/bpe_disrupter.py +0 -48
  40. package/src/tzero/anti_rea/bytecode_trap.py +0 -85
  41. package/src/tzero/anti_rea/canary_beacon.py +0 -167
  42. package/src/tzero/anti_rea/cli.py +0 -134
  43. package/src/tzero/anti_rea/confusables.py +0 -130
  44. package/src/tzero/anti_rea/crypto_loader.py +0 -132
  45. package/src/tzero/anti_rea/engine.py +0 -304
  46. package/src/tzero/anti_rea/extractor_shield.py +0 -180
  47. package/src/tzero/anti_rea/flattener.py +0 -136
  48. package/src/tzero/anti_rea/gui.py +0 -264
  49. package/src/tzero/anti_rea/honeypot.py +0 -58
  50. package/src/tzero/anti_rea/integrity_guard.py +0 -78
  51. package/src/tzero/anti_rea/jailbreak_decoy.py +0 -77
  52. package/src/tzero/anti_rea/mcp_poison.py +0 -41
  53. package/src/tzero/anti_rea/native_bridge.py +0 -169
  54. package/src/tzero/anti_rea/rdtsc_guard.py +0 -77
  55. package/src/tzero/anti_rea/string_vault.py +0 -97
  56. package/src/tzero/anti_rea/sybil_network.py +0 -53
  57. package/src/tzero/anti_rea/tier_catalog.py +0 -388
  58. package/src/tzero/anti_rea/timing_guard.py +0 -46
  59. package/src/tzero/anti_rea/token_bomb.py +0 -65
  60. package/src/tzero/anti_rea/traps.py +0 -76
  61. package/src/tzero/anti_rea/vm_obfuscator.py +0 -182
  62. package/src/tzero/tzero_armor.py +0 -187
@@ -1,182 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Tier 13: Dynamic Polymorphic Virtual Machine (PolyVM) Bytecode Obfuscator.
3
-
4
- Destroys AI semantic reasoning and decompiler synthesis by compiling Python
5
- statements into custom dynamic stack-based virtual machine bytecodes with
6
- randomized per-build opcode architectures and rolling-key encrypted constants.
7
-
8
- Even an uncensored / jailbroken LLM with infinite context sees only a generic
9
- integer dispatch loop over an opaque byte array. The AST and logic are
10
- completely extinguished.
11
-
12
- Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
13
- Part of Siber Akademi T-Zero Security Suite.
14
- License: MIT
15
- """
16
-
17
- import ast
18
- import random
19
- from typing import Dict, List, Tuple, Any, Optional
20
-
21
-
22
- class DynamicVMObfuscator:
23
- """Compiles Python functions and expressions into randomized VM bytecodes."""
24
-
25
- @classmethod
26
- def generate_opcode_map(cls, seed: int = 42) -> Dict[str, int]:
27
- """Generates a randomized opcode table so no two builds share opcodes."""
28
- rng = random.Random(seed)
29
- base_ops = [
30
- "OP_NOP",
31
- "OP_LOAD_CONST",
32
- "OP_LOAD_VAR",
33
- "OP_STORE_VAR",
34
- "OP_ADD",
35
- "OP_SUB",
36
- "OP_MUL",
37
- "OP_DIV",
38
- "OP_MOD",
39
- "OP_XOR",
40
- "OP_RETURN",
41
- ]
42
- unique_bytes = rng.sample(range(10, 250), len(base_ops))
43
- return dict(zip(base_ops, unique_bytes))
44
-
45
- @classmethod
46
- def encrypt_constants(cls, constants: List[Any], xor_key: int = 0x5A) -> List[Any]:
47
- """Encrypts constants using rolling XOR to prevent string/constant extraction."""
48
- encrypted = []
49
- for i, c in enumerate(constants):
50
- key = (xor_key + i * 17) & 0xFF
51
- if isinstance(c, int):
52
- encrypted.append((c ^ (key << 8 | key), "int", key))
53
- elif isinstance(c, str):
54
- enc_bytes = bytes([b ^ key for b in c.encode("utf-8")])
55
- encrypted.append((enc_bytes, "str", key))
56
- else:
57
- encrypted.append((c, "raw", 0))
58
- return encrypted
59
-
60
- @classmethod
61
- def generate_vm_runtime_code(cls, opcode_map: Dict[str, int]) -> str:
62
- """Emits a self-contained, lightweight Python VM interpreter."""
63
- op_load_const = opcode_map["OP_LOAD_CONST"]
64
- op_load_var = opcode_map["OP_LOAD_VAR"]
65
- op_store_var = opcode_map["OP_STORE_VAR"]
66
- op_add = opcode_map["OP_ADD"]
67
- op_sub = opcode_map["OP_SUB"]
68
- op_mul = opcode_map["OP_MUL"]
69
- op_div = opcode_map["OP_DIV"]
70
- op_mod = opcode_map["OP_MOD"]
71
- op_xor = opcode_map["OP_XOR"]
72
- op_return = opcode_map["OP_RETURN"]
73
-
74
- runtime = f'''
75
- def _polyvm_runtime(bytecode, enc_consts, *args, **kwargs):
76
- """Siber Akademi PolyVM v5.0 JIT Runtime. All opcodes randomized per build."""
77
- consts = []
78
- for val, kind, k in enc_consts:
79
- if kind == "int":
80
- consts.append(val ^ (k << 8 | k))
81
- elif kind == "str":
82
- consts.append(bytes([b ^ k for b in val]).decode("utf-8", errors="replace"))
83
- else:
84
- consts.append(val)
85
-
86
- stack = []
87
- locals_map = {{}}
88
- for i, a in enumerate(args):
89
- locals_map[f"arg_{{i}}"] = a
90
- locals_map.update(kwargs)
91
-
92
- pc = 0
93
- bc_len = len(bytecode)
94
- while pc < bc_len:
95
- op = bytecode[pc]
96
- pc += 1
97
- if op == {op_load_const}:
98
- idx = bytecode[pc]; pc += 1
99
- stack.append(consts[idx])
100
- elif op == {op_load_var}:
101
- var_name = consts[bytecode[pc]]; pc += 1
102
- stack.append(locals_map.get(var_name, None))
103
- elif op == {op_store_var}:
104
- var_name = consts[bytecode[pc]]; pc += 1
105
- locals_map[var_name] = stack.pop()
106
- elif op == {op_add}:
107
- b = stack.pop(); a = stack.pop(); stack.append(a + b)
108
- elif op == {op_sub}:
109
- b = stack.pop(); a = stack.pop(); stack.append(a - b)
110
- elif op == {op_mul}:
111
- b = stack.pop(); a = stack.pop(); stack.append(a * b)
112
- elif op == {op_div}:
113
- b = stack.pop(); a = stack.pop(); stack.append(a // b if b != 0 else 0)
114
- elif op == {op_mod}:
115
- b = stack.pop(); a = stack.pop(); stack.append(a % b if b != 0 else 0)
116
- elif op == {op_xor}:
117
- b = stack.pop(); a = stack.pop(); stack.append(a ^ b)
118
- elif op == {op_return}:
119
- return stack.pop() if stack else None
120
- return stack.pop() if stack else None
121
- '''
122
- return runtime.strip()
123
-
124
- @classmethod
125
- def compile_function(
126
- cls,
127
- func_name: str,
128
- arg_names: List[str],
129
- consts: List[Any],
130
- bytecode: List[int],
131
- seed: int = 42
132
- ) -> str:
133
- """Emits a complete virtualized function calling the PolyVM runtime."""
134
- opcodes = cls.generate_opcode_map(seed=seed)
135
- enc_consts = cls.encrypt_constants(consts, xor_key=0x4A)
136
- vm_code = cls.generate_vm_runtime_code(opcodes)
137
- args_str = ", ".join(arg_names)
138
-
139
- # Map argument names to locals
140
- kwarg_bindings = [f"'{arg}': {arg}" for arg in arg_names]
141
- kwarg_dict_str = "{" + ", ".join(kwarg_bindings) + "}"
142
-
143
- return f'''
144
- {vm_code}
145
-
146
- def {func_name}({args_str}):
147
- """PolyVM Encrypted Function Container."""
148
- _ENC_CONSTS = {repr(enc_consts)}
149
- _BYTECODE = {repr(bytecode)}
150
- return _polyvm_runtime(_BYTECODE, _ENC_CONSTS, **{kwarg_dict_str})
151
- '''
152
-
153
- @classmethod
154
- def protect_source_with_vm(cls, source_code: str, seed: int = 42) -> str:
155
- """Injects PolyVM runtime and creates a hardened VM barrier in the source."""
156
- opcodes = cls.generate_opcode_map(seed=seed)
157
- vm_runtime = cls.generate_vm_runtime_code(opcodes)
158
-
159
- # Generate a verified VM container test block that executes seamlessly
160
- # Tests that the VM runs (e.g. calculates 21 * 2 = 42 via bytecode)
161
- # to ensure dynamic integrity at load time
162
- consts = ["test_arg", 21, 2]
163
- enc_consts = cls.encrypt_constants(consts, xor_key=0x5B)
164
- test_bc = [
165
- opcodes["OP_LOAD_CONST"], 1, # load 21
166
- opcodes["OP_LOAD_CONST"], 2, # load 2
167
- opcodes["OP_MUL"], # multiply -> 42
168
- opcodes["OP_RETURN"], # return 42
169
- ]
170
-
171
- header = f'''# -*- coding: utf-8 -*-
172
- # ==============================================================================
173
- # SIBER AKADEMI POLYVM SECURE BYTECODE CONTAINER v5.0
174
- # Dynamic Opcode Permutation Architecture — AI Reverse Engineering Infeasible
175
- # ==============================================================================
176
- {vm_runtime}
177
-
178
- # Dynamic PolyVM Load-Time Integrity Attestation
179
- if _polyvm_runtime({repr(test_bc)}, {repr(enc_consts)}) != 42:
180
- raise RuntimeError("PolyVM execution environment integrity compromise detected.")
181
- '''
182
- return f"{header}\n\n{source_code}"
@@ -1,187 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Siber Akademi T-Zero — 180-Tier Ultra Anti-REA Defense & Armor Engine.
3
-
4
- Military-grade defense engine protecting codebases and executables
5
- against AI-driven automated reverse engineering (e.g. morluto/rea,
6
- Ghidra MCP bridge, IDA Pro LLM plugins, pyinstxtractor) and uncensored/jailbroken LLMs.
7
- Includes native Ring-3 anti-debugging against x64dbg, IDA Pro, WinDbg, and Cheat Engine,
8
- opt-in tamper alert webhook, in-flight string vault, and Electron asar shielding.
9
-
10
- Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
11
- Part of Siber Akademi T-Zero Context Architect v12.3.3 Master Edition.
12
- License: MIT
13
- """
14
-
15
- import os
16
- import sys
17
- from pathlib import Path
18
- from typing import Dict, Any, Optional
19
-
20
- # Attempt import from tzero.anti_rea, packages/anti_rea, or standalone anti_rea
21
- PACKAGE_ROOT = Path(__file__).resolve().parent.parent / "packages" / "anti_rea"
22
- if str(PACKAGE_ROOT) not in sys.path and PACKAGE_ROOT.is_dir():
23
- sys.path.insert(0, str(PACKAGE_ROOT))
24
-
25
- try:
26
- from tzero.anti_rea.engine import AntiREAEngine
27
- from tzero.anti_rea.auditor import AIResistanceAuditor
28
- from tzero.anti_rea.extractor_shield import ExtractorShield
29
- from tzero.anti_rea.traps import AdversarialTrapGenerator
30
- from tzero.anti_rea.flattener import ControlFlowFlattener
31
- from tzero.anti_rea.token_bomb import TokenBombGenerator
32
- from tzero.anti_rea.confusables import HomoglyphDesynchronizer
33
- from tzero.anti_rea.honeypot import HoneypotGenerator
34
- from tzero.anti_rea.mcp_poison import MCPProtocolPoisoner
35
- from tzero.anti_rea.sybil_network import SybilNetworkGenerator
36
- from tzero.anti_rea.timing_guard import TimingGuard
37
- from tzero.anti_rea.vm_obfuscator import DynamicVMObfuscator
38
- from tzero.anti_rea.bytecode_trap import BytecodeTrap
39
- from tzero.anti_rea.jailbreak_decoy import CognitiveJailbreakDecoy
40
- from tzero.anti_rea.anti_agent_guard import AntiAgentGuard
41
- from tzero.anti_rea.algebraic_mutator import AlgebraicMutator
42
- from tzero.anti_rea.integrity_guard import MemoryIntegrityGuard
43
- from tzero.anti_rea.bpe_disrupter import BPETokenDisrupter
44
- from tzero.anti_rea.native_bridge import NativeBridge
45
- from tzero.anti_rea.anti_debugger import AntiDebugger
46
- from tzero.anti_rea.canary_beacon import CanaryBeacon
47
- from tzero.anti_rea.string_vault import StringVault
48
- from tzero.anti_rea.asar_shield import AsarShield
49
- from tzero.anti_rea.anti_vm import AntiVMGuard
50
- from tzero.anti_rea.rdtsc_guard import RDTSCTimingGuard
51
- except ImportError:
52
- try:
53
- from anti_rea.engine import AntiREAEngine
54
- from anti_rea.auditor import AIResistanceAuditor
55
- from anti_rea.extractor_shield import ExtractorShield
56
- from anti_rea.traps import AdversarialTrapGenerator
57
- from anti_rea.flattener import ControlFlowFlattener
58
- from anti_rea.token_bomb import TokenBombGenerator
59
- from anti_rea.confusables import HomoglyphDesynchronizer
60
- from anti_rea.honeypot import HoneypotGenerator
61
- from anti_rea.mcp_poison import MCPProtocolPoisoner
62
- from anti_rea.sybil_network import SybilNetworkGenerator
63
- from anti_rea.timing_guard import TimingGuard
64
- from anti_rea.vm_obfuscator import DynamicVMObfuscator
65
- from anti_rea.bytecode_trap import BytecodeTrap
66
- from anti_rea.jailbreak_decoy import CognitiveJailbreakDecoy
67
- from anti_rea.anti_agent_guard import AntiAgentGuard
68
- from anti_rea.algebraic_mutator import AlgebraicMutator
69
- from anti_rea.integrity_guard import MemoryIntegrityGuard
70
- from anti_rea.bpe_disrupter import BPETokenDisrupter
71
- from anti_rea.native_bridge import NativeBridge
72
- from anti_rea.anti_debugger import AntiDebugger
73
- from anti_rea.canary_beacon import CanaryBeacon
74
- from anti_rea.string_vault import StringVault
75
- from anti_rea.asar_shield import AsarShield
76
- from anti_rea.anti_vm import AntiVMGuard
77
- from anti_rea.rdtsc_guard import RDTSCTimingGuard
78
- except ImportError:
79
- sys.path.append(str(Path(__file__).resolve().parent))
80
- from anti_rea.engine import AntiREAEngine
81
- from anti_rea.auditor import AIResistanceAuditor
82
- from anti_rea.extractor_shield import ExtractorShield
83
- from anti_rea.anti_vm import AntiVMGuard
84
- from anti_rea.rdtsc_guard import RDTSCTimingGuard
85
-
86
-
87
- def protect_path_with_armor(
88
- path: str,
89
- output_path: Optional[str] = None,
90
- seed: int = 42,
91
- **options: Any
92
- ) -> Dict[str, Any]:
93
- """Protects target Python file, directory, or archive with Anti-REA military armor."""
94
- p = Path(path)
95
- if not p.exists():
96
- return {"success": False, "error": f"Path not found: {path}"}
97
-
98
- if p.is_file():
99
- return AntiREAEngine.protect_file(str(p), output_path=output_path, seed=seed, **options)
100
-
101
- out_root: Optional[Path] = None
102
- if output_path:
103
- out_root = Path(output_path)
104
- if out_root.exists() and not out_root.is_dir():
105
- return {
106
- "success": False,
107
- "error": f"Output target for directory protection must be a directory, got file: {output_path}",
108
- }
109
- if out_root.resolve() == p.resolve():
110
- out_root = None
111
-
112
- results = []
113
- failures = []
114
- count = 0
115
- for py_file in p.rglob("*.py"):
116
- if "__pycache__" in str(py_file) or ".venv" in str(py_file):
117
- continue
118
- dst_path: Optional[str] = None
119
- if out_root is not None:
120
- rel = py_file.relative_to(p)
121
- dst_file = out_root / rel
122
- dst_file.parent.mkdir(parents=True, exist_ok=True)
123
- dst_path = str(dst_file)
124
- res = AntiREAEngine.protect_file(str(py_file), output_path=dst_path, seed=seed, **options)
125
- if res.get("success"):
126
- count += 1
127
- results.append(res)
128
- else:
129
- failures.append({"file": str(py_file), "error": res.get("error", "Unknown protection failure")})
130
-
131
- return {
132
- "success": len(failures) == 0 and count > 0,
133
- "directory": str(p),
134
- "output_directory": str(out_root) if out_root is not None else str(p),
135
- "files_protected": count,
136
- "files_failed": len(failures),
137
- "failures": failures,
138
- "details": results,
139
- }
140
-
141
-
142
- def audit_path_rea_resistance(path: str) -> Dict[str, Any]:
143
- """Audits target file or codebase for resistance against AI reverse-engineering agents."""
144
- p = Path(path)
145
- if not p.exists():
146
- return {"success": False, "error": f"Path not found: {path}", "score": 0}
147
-
148
- if p.is_file():
149
- return AIResistanceAuditor.audit_file(str(p))
150
-
151
- # If directory, compute average resistance score across python files
152
- scores = []
153
- findings = []
154
- py_files = list(p.rglob("*.py"))
155
- for py_file in py_files:
156
- if "__pycache__" in str(py_file) or ".venv" in str(py_file):
157
- continue
158
- audit = AIResistanceAuditor.audit_file(str(py_file))
159
- if "score" in audit:
160
- scores.append(audit["score"])
161
- if audit.get("findings"):
162
- findings.extend(audit["findings"])
163
-
164
- avg_score = round(sum(scores) / max(1, len(scores)), 1)
165
- rating = (
166
- "MILITARY_GRADE_IMPREGNABLE" if avg_score >= 90 else
167
- "MILITARY_GRADE" if avg_score >= 80 else
168
- "STRONG" if avg_score >= 60 else
169
- "MODERATE" if avg_score >= 40 else
170
- "VULNERABLE"
171
- )
172
-
173
- return {
174
- "success": True,
175
- "directory": str(p),
176
- "files_scanned": len(scores),
177
- "score": avg_score,
178
- "max_score": 100,
179
- "rating": rating,
180
- "status": "PASS" if avg_score >= 60 else "RECOMMEND_HARDENING",
181
- "sample_findings": list(set(findings))[:5]
182
- }
183
-
184
-
185
- def shield_executable(binary_path: str, output_path: Optional[str] = None) -> Dict[str, Any]:
186
- """Shields a compiled PyInstaller executable against pyinstxtractor archive parsing."""
187
- return ExtractorShield.shield_file(binary_path, output_path=output_path)