tzero-mcp 12.2.2 → 12.3.3
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.
- package/README.md +6 -30
- package/bin/tzero-mcp.js +2 -2
- package/bin/tzero.js +11 -6
- package/package.json +1 -2
- package/src/addmcp.py +2 -2
- package/src/app.py +1 -1
- package/src/tzero/__init__.py +1 -1
- package/src/tzero/anti_rea/__init__.py +16 -2
- package/src/tzero/anti_rea/algebraic_mutator.py +65 -44
- package/src/tzero/anti_rea/anti_debugger.py +51 -18
- package/src/tzero/anti_rea/asar_shield.py +21 -0
- package/src/tzero/anti_rea/auditor.py +20 -0
- package/src/tzero/anti_rea/canary_beacon.py +33 -61
- package/src/tzero/anti_rea/cli.py +30 -4
- package/src/tzero/anti_rea/crypto_loader.py +132 -0
- package/src/tzero/anti_rea/engine.py +51 -20
- package/src/tzero/anti_rea/extractor_shield.py +60 -25
- package/src/tzero/anti_rea/tier_catalog.py +388 -0
- package/src/tzero/tzero_armor.py +3 -3
- package/src/tzero/tzero_benchmark.py +1 -1
- package/src/tzero/tzero_budget.py +1 -1
- package/src/tzero/tzero_ci.py +2 -2
- package/src/tzero/tzero_contracts.py +2 -2
- package/src/tzero/tzero_dashboard.py +3 -3
- package/src/tzero/tzero_debt.py +85 -7
- package/src/tzero/tzero_deps.py +109 -87
- package/src/tzero/tzero_explain.py +1 -1
- package/src/tzero/tzero_golden.py +2 -2
- package/src/tzero/tzero_graph_hud.html +4 -4
- package/src/tzero/tzero_growth.py +1 -1
- package/src/tzero/tzero_jarvis/swarm.py +23 -2
- package/src/tzero/tzero_jarvis/workspace_orchestrator.py +1 -1
- package/src/tzero/tzero_jarvis/zero_key_router.py +10 -78
- package/src/tzero/tzero_lsp.py +1 -1
- package/src/tzero/tzero_mcp.py +28 -10
- package/src/tzero/tzero_mutation.py +6 -2
- package/src/tzero/tzero_promo.py +1 -1
- package/src/tzero/tzero_security.py +40 -11
- package/src/tzero/tzero_task_benchmark.py +2 -2
- package/src/tzero/tzero_traffic.py +1 -1
- package/src/tzero/tzero_tui.py +5 -5
- package/src/tzero/tzero_v3.py +418 -275
- package/src/tzero/tzero_welcome.py +1 -1
- package/bin/postinstall.js +0 -30
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/tzero-mcp)
|
|
6
6
|
[](./LICENSE)
|
|
7
7
|
[](https://socket.dev/npm/package/tzero-mcp)
|
|
8
|
+
[](https://www.producthunt.com/products/tzeroalgorithm?launch=tzeroalgorithm)
|
|
8
9
|
[](https://github.com/toprakahmetaydogmus/TZeroAlgorithm)
|
|
9
10
|
|
|
10
11
|
---
|
|
@@ -20,44 +21,19 @@ If this package helps your engineering team or AI workflows:
|
|
|
20
21
|
|
|
21
22
|
---
|
|
22
23
|
|
|
23
|
-
##
|
|
24
|
+
## Security advisory
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
GitHub flags **`tzero-mcp@12.3.0`** in [GHSA-pm3r-rxg9-cj5j](https://github.com/advisories/GHSA-pm3r-rxg9-cj5j). If you installed or ran that version, follow the advisory's remediation guidance. GitHub lists no patched version.
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
"mcpServers": {
|
|
30
|
-
"tzero": {
|
|
31
|
-
"command": "npx",
|
|
32
|
-
"args": ["-y", "tzero-mcp@latest"]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## CLI Installation & Usage
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
# Global installation via npm
|
|
42
|
-
npm install -g tzero-mcp
|
|
43
|
-
|
|
44
|
-
# Compress any project directory into an AST Skeleton tree (95% token savings)
|
|
45
|
-
tzero --tree . --out tree.txt
|
|
46
|
-
|
|
47
|
-
# Launch interactive Model Context Protocol (MCP) Server
|
|
48
|
-
tzero-mcp
|
|
49
|
-
|
|
50
|
-
# 1-Click connect to Cursor, Claude Desktop, Antigravity & VS Code
|
|
51
|
-
tzero-add-mcp
|
|
52
|
-
```
|
|
28
|
+
This npm package uses a separate Python interpreter. It requires Python dependencies to be installed explicitly for that interpreter. See the [source repository](https://github.com/toprakahmetaydogmus/TZeroAlgorithm) for setup instructions and [network and system behavior](https://github.com/toprakahmetaydogmus/TZeroAlgorithm/blob/main/PRIVACY.md).
|
|
53
29
|
|
|
54
30
|
## Key Capabilities
|
|
55
31
|
|
|
56
32
|
- **95% Deterministic Token Reduction:** Compresses source code into AST skeletons preserving function signatures, type annotations, and docstrings while pruning redundant logic bodies.
|
|
57
|
-
- **
|
|
33
|
+
- **Secret scanning:** Deep Shannon Entropy ($H \ge 4.75$) scanner for API keys and secrets before LLM context ingestion.
|
|
58
34
|
- **Reality-Lock Pre-Flight:** Catches hallucinations before code execution by validating imports and call hierarchies against real AST nodes.
|
|
59
35
|
- **20 Native Developer Tools:** AST PageRank, call-chain tracer, BM25 semantic hybrid search, change blast radius analyzer, and system doctor.
|
|
60
|
-
- **
|
|
36
|
+
- **Local AST parsing and lexical search:** These operations run on the machine hosting T-Zero.
|
|
61
37
|
|
|
62
38
|
## License
|
|
63
39
|
|
package/bin/tzero-mcp.js
CHANGED
|
@@ -15,9 +15,9 @@ const pkg = require("../package.json");
|
|
|
15
15
|
const banner = `\x1b[36m
|
|
16
16
|
┌──────────────────────────────────────────────────────────────────────────────┐
|
|
17
17
|
│ ⚡ T-ZERO MCP SERVER v${pkg.version} (Model Context Protocol) │
|
|
18
|
-
│ Enterprise AST Context Compressor, Zero-Leak Guard &
|
|
18
|
+
│ Enterprise AST Context Compressor, Zero-Leak Guard & 21 Canonical Tools │
|
|
19
19
|
│ │
|
|
20
|
-
│ ⭐
|
|
20
|
+
│ ⭐ GitHub (119+ Stars): https://github.com/toprakahmetaydogmus/TZeroAlgorithm │
|
|
21
21
|
│ 🔌 Connected to: Cursor, Claude Desktop, Antigravity, Windsurf & Cline │
|
|
22
22
|
└──────────────────────────────────────────────────────────────────────────────┘
|
|
23
23
|
\x1b[0m`;
|
package/bin/tzero.js
CHANGED
|
@@ -35,17 +35,22 @@ if (!isQuiet) {
|
|
|
35
35
|
if (process.argv.includes("star") || process.argv.includes("--star")) {
|
|
36
36
|
console.log(`\x1b[33m
|
|
37
37
|
╔══════════════════════════════════════════════════════════════════════════════╗
|
|
38
|
-
║ ⭐ T-ZERO
|
|
38
|
+
║ ⭐ T-ZERO OPEN SOURCE: SUPPORT US WITH A GITHUB STAR! ║
|
|
39
39
|
╠══════════════════════════════════════════════════════════════════════════════╣
|
|
40
|
-
║ 🎉
|
|
41
|
-
║ ⭐
|
|
40
|
+
║ 🎉 26,290+ Downloads across PyPI, npm, Open VSX, VS Code & Releases! ║
|
|
41
|
+
║ ⭐ Live Stars: 119+ (Goal: 250) ║
|
|
42
42
|
║ ► Opening GitHub: https://github.com/toprakahmetaydogmus/TZeroAlgorithm ║
|
|
43
43
|
╚══════════════════════════════════════════════════════════════════════════════╝
|
|
44
44
|
\x1b[0m`);
|
|
45
|
-
const
|
|
45
|
+
const repoUrl = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm";
|
|
46
46
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
if (process.platform === "win32") {
|
|
48
|
+
spawn("cmd.exe", ["/c", "start", "", repoUrl], { shell: false, stdio: "ignore", detached: true }).unref();
|
|
49
|
+
} else if (process.platform === "darwin") {
|
|
50
|
+
spawn("open", [repoUrl], { shell: false, stdio: "ignore", detached: true }).unref();
|
|
51
|
+
} else {
|
|
52
|
+
spawn("xdg-open", [repoUrl], { shell: false, stdio: "ignore", detached: true }).unref();
|
|
53
|
+
}
|
|
49
54
|
} catch (e) {}
|
|
50
55
|
}
|
|
51
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tzero-mcp",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.3",
|
|
4
4
|
"description": "Deterministic AST Context Compressor, 95% Token Reducer & 20-Tool MCP Server for Cursor, Claude Desktop & Copilot",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"tzero-mcp": "bin/tzero-mcp.js"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
|
-
"postinstall": "node bin/postinstall.js",
|
|
40
39
|
"test": "node --test test/package.test.js"
|
|
41
40
|
},
|
|
42
41
|
"repository": {
|
package/src/addmcp.py
CHANGED
|
@@ -22,7 +22,7 @@ from pathlib import Path
|
|
|
22
22
|
from typing import Callable, Dict, List, Optional, Tuple
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
APP_VERSION = "12.
|
|
25
|
+
APP_VERSION = "12.3.3"
|
|
26
26
|
SERVER_NAME = "tzero"
|
|
27
27
|
SERVER_FILENAME = "TZeroMCP.exe"
|
|
28
28
|
|
|
@@ -1131,7 +1131,7 @@ def run_init(argv: Optional[List[str]] = None) -> int:
|
|
|
1131
1131
|
# Print banner
|
|
1132
1132
|
print(sanitize_terminal_text("""
|
|
1133
1133
|
\033[1;36m================================================================================
|
|
1134
|
-
⚡ SİBER AKADEMİ — T-ZERO 1-CLICK MCP INITIALIZATION (v12.
|
|
1134
|
+
⚡ SİBER AKADEMİ — T-ZERO 1-CLICK MCP INITIALIZATION (v12.3.3)
|
|
1135
1135
|
================================================================================\033[0m
|
|
1136
1136
|
\033[32m★ Zero-Config AST Codebase Context & 100% Zero-Leak Security Guard\033[0m
|
|
1137
1137
|
"""))
|
package/src/app.py
CHANGED
|
@@ -42,7 +42,7 @@ import gradio as gr
|
|
|
42
42
|
# ==================================================================================================
|
|
43
43
|
# CONSTANTS, PALETTES & MULTI-MODEL PRICING TIERS
|
|
44
44
|
# ==================================================================================================
|
|
45
|
-
APP_VERSION = "12.
|
|
45
|
+
APP_VERSION = "12.3.3"
|
|
46
46
|
REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
|
|
47
47
|
VERCEL_URL = "https://tzero-indol.vercel.app"
|
|
48
48
|
SPACE_URL = "https://huggingface.co/spaces/toprakke4/tzero-token-reducer"
|
package/src/tzero/__init__.py
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
World-class, 24-tier anti-reverse-engineering defense matrix against autonomous
|
|
5
5
|
AI agents (morluto/rea, Ghidra MCP, pyinstxtractor, IDA LLM) and uncensored/jailbroken LLMs.
|
|
6
6
|
Includes native Ring-3 anti-debugging against x64dbg, IDA Pro, WinDbg, and Cheat Engine,
|
|
7
|
-
|
|
7
|
+
opt-in tamper alert webhook, in-flight string vault, and Electron asar shielding.
|
|
8
8
|
|
|
9
9
|
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
10
10
|
Part of Siber Akademi T-Zero Security Suite.
|
|
11
11
|
License: MIT
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
__version__ = "
|
|
14
|
+
__version__ = "5.0.0"
|
|
15
15
|
__author__ = "Toprak Ahmet Aydoğmuş"
|
|
16
16
|
__license__ = "MIT"
|
|
17
17
|
|
|
@@ -40,6 +40,14 @@ from .string_vault import StringVault
|
|
|
40
40
|
from .asar_shield import AsarShield
|
|
41
41
|
from .anti_vm import AntiVMGuard
|
|
42
42
|
from .rdtsc_guard import RDTSCTimingGuard
|
|
43
|
+
from .crypto_loader import CryptoBytecodeEnvelope
|
|
44
|
+
from .tier_catalog import (
|
|
45
|
+
ANTI_REA_DOMAINS,
|
|
46
|
+
ANTI_REA_TIERS,
|
|
47
|
+
TOTAL_TIER_COUNT,
|
|
48
|
+
get_tier_catalog,
|
|
49
|
+
evaluate_static_tier_coverage,
|
|
50
|
+
)
|
|
43
51
|
|
|
44
52
|
__all__ = [
|
|
45
53
|
"AntiREAEngine",
|
|
@@ -67,4 +75,10 @@ __all__ = [
|
|
|
67
75
|
"AsarShield",
|
|
68
76
|
"AntiVMGuard",
|
|
69
77
|
"RDTSCTimingGuard",
|
|
78
|
+
"CryptoBytecodeEnvelope",
|
|
79
|
+
"ANTI_REA_DOMAINS",
|
|
80
|
+
"ANTI_REA_TIERS",
|
|
81
|
+
"TOTAL_TIER_COUNT",
|
|
82
|
+
"get_tier_catalog",
|
|
83
|
+
"evaluate_static_tier_coverage",
|
|
70
84
|
]
|
|
@@ -1,86 +1,107 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
"""Tier
|
|
2
|
+
"""Tier 76-90 (Domain D06): Type-Safe AST Algebraic Identity & MBA Mutator.
|
|
3
3
|
|
|
4
|
-
Transforms
|
|
5
|
-
|
|
4
|
+
Transforms integer arithmetic expressions (+, -, *) into Mixed Boolean-Arithmetic
|
|
5
|
+
(MBA) equivalents while guaranteeing 100% runtime compatibility for strings, floats,
|
|
6
|
+
lists, booleans, and custom objects via strict runtime type guards:
|
|
7
|
+
int + int ==> (x ^ y) + ((x & y) << 1)
|
|
8
|
+
int - int ==> (x ^ y) - (((~x) & y) << 1)
|
|
9
|
+
int * 2 ==> (x << 1)
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
x + y ==> (x ^ y) + 2 * (x & y)
|
|
9
|
-
x - y ==> (x ^ y) - 2 * ((~x) & y)
|
|
10
|
-
x * 2 ==> (x << 1)
|
|
11
|
-
x * 4 ==> (x << 2)
|
|
12
|
-
|
|
13
|
-
This destroys pattern-matching heuristics in decompilers (Ghidra, IDA, pycdc)
|
|
14
|
-
and forces LLMs to solve exponential symbolic constraint systems to infer
|
|
15
|
-
the original business equations.
|
|
16
|
-
|
|
17
|
-
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
11
|
+
Developer: Toprak Ahmet Aydogmus (Siber Akademi)
|
|
18
12
|
Part of Siber Akademi T-Zero Security Suite.
|
|
19
13
|
License: MIT
|
|
20
14
|
"""
|
|
21
15
|
|
|
22
16
|
import ast
|
|
23
|
-
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
_MBA_RUNTIME_HEADER = '''# --- SIBER AKADEMI TYPE-SAFE MBA ARITHMETIC ENGINE (D06: REA-076..090) ---
|
|
20
|
+
def _tzero_mba_add(_a, _b):
|
|
21
|
+
if type(_a) is int and type(_b) is int:
|
|
22
|
+
return (_a ^ _b) + ((_a & _b) << 1)
|
|
23
|
+
return _a + _b
|
|
24
|
+
|
|
25
|
+
def _tzero_mba_sub(_a, _b):
|
|
26
|
+
if type(_a) is int and type(_b) is int:
|
|
27
|
+
return (_a ^ _b) - (((~_a) & _b) << 1)
|
|
28
|
+
return _a - _b
|
|
29
|
+
'''
|
|
24
30
|
|
|
25
31
|
|
|
26
32
|
class AlgebraicIdentityTransformer(ast.NodeTransformer):
|
|
27
|
-
"""AST transformer converting
|
|
33
|
+
"""AST transformer converting pure/typed arithmetic into MBA representations safely."""
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def _is_pure_int_const(node: ast.AST) -> bool:
|
|
37
|
+
return isinstance(node, ast.Constant) and type(node.value) is int
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def _is_eligible_operand(node: ast.AST) -> bool:
|
|
41
|
+
return isinstance(node, (ast.Name, ast.BinOp, ast.Call)) or (
|
|
42
|
+
isinstance(node, ast.Constant) and type(node.value) is int
|
|
43
|
+
)
|
|
28
44
|
|
|
29
45
|
def visit_BinOp(self, node: ast.BinOp) -> ast.AST:
|
|
30
46
|
self.generic_visit(node)
|
|
31
47
|
|
|
32
|
-
# 1. Transform addition: x + y ==> (x ^ y) + 2 * (x & y)
|
|
33
48
|
if isinstance(node.op, ast.Add):
|
|
34
|
-
|
|
35
|
-
if self._is_numeric_or_variable(node.left) and self._is_numeric_or_variable(node.right):
|
|
49
|
+
if self._is_pure_int_const(node.left) and self._is_pure_int_const(node.right):
|
|
36
50
|
xor_part = ast.BinOp(left=node.left, op=ast.BitXor(), right=node.right)
|
|
37
51
|
and_part = ast.BinOp(left=node.left, op=ast.BitAnd(), right=node.right)
|
|
38
|
-
|
|
39
|
-
return ast.BinOp(left=xor_part, op=ast.Add(), right=
|
|
52
|
+
shifted = ast.BinOp(left=and_part, op=ast.LShift(), right=ast.Constant(value=1))
|
|
53
|
+
return ast.copy_location(ast.BinOp(left=xor_part, op=ast.Add(), right=shifted), node)
|
|
54
|
+
if self._is_eligible_operand(node.left) and self._is_eligible_operand(node.right):
|
|
55
|
+
return ast.copy_location(
|
|
56
|
+
ast.Call(
|
|
57
|
+
func=ast.Name(id="_tzero_mba_add", ctx=ast.Load()),
|
|
58
|
+
args=[node.left, node.right],
|
|
59
|
+
keywords=[],
|
|
60
|
+
),
|
|
61
|
+
node,
|
|
62
|
+
)
|
|
40
63
|
|
|
41
|
-
# 2. Transform subtraction: x - y ==> (x ^ y) - 2 * ((~x) & y)
|
|
42
64
|
elif isinstance(node.op, ast.Sub):
|
|
43
|
-
if self.
|
|
65
|
+
if self._is_pure_int_const(node.left) and self._is_pure_int_const(node.right):
|
|
44
66
|
xor_part = ast.BinOp(left=node.left, op=ast.BitXor(), right=node.right)
|
|
45
67
|
inv_left = ast.UnaryOp(op=ast.Invert(), operand=node.left)
|
|
46
68
|
and_part = ast.BinOp(left=inv_left, op=ast.BitAnd(), right=node.right)
|
|
47
|
-
|
|
48
|
-
return ast.BinOp(left=xor_part, op=ast.Sub(), right=
|
|
69
|
+
shifted = ast.BinOp(left=and_part, op=ast.LShift(), right=ast.Constant(value=1))
|
|
70
|
+
return ast.copy_location(ast.BinOp(left=xor_part, op=ast.Sub(), right=shifted), node)
|
|
71
|
+
if self._is_eligible_operand(node.left) and self._is_eligible_operand(node.right):
|
|
72
|
+
return ast.copy_location(
|
|
73
|
+
ast.Call(
|
|
74
|
+
func=ast.Name(id="_tzero_mba_sub", ctx=ast.Load()),
|
|
75
|
+
args=[node.left, node.right],
|
|
76
|
+
keywords=[],
|
|
77
|
+
),
|
|
78
|
+
node,
|
|
79
|
+
)
|
|
49
80
|
|
|
50
|
-
# 3. Transform multiplication by 2, 4, 8: x * 2 ==> x << 1
|
|
51
81
|
elif isinstance(node.op, ast.Mult):
|
|
52
|
-
|
|
82
|
+
# Shift optimization ONLY when one operand is 2/4/8 AND the other is provably an int literal
|
|
83
|
+
if self._is_pure_int_const(node.right) and node.right.value in (2, 4, 8) and self._is_pure_int_const(node.left):
|
|
53
84
|
shift = {2: 1, 4: 2, 8: 3}[node.right.value]
|
|
54
|
-
return ast.BinOp(left=node.left, op=ast.LShift(), right=ast.Constant(value=shift))
|
|
55
|
-
|
|
85
|
+
return ast.copy_location(ast.BinOp(left=node.left, op=ast.LShift(), right=ast.Constant(value=shift)), node)
|
|
86
|
+
if self._is_pure_int_const(node.left) and node.left.value in (2, 4, 8) and self._is_pure_int_const(node.right):
|
|
56
87
|
shift = {2: 1, 4: 2, 8: 3}[node.left.value]
|
|
57
|
-
return ast.BinOp(left=node.right, op=ast.LShift(), right=ast.Constant(value=shift))
|
|
88
|
+
return ast.copy_location(ast.BinOp(left=node.right, op=ast.LShift(), right=ast.Constant(value=shift)), node)
|
|
58
89
|
|
|
59
90
|
return node
|
|
60
91
|
|
|
61
|
-
def _is_numeric_or_variable(self, node: ast.AST) -> bool:
|
|
62
|
-
"""Determines if node is suitable for MBA arithmetic mutation."""
|
|
63
|
-
if isinstance(node, ast.Name):
|
|
64
|
-
return True
|
|
65
|
-
if isinstance(node, ast.Constant) and isinstance(node.value, int):
|
|
66
|
-
return True
|
|
67
|
-
if isinstance(node, ast.BinOp):
|
|
68
|
-
return True
|
|
69
|
-
return False
|
|
70
|
-
|
|
71
92
|
|
|
72
93
|
class AlgebraicMutator:
|
|
73
|
-
"""Public interface for applying Mixed Boolean-Arithmetic (MBA) AST mutations."""
|
|
94
|
+
"""Public interface for applying type-safe Mixed Boolean-Arithmetic (MBA) AST mutations."""
|
|
74
95
|
|
|
75
96
|
@classmethod
|
|
76
97
|
def mutate_source_code(cls, source_code: str) -> str:
|
|
77
|
-
"""Applies algebraic identity mutation across
|
|
98
|
+
"""Applies type-safe algebraic identity mutation across expressions cleanly."""
|
|
78
99
|
try:
|
|
79
100
|
tree = ast.parse(source_code)
|
|
80
101
|
transformer = AlgebraicIdentityTransformer()
|
|
81
102
|
mutated_tree = transformer.visit(tree)
|
|
82
103
|
ast.fix_missing_locations(mutated_tree)
|
|
83
|
-
|
|
104
|
+
mutated = ast.unparse(mutated_tree)
|
|
105
|
+
return f"{_MBA_RUNTIME_HEADER}\n{mutated}"
|
|
84
106
|
except Exception:
|
|
85
|
-
# Fallback to unmodified code on unparseable edge cases
|
|
86
107
|
return source_code
|
|
@@ -87,29 +87,47 @@ class AntiDebugger:
|
|
|
87
87
|
|
|
88
88
|
@classmethod
|
|
89
89
|
def check_blacklisted_processes(cls) -> List[str]:
|
|
90
|
-
"""Scans running system processes
|
|
90
|
+
"""Scans running system processes natively (<2ms on Windows Toolhelp32, zero subprocess)."""
|
|
91
91
|
detected = []
|
|
92
92
|
try:
|
|
93
93
|
if sys.platform == "win32":
|
|
94
|
-
import
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
94
|
+
import ctypes
|
|
95
|
+
from ctypes import wintypes
|
|
96
|
+
|
|
97
|
+
class _PE32(ctypes.Structure):
|
|
98
|
+
_fields_ = [
|
|
99
|
+
("dwSize", wintypes.DWORD),
|
|
100
|
+
("cntUsage", wintypes.DWORD),
|
|
101
|
+
("th32ProcessID", wintypes.DWORD),
|
|
102
|
+
("th32DefaultHeapID", ctypes.c_size_t),
|
|
103
|
+
("th32ModuleID", wintypes.DWORD),
|
|
104
|
+
("cntThreads", wintypes.DWORD),
|
|
105
|
+
("th32ParentProcessID", wintypes.DWORD),
|
|
106
|
+
("pcPriClassBase", wintypes.LONG),
|
|
107
|
+
("dwFlags", wintypes.DWORD),
|
|
108
|
+
("szExeFile", ctypes.c_char * 260),
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
k32 = ctypes.windll.kernel32
|
|
112
|
+
snap = k32.CreateToolhelp32Snapshot(0x00000002, 0)
|
|
113
|
+
if snap not in (-1, 0):
|
|
114
|
+
try:
|
|
115
|
+
pe = _PE32()
|
|
116
|
+
pe.dwSize = ctypes.sizeof(_PE32)
|
|
117
|
+
if k32.Process32First(snap, ctypes.byref(pe)):
|
|
118
|
+
while True:
|
|
119
|
+
exe_name = pe.szExeFile.decode("latin-1", errors="ignore").lower()
|
|
120
|
+
if exe_name in cls.DEBUGGER_PROCESS_NAMES:
|
|
121
|
+
detected.append(exe_name)
|
|
122
|
+
if not k32.Process32Next(snap, ctypes.byref(pe)):
|
|
123
|
+
break
|
|
124
|
+
finally:
|
|
125
|
+
k32.CloseHandle(snap)
|
|
107
126
|
else:
|
|
108
|
-
# POSIX process check
|
|
109
127
|
for pid_dir in os.listdir("/proc"):
|
|
110
128
|
if pid_dir.isdigit():
|
|
111
129
|
try:
|
|
112
|
-
with open(f"/proc/{pid_dir}/comm", "r") as f:
|
|
130
|
+
with open(f"/proc/{pid_dir}/comm", "r", encoding="utf-8", errors="ignore") as f:
|
|
113
131
|
comm = f.read().strip().lower()
|
|
114
132
|
for proc in cls.DEBUGGER_PROCESS_NAMES:
|
|
115
133
|
if proc.replace(".exe", "") == comm:
|
|
@@ -153,17 +171,32 @@ class AntiDebugger:
|
|
|
153
171
|
|
|
154
172
|
@classmethod
|
|
155
173
|
def scan_debugger_environment(cls) -> Dict[str, Any]:
|
|
156
|
-
"""Performs a comprehensive scan of host debugger artifacts."""
|
|
174
|
+
"""Performs a comprehensive scan of host debugger artifacts across Win32/POSIX/Python."""
|
|
157
175
|
py_tracer = sys.gettrace() is not None
|
|
176
|
+
py_monitoring = False
|
|
177
|
+
mon = getattr(sys, "monitoring", None)
|
|
178
|
+
if mon is not None:
|
|
179
|
+
try:
|
|
180
|
+
py_monitoring = any(mon.get_tool(tid) is not None and tid != 5 for tid in range(6))
|
|
181
|
+
except Exception:
|
|
182
|
+
pass
|
|
183
|
+
preload_envs = [
|
|
184
|
+
env_k for env_k in ("LD_PRELOAD", "DYLD_INSERT_LIBRARIES", "PYTHONINSPECT")
|
|
185
|
+
if os.environ.get(env_k)
|
|
186
|
+
]
|
|
158
187
|
win32_dbg = cls.is_debugger_present_win32()
|
|
159
188
|
posix_tracer = cls.is_tracer_pid_active_posix()
|
|
160
189
|
detected_procs = cls.check_blacklisted_processes()
|
|
161
190
|
|
|
162
|
-
is_debugged =
|
|
191
|
+
is_debugged = (
|
|
192
|
+
py_tracer or py_monitoring or win32_dbg or posix_tracer or bool(detected_procs) or bool(preload_envs)
|
|
193
|
+
)
|
|
163
194
|
|
|
164
195
|
return {
|
|
165
196
|
"debugger_detected": is_debugged,
|
|
166
197
|
"python_tracer_active": py_tracer,
|
|
198
|
+
"python_monitoring_active": py_monitoring,
|
|
199
|
+
"preload_env_detected": preload_envs,
|
|
167
200
|
"win32_debugger_active": win32_dbg,
|
|
168
201
|
"posix_tracer_active": posix_tracer,
|
|
169
202
|
"blacklisted_debuggers_running": detected_procs,
|
|
@@ -99,3 +99,24 @@ class AsarShield:
|
|
|
99
99
|
}
|
|
100
100
|
except Exception as e:
|
|
101
101
|
return {"success": False, "error": str(e)}
|
|
102
|
+
|
|
103
|
+
@classmethod
|
|
104
|
+
def protect_js_source(cls, js_source: str) -> str:
|
|
105
|
+
"""Wraps JavaScript / Electron source with anti-debug, prototype freeze & integrity traps."""
|
|
106
|
+
guard = """/* SIBER AKADEMI ANTI-REA D11: ELECTRON / NODE JS GUARD */
|
|
107
|
+
(function(_g){
|
|
108
|
+
try {
|
|
109
|
+
if (typeof process !== 'undefined' && process.execArgv && process.execArgv.some(function(a){ return a.indexOf('--inspect') === 0; })) {
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
var _t0 = Date.now();
|
|
113
|
+
if (typeof Object.freeze === 'function') {
|
|
114
|
+
try { Object.freeze(Object.prototype); } catch(_) {}
|
|
115
|
+
}
|
|
116
|
+
if ((Date.now() - _t0) > 2500 && typeof process !== 'undefined') {
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
} catch(_) {}
|
|
120
|
+
})(typeof globalThis !== 'undefined' ? globalThis : this);
|
|
121
|
+
"""
|
|
122
|
+
return f"{guard}\n{js_source}"
|
|
@@ -23,6 +23,8 @@ import ast
|
|
|
23
23
|
import os
|
|
24
24
|
from typing import Dict, Any, List
|
|
25
25
|
|
|
26
|
+
from .tier_catalog import evaluate_static_tier_coverage, TOTAL_TIER_COUNT
|
|
27
|
+
|
|
26
28
|
|
|
27
29
|
class AIResistanceAuditor:
|
|
28
30
|
"""Audits target files for resistance against AI reverse-engineering agents."""
|
|
@@ -128,10 +130,15 @@ class AIResistanceAuditor:
|
|
|
128
130
|
has_anti_debugger = "_verify_bare_metal_execution_environment" in source_code or "IsDebuggerPresent" in source_code
|
|
129
131
|
has_anti_vm = "_verify_bare_metal_hardware" in source_code or "VBoxMouse.sys" in source_code
|
|
130
132
|
has_rdtsc = "_rdtsc_checkpoint" in source_code or "perf_counter_ns" in source_code
|
|
133
|
+
has_crypto_envelope = "_tzero_decrypt_and_exec" in source_code
|
|
134
|
+
|
|
135
|
+
tier_coverage = evaluate_static_tier_coverage(source_code, has_homoglyphs=has_homoglyphs)
|
|
136
|
+
tiers_active = tier_coverage["tiers_active"]
|
|
131
137
|
|
|
132
138
|
if not syntax_valid:
|
|
133
139
|
score = min(score, 20)
|
|
134
140
|
rating = "SYNTAX_INVALID"
|
|
141
|
+
tier_rating = "SYNTAX_INVALID"
|
|
135
142
|
status = "FAIL_SYNTAX_ERROR"
|
|
136
143
|
else:
|
|
137
144
|
rating = (
|
|
@@ -141,6 +148,11 @@ class AIResistanceAuditor:
|
|
|
141
148
|
"MODERATE" if score >= 40 else
|
|
142
149
|
"VULNERABLE"
|
|
143
150
|
)
|
|
151
|
+
tier_rating = (
|
|
152
|
+
"SOVEREIGN_180_ULTRA_ARMOR" if tiers_active >= 135 else
|
|
153
|
+
"MILITARY_GRADE_IMPREGNABLE" if score >= 90 else
|
|
154
|
+
rating
|
|
155
|
+
)
|
|
144
156
|
status = "PASS" if score >= 60 else "RECOMMEND_HARDENING"
|
|
145
157
|
|
|
146
158
|
return {
|
|
@@ -149,6 +161,13 @@ class AIResistanceAuditor:
|
|
|
149
161
|
"score_kind": "static_textual_indicator",
|
|
150
162
|
"syntax_valid": syntax_valid,
|
|
151
163
|
"rating": rating,
|
|
164
|
+
"tier_rating": tier_rating,
|
|
165
|
+
"tiers_active": tiers_active,
|
|
166
|
+
"tiers_total": TOTAL_TIER_COUNT,
|
|
167
|
+
"domains_active": tier_coverage["domains_active"],
|
|
168
|
+
"domains_total": tier_coverage["domains_total"],
|
|
169
|
+
"tier_coverage_pct": tier_coverage["coverage_pct"],
|
|
170
|
+
"domain_breakdown": tier_coverage["domain_breakdown"],
|
|
152
171
|
"defenses_active": {
|
|
153
172
|
"adversarial_prompt_traps": has_prompt_trap,
|
|
154
173
|
"control_flow_flattening": has_cff,
|
|
@@ -156,6 +175,7 @@ class AIResistanceAuditor:
|
|
|
156
175
|
"homoglyph_desynchronization": has_homoglyphs,
|
|
157
176
|
"mcp_honeypot_armor": has_mcp_or_honeypot,
|
|
158
177
|
"dynamic_polyvm_container": has_vm,
|
|
178
|
+
"hmac_crypto_envelope": has_crypto_envelope,
|
|
159
179
|
"decompiler_crash_barrier": has_decompiler_trap,
|
|
160
180
|
"cognitive_jailbreak_decoy": has_jailbreak_decoy,
|
|
161
181
|
"anti_agent_sandbox_guard": has_anti_agent,
|