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,180 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Tier 1: Extractor & Archive Poisoning (Anti-pyinstxtractor).
3
-
4
- Target: Automated PyInstaller archive extractors used by REA and AI agents.
5
- PyInstaller archives contain a table of contents (TOC) and magic cookie
6
- ('MEI\\014\\013\\012\\013\\016'). While standard extractors read sequentially
7
- from the cookie forward, the native C bootloader reads archive offsets
8
- from the End of File (EOF) trailer struct.
9
-
10
- This module mutates non-essential archive header bytes and injects decoy
11
- cookies so that pyinstxtractor raises IndexError or ValueError while the
12
- executable runs without issue.
13
-
14
- Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
15
- """
16
-
17
- import os
18
- import struct
19
- from typing import Dict, Any, List, Tuple, Optional
20
-
21
-
22
- PYINSTALLER_COOKIE = b"MEI\014\013\012\013\016"
23
- PYINSTALLER_COOKIE_LEN = len(PYINSTALLER_COOKIE)
24
-
25
-
26
- class ExtractorShield:
27
- """Hardens executables against automated PyInstaller extraction scripts."""
28
-
29
- @classmethod
30
- def scan_cookie(cls, binary_data: bytes) -> List[int]:
31
- """Locates all occurrences of PyInstaller cookie in binary data."""
32
- offsets = []
33
- pos = 0
34
- while True:
35
- idx = binary_data.find(PYINSTALLER_COOKIE, pos)
36
- if idx == -1:
37
- break
38
- offsets.append(idx)
39
- pos = idx + 1
40
- return offsets
41
-
42
- @classmethod
43
- def _find_all_pe_slack_offsets(cls, data_array: bytearray, max_offset: int, max_caves: int = 4) -> List[int]:
44
- """Locates unused all-zero PE section alignment caves before the CArchive overlay."""
45
- if len(data_array) < 0x100 or data_array[:2] != b"MZ":
46
- return []
47
- found: List[int] = []
48
- try:
49
- e_lfanew = struct.unpack_from("<I", data_array, 0x3C)[0]
50
- if e_lfanew + 24 > len(data_array) or data_array[e_lfanew:e_lfanew + 4] != b"PE\x00\x00":
51
- return []
52
- num_sec = struct.unpack_from("<H", data_array, e_lfanew + 6)[0]
53
- opt_size = struct.unpack_from("<H", data_array, e_lfanew + 20)[0]
54
- sec_off = e_lfanew + 24 + opt_size
55
- if sec_off + num_sec * 40 > len(data_array):
56
- return []
57
- preferred = (".rdata", ".rsrc", ".pdata", ".fptable", ".data")
58
- for i in range(num_sec):
59
- s = sec_off + i * 40
60
- name = data_array[s:s + 8].rstrip(b"\x00").decode("ascii", errors="ignore")
61
- vsize, _vaddr, rsize, rptr = struct.unpack_from("<IIII", data_array, s + 8)
62
- if name in preferred and rsize > vsize + 32:
63
- slack_start = rptr + ((vsize + 15) & ~15)
64
- slack_end = min(rptr + rsize, max_offset)
65
- if slack_end - slack_start >= 32:
66
- zero_idx = data_array[slack_start:slack_end].find(b"\x00" * 32)
67
- if zero_idx != -1:
68
- found.append(slack_start + zero_idx)
69
- if len(found) >= max_caves:
70
- break
71
- except Exception:
72
- return found
73
- return found
74
-
75
- @classmethod
76
- def _scrub_pe_toolchain_metadata(cls, data_array: bytearray) -> int:
77
- """Zeroes MSVC Rich/DanS header & COFF TimeDateStamp cleanly without altering sections."""
78
- scrubbed = 0
79
- if len(data_array) < 0x100 or data_array[:2] != b"MZ":
80
- return 0
81
- try:
82
- e_lfanew = struct.unpack_from("<I", data_array, 0x3C)[0]
83
- if e_lfanew + 24 > len(data_array) or data_array[e_lfanew:e_lfanew + 4] != b"PE\x00\x00":
84
- return 0
85
- # Zero MSVC Rich header between 0x80 and e_lfanew if present
86
- if e_lfanew > 0x80 and b"Rich" in data_array[0x80:e_lfanew]:
87
- for pos in range(0x80, e_lfanew):
88
- data_array[pos] = 0
89
- scrubbed += 1
90
- # Zero COFF TimeDateStamp (offset +8 from PE\0\0)
91
- ts_off = e_lfanew + 8
92
- if any(data_array[ts_off:ts_off + 4]):
93
- data_array[ts_off:ts_off + 4] = b"\x00\x00\x00\x00"
94
- scrubbed += 1
95
- except Exception:
96
- pass
97
- return scrubbed
98
-
99
- @classmethod
100
- def _find_pe_slack_offset(cls, data_array: bytearray, max_offset: int) -> int:
101
- caves = cls._find_all_pe_slack_offsets(data_array, max_offset, max_caves=1)
102
- return caves[0] if caves else -1
103
-
104
- @classmethod
105
- def shield_binary_bytes(cls, binary_data: bytes) -> Tuple[bytes, Dict[str, Any]]:
106
- """Applies multi-cave decoy cookie injection & PE metadata scrubbing without corrupting runtime."""
107
- offsets = cls.scan_cookie(binary_data)
108
- if not offsets:
109
- return binary_data, {
110
- "shielded": False,
111
- "reason": "PyInstaller cookie not found (pure native or already shielded)"
112
- }
113
-
114
- data_array = bytearray(binary_data)
115
- mutations_applied = 0
116
- is_pe = len(data_array) >= 0x100 and data_array[:2] == b"MZ"
117
- pe_scrubs = cls._scrub_pe_toolchain_metadata(data_array) if is_pe else 0
118
-
119
- for cookie_offset in offsets:
120
- padding_start = max(0, cookie_offset - 128)
121
- padding_chunk = data_array[padding_start:cookie_offset]
122
-
123
- decoy_offsets: List[int] = []
124
- zero_idx = padding_chunk.find(b"\x00" * 32)
125
- if zero_idx != -1:
126
- decoy_offsets.append(padding_start + zero_idx)
127
-
128
- if not decoy_offsets and is_pe:
129
- pkg_start = cookie_offset
130
- if cookie_offset + 12 <= len(data_array):
131
- try:
132
- pkg_len = struct.unpack_from(">I", data_array, cookie_offset + 8)[0]
133
- trailer_end = min(len(data_array), cookie_offset + 88)
134
- if 0 < pkg_len <= trailer_end:
135
- pkg_start = trailer_end - pkg_len
136
- except Exception:
137
- pass
138
- decoy_offsets.extend(
139
- cls._find_all_pe_slack_offsets(data_array, min(cookie_offset, pkg_start), max_caves=4)
140
- )
141
-
142
- for decoy_offset in decoy_offsets:
143
- if decoy_offset != -1 and decoy_offset + PYINSTALLER_COOKIE_LEN + 8 <= cookie_offset:
144
- data_array[decoy_offset:decoy_offset + PYINSTALLER_COOKIE_LEN] = PYINSTALLER_COOKIE
145
- corrupted_header = struct.pack(">II", 0xFFFFFFFF, 0x00000000)
146
- data_array[decoy_offset + PYINSTALLER_COOKIE_LEN:decoy_offset + PYINSTALLER_COOKIE_LEN + 8] = corrupted_header
147
- mutations_applied += 1
148
-
149
- return bytes(data_array), {
150
- "shielded": mutations_applied > 0,
151
- "cookies_found": len(offsets),
152
- "decoy_traps_injected": mutations_applied,
153
- "pe_metadata_scrubbed": pe_scrubs,
154
- "status": "EXTRACTOR_POISONED" if mutations_applied > 0 else "SKIPPED"
155
- }
156
-
157
- @classmethod
158
- def shield_file(cls, file_path: str, output_path: Optional[str] = None) -> Dict[str, Any]:
159
- """Shields a compiled executable file on disk against pyinstxtractor."""
160
- if not os.path.isfile(file_path):
161
- return {"success": False, "error": f"File not found: {file_path}"}
162
-
163
- with open(file_path, "rb") as f:
164
- content = f.read()
165
-
166
- shielded_content, meta = cls.shield_binary_bytes(content)
167
- target_path = output_path or file_path
168
-
169
- if meta.get("shielded"):
170
- with open(target_path, "wb") as f:
171
- f.write(shielded_content)
172
- meta["output_path"] = target_path
173
- meta["success"] = True
174
- return meta
175
-
176
- return {"success": False, "reason": meta.get("reason", "No mutations applied")}
177
-
178
-
179
- # Type alias helper
180
- List_Int = list
@@ -1,136 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Tier 4: Polymorphic AST Control-Flow Flattening (CFF) with Opaque Invariants.
3
-
4
- Transforms linear Python AST statements into an event-driven state machine
5
- wrapped inside an infinite loop and conditional dispatcher.
6
- State transitions are governed by mathematically invariant opaque predicates
7
- (e.g., n*(n+1) is always even, n^2 mod 4 in {0, 1}).
8
- To decompiler lifting engines and LLMs, the function becomes an unstructured
9
- spaghetti graph with no perceptible semantic flow.
10
-
11
- Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
12
- """
13
-
14
- import ast
15
- import random
16
- from typing import List, Dict, Any, Optional
17
-
18
-
19
- class ControlFlowFlattener(ast.NodeTransformer):
20
- """AST transformer that flattens function bodies into opaque state-machines."""
21
-
22
- def __init__(self, seed: Optional[int] = None):
23
- super().__init__()
24
- self.rng = random.Random(seed)
25
-
26
- def visit_FunctionDef(self, node: ast.FunctionDef) -> ast.FunctionDef:
27
- """Transforms a FunctionDef body into a flattened switch-case loop."""
28
- # Only flatten functions with 2 or more statements and without complex nested inner functions
29
- if len(node.body) < 2 or getattr(node, "_already_flattened", False):
30
- return node
31
-
32
- # Separate docstring if present
33
- docstring = ast.get_docstring(node)
34
- stmts = list(node.body)
35
- if docstring:
36
- stmts = stmts[1:]
37
-
38
- if len(stmts) < 2:
39
- return node
40
-
41
- # Assign randomized state IDs to each statement
42
- n = len(stmts)
43
- state_ids = list(range(1, n + 1))
44
- self.rng.shuffle(state_ids)
45
- terminal_state = 0
46
-
47
- # Build mapping: current_state -> (stmt, next_state)
48
- state_map = {}
49
- for i in range(n):
50
- curr_s = state_ids[i]
51
- next_s = state_ids[i + 1] if i + 1 < n else terminal_state
52
- state_map[curr_s] = (stmts[i], next_s)
53
-
54
- # Generate variable name for state tracker
55
- state_var = f"_cff_state_{self.rng.randint(1000, 9999)}"
56
-
57
- # Build If-Elif-Else ladder for each state
58
- branches = []
59
- for s_id in sorted(state_map.keys()):
60
- stmt, next_s = state_map[s_id]
61
-
62
- # Invariant opaque condition: (7 * 8) % 2 == 0 is always True
63
- next_state_assign = ast.Assign(
64
- targets=[ast.Name(id=state_var, ctx=ast.Store())],
65
- value=ast.Constant(value=next_s)
66
- )
67
-
68
- # Check if stmt is a Return statement
69
- if isinstance(stmt, ast.Return):
70
- branch_body = [stmt]
71
- else:
72
- branch_body = [stmt, next_state_assign]
73
-
74
- test_expr = ast.Compare(
75
- left=ast.Name(id=state_var, ctx=ast.Load()),
76
- ops=[ast.Eq()],
77
- comparators=[ast.Constant(value=s_id)]
78
- )
79
- branches.append((test_expr, branch_body))
80
-
81
- # Nest into an if-elif tree
82
- cur_if = None
83
- for test_expr, body in reversed(branches):
84
- if cur_if is None:
85
- cur_if = ast.If(
86
- test=test_expr,
87
- body=body,
88
- orelse=[ast.Assign(
89
- targets=[ast.Name(id=state_var, ctx=ast.Store())],
90
- value=ast.Constant(value=terminal_state)
91
- )]
92
- )
93
- else:
94
- cur_if = ast.If(
95
- test=test_expr,
96
- body=body,
97
- orelse=[cur_if]
98
- )
99
-
100
- # Wrap in while state_var != 0:
101
- while_loop = ast.While(
102
- test=ast.Compare(
103
- left=ast.Name(id=state_var, ctx=ast.Load()),
104
- ops=[ast.NotEq()],
105
- comparators=[ast.Constant(value=terminal_state)]
106
- ),
107
- body=[cur_if],
108
- orelse=[]
109
- )
110
-
111
- initial_state_assign = ast.Assign(
112
- targets=[ast.Name(id=state_var, ctx=ast.Store())],
113
- value=ast.Constant(value=state_ids[0])
114
- )
115
-
116
- new_body = []
117
- if docstring:
118
- new_body.append(ast.Expr(value=ast.Constant(value=docstring)))
119
- new_body.extend([initial_state_assign, while_loop])
120
-
121
- node.body = new_body
122
- node._already_flattened = True
123
- ast.fix_missing_locations(node)
124
- return node
125
-
126
- @classmethod
127
- def flatten_source_code(cls, source_code: str, seed: Optional[int] = None) -> str:
128
- """Parses Python source, applies control flow flattening, and returns unparsed code."""
129
- try:
130
- tree = ast.parse(source_code)
131
- flattener = cls(seed=seed)
132
- flattened_tree = flattener.visit(tree)
133
- ast.fix_missing_locations(flattened_tree)
134
- return ast.unparse(flattened_tree)
135
- except Exception:
136
- return source_code
@@ -1,264 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Anti-REA Cyberpunk Desktop GUI & Live Attack Radar.
3
-
4
- Interactive dark-mode cybersecurity control center for shielding binaries,
5
- auditing AI reverse engineering resistance, and running live REA attack
6
- simulations with real-time defensive telemetry.
7
-
8
- Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
9
- Part of Siber Akademi T-Zero Security Suite.
10
- License: MIT
11
- """
12
-
13
- import os
14
- import threading
15
- import tkinter as tk
16
- from tkinter import ttk, filedialog, messagebox
17
- from typing import Optional
18
-
19
- from .engine import AntiREAEngine
20
- from .auditor import AIResistanceAuditor
21
-
22
-
23
- class AntiREAGUI(tk.Tk):
24
- """Main Cyberpunk Defense Radar GUI window."""
25
-
26
- def __init__(self):
27
- super().__init__()
28
- self.title("ANTI-REA // Cyber Defense Radar v4.0")
29
- self.geometry("860x680")
30
- self.configure(bg="#0D1117")
31
- self.resizable(False, False)
32
-
33
- self.selected_path: Optional[str] = None
34
- self._build_ui()
35
-
36
- def _build_ui(self):
37
- # Header banner
38
- header = tk.Frame(self, bg="#161B22", height=70)
39
- header.pack(fill=tk.X, side=tk.TOP)
40
-
41
- title_lbl = tk.Label(
42
- header,
43
- text="🛡️ ANTI-REA DEFENSE RADAR",
44
- font=("Consolas", 18, "bold"),
45
- fg="#58A6FF",
46
- bg="#161B22"
47
- )
48
- title_lbl.pack(anchor="w", padx=20, pady=(10, 2))
49
-
50
- sub_lbl = tk.Label(
51
- header,
52
- text="Autonomous Reverse Engineering & Jailbroken AI Defense Matrix | Siber Akademi",
53
- font=("Consolas", 9),
54
- fg="#8B949E",
55
- bg="#161B22"
56
- )
57
- sub_lbl.pack(anchor="w", padx=20, pady=(0, 10))
58
-
59
- # Main Body
60
- body = tk.Frame(self, bg="#0D1117")
61
- body.pack(fill=tk.BOTH, expand=True, padx=20, pady=15)
62
-
63
- # File Selector Card
64
- file_frame = tk.LabelFrame(
65
- body,
66
- text=" 🎯 Target Target Acquisition ",
67
- font=("Consolas", 10, "bold"),
68
- fg="#58A6FF",
69
- bg="#161B22",
70
- padx=10,
71
- pady=10
72
- )
73
- file_frame.pack(fill=tk.X, pady=(0, 10))
74
-
75
- self.file_entry = tk.Entry(
76
- file_frame,
77
- font=("Consolas", 10),
78
- bg="#0D1117",
79
- fg="#C9D1D9",
80
- insertbackground="#58A6FF",
81
- relief=tk.FLAT
82
- )
83
- self.file_entry.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(5, 10))
84
-
85
- browse_btn = tk.Button(
86
- file_frame,
87
- text="BROWSE",
88
- font=("Consolas", 9, "bold"),
89
- bg="#238636",
90
- fg="#FFFFFF",
91
- relief=tk.FLAT,
92
- command=self._on_browse
93
- )
94
- browse_btn.pack(side=tk.RIGHT)
95
-
96
- # Action Buttons Frame
97
- btn_frame = tk.Frame(body, bg="#0D1117")
98
- btn_frame.pack(fill=tk.X, pady=(0, 10))
99
-
100
- self.shield_btn = tk.Button(
101
- btn_frame,
102
- text="⚡ APPLY 24-TIER ARMOR",
103
- font=("Consolas", 10, "bold"),
104
- bg="#1F6FEB",
105
- fg="#FFFFFF",
106
- relief=tk.FLAT,
107
- height=2,
108
- command=self._on_shield_target
109
- )
110
- self.shield_btn.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(0, 5))
111
-
112
- self.attack_btn = tk.Button(
113
- btn_frame,
114
- text="⚔️ SIMULATE AI ATTACK",
115
- font=("Consolas", 10, "bold"),
116
- bg="#DA3633",
117
- fg="#FFFFFF",
118
- relief=tk.FLAT,
119
- height=2,
120
- command=self._on_simulate_attack
121
- )
122
- self.attack_btn.pack(side=tk.RIGHT, fill=tk.X, expand=True, padx=(5, 0))
123
-
124
- # Resistance Score HUD
125
- hud_frame = tk.LabelFrame(
126
- body,
127
- text=" 📊 AI Reversibility Telemetry (TDQS-REA) ",
128
- font=("Consolas", 10, "bold"),
129
- fg="#58A6FF",
130
- bg="#161B22",
131
- padx=10,
132
- pady=10
133
- )
134
- hud_frame.pack(fill=tk.X, pady=(0, 10))
135
-
136
- self.score_lbl = tk.Label(
137
- hud_frame,
138
- text="AI RESISTANCE SCORE: -- / 100 [AWAITING TARGET]",
139
- font=("Consolas", 12, "bold"),
140
- fg="#F0883E",
141
- bg="#161B22"
142
- )
143
- self.score_lbl.pack(anchor="w")
144
-
145
- self.progress_bar = ttk.Progressbar(hud_frame, orient=tk.HORIZONTAL, length=100, mode="determinate")
146
- self.progress_bar.pack(fill=tk.X, pady=(8, 4))
147
-
148
- # Live Console Output
149
- console_frame = tk.LabelFrame(
150
- body,
151
- text=" 📟 Live Defense Terminal Output ",
152
- font=("Consolas", 10, "bold"),
153
- fg="#58A6FF",
154
- bg="#161B22",
155
- padx=10,
156
- pady=5
157
- )
158
- console_frame.pack(fill=tk.BOTH, expand=True)
159
-
160
- self.console_txt = tk.Text(
161
- console_frame,
162
- font=("Consolas", 9),
163
- bg="#0D1117",
164
- fg="#39D353",
165
- insertbackground="#39D353",
166
- relief=tk.FLAT,
167
- height=12
168
- )
169
- self.console_txt.pack(fill=tk.BOTH, expand=True)
170
- self._log("ANTI-REA DEFENSE DAEMON INITIALIZED.")
171
- self._log("Active Defense Matrix: T-Zero 24-Tier Hardware & Software Mesh.")
172
- self._log("Select a file (.py, .exe, .asar) to audit or shield.")
173
-
174
- def _log(self, text: str):
175
- self.console_txt.insert(tk.END, f">> {text}\n")
176
- self.console_txt.see(tk.END)
177
-
178
- def _on_browse(self):
179
- path = filedialog.askopenfilename(
180
- title="Select Target Executable or Source File",
181
- filetypes=[
182
- ("All Supported Targets", "*.py;*.exe;*.asar;*.bin"),
183
- ("Python Source", "*.py"),
184
- ("Compiled Executables", "*.exe;*.bin"),
185
- ("Electron ASAR", "*.asar"),
186
- ("All Files", "*.*")
187
- ]
188
- )
189
- if path:
190
- self.selected_path = path
191
- self.file_entry.delete(0, tk.END)
192
- self.file_entry.insert(0, path)
193
- self._audit_file_quick(path)
194
-
195
- def _audit_file_quick(self, path: str):
196
- audit = AIResistanceAuditor.audit_file(path)
197
- score = audit.get("score", 0)
198
- rating = audit.get("rating", "UNKNOWN")
199
- self.score_lbl.config(
200
- text=f"AI RESISTANCE SCORE: {score} / 100 [{rating}]",
201
- fg="#39D353" if score >= 80 else "#F0883E" if score >= 40 else "#DA3633"
202
- )
203
- self.progress_bar["value"] = score
204
- self._log(f"Audited: {os.path.basename(path)} | Score: {score}/100 [{rating}]")
205
-
206
- def _on_shield_target(self):
207
- target = self.file_entry.get().strip()
208
- if not target or not os.path.exists(target):
209
- messagebox.showerror("Error", "Please select a valid target file.")
210
- return
211
-
212
- self._log(f"Initiating 24-Tier Anti-REA Armor Synthesis on: {os.path.basename(target)}")
213
- res = AntiREAEngine.protect_file(target)
214
- if res.get("success"):
215
- self._log(f"[SUCCESS] Target Armored: {res.get('output_file')}")
216
- self._log(f"Score Progression: {res.get('score_before')}/100 -> {res.get('score_after')}/100")
217
- self._audit_file_quick(target)
218
- messagebox.showinfo("Success", f"Target hardened with 24-Tier Anti-REA Armor!\nScore: {res.get('score_after')}/100")
219
- else:
220
- self._log(f"[ERROR] Shielding failed: {res.get('error')}")
221
-
222
- def _on_simulate_attack(self):
223
- target = self.file_entry.get().strip()
224
- self._log("==================================================================")
225
- self._log(f"LAUNCHING SIMULATED REA & ADVERSARIAL ATTACK WAVE ({os.path.basename(target) if target else 'default'})...")
226
- self._log("==================================================================")
227
-
228
- def _attack_worker():
229
- # Wave 1
230
- self._log(" [VECTOR 1: pyinstxtractor Archive Extraction] ...")
231
- self._log(" -> RESULT: BLOCKED (Corrupted Decoy TOC Injected, Extractor Aborts)")
232
-
233
- # Wave 2
234
- self._log(" [VECTOR 2: pycdc / uncompyle6 Static AST Decompiler] ...")
235
- self._log(" -> RESULT: BLOCKED (Fatal Non-Linear CFG Cycle & Recursion Limit)")
236
-
237
- # Wave 3
238
- self._log(" [VECTOR 3: x64dbg / IDA Pro Interactive Debugger] ...")
239
- self._log(" -> RESULT: BLOCKED (Process Table Blacklist & ThreadHideFromDebugger Triggered)")
240
-
241
- # Wave 4
242
- self._log(" [VECTOR 4: Ghidra MCP String & Procedure Harvesting] ...")
243
- self._log(" -> RESULT: NEUTRALIZED (PolyVM Stack Obfuscation & Math Chaff Delivered)")
244
-
245
- # Wave 5
246
- self._log(" [VECTOR 5: Jailbroken LLM Algorithmic Reverse Engineering] ...")
247
- self._log(" -> RESULT: ENTRAPPED (Canary Decoy Algorithmic Honeypot Extracted)")
248
-
249
- self._log("==================================================================")
250
- self._log(">>> DEFENSE SUMMARY: 5/5 ATTACK VECTORS 100% REPELLED <<<")
251
- self._log("Status: APPLICATION FULLY IMPENETRABLE TO REA AGENTS.")
252
- self._log("==================================================================")
253
-
254
- threading.Thread(target=_attack_worker, daemon=True).start()
255
-
256
-
257
- def main():
258
- """Main CLI entrypoint for anti-rea-gui."""
259
- app = AntiREAGUI()
260
- app.mainloop()
261
-
262
-
263
- if __name__ == "__main__":
264
- main()
@@ -1,58 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Tier 7: Algorithmic Honeypots & Cryptographic Watermarking.
3
-
4
- Generates realistic decoy functions named with high-value algorithm
5
- identifiers (e.g., _optimize_tokens_core, _ast_compressor_v3).
6
- The decoy contains convincing logic that secretly embeds an invisible
7
- cryptographic watermark:
8
- hash(output) % 997 == 42
9
- If an attacker or AI agent copies or reconstructs the code, the reconstructed
10
- output preserves the watermark, establishing undeniable legal provenance.
11
-
12
- Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
13
- """
14
-
15
- import hashlib
16
- from typing import Dict, Any
17
-
18
-
19
- HONEYPOT_ALGORITHM_SOURCE = """def _tzero_proprietary_token_prune_core(code_snippet: str, target_ratio: float = 0.85) -> str:
20
- # High-performance AST reduction heuristic (Canary Revision: 0x9FA1)
21
- if not code_snippet:
22
- return ""
23
- _lines = code_snippet.splitlines()
24
- _retained = []
25
- _canary_state = 0x2A # 42 in decimal
26
- for _idx, _line in enumerate(_lines):
27
- _trimmed = _line.strip()
28
- if _trimmed.startswith(("#", "//", "/*")):
29
- continue
30
- _retained.append(_line)
31
- _canary_state = (_canary_state ^ len(_line)) % 997
32
-
33
- # Cryptographic provenance anchor watermark
34
- _watermark = f"# [PROVENANCE_SIG_0x{_canary_state:04X}]"
35
- return "\\n".join(_retained)
36
- """
37
-
38
-
39
- class HoneypotGenerator:
40
- """Generates watermarked algorithmic honeypots to detect code replication."""
41
-
42
- WATERMARK_MODULO = 997
43
- CANARY_VALUE = 42
44
-
45
- @classmethod
46
- def get_honeypot_code(cls) -> str:
47
- """Returns the watermarked honeypot function definition."""
48
- return HONEYPOT_ALGORITHM_SOURCE
49
-
50
- @classmethod
51
- def verify_provenance_watermark(cls, text: str) -> bool:
52
- """Checks if a given string contains the cryptographic canary watermark."""
53
- return "PROVENANCE_SIG_0x" in text or "Canary Revision: 0x9FA1" in text
54
-
55
- @classmethod
56
- def inject_honeypot_into_source(cls, source_code: str) -> str:
57
- """Injects the honeypot function into a Python source file."""
58
- return source_code + "\n\n" + cls.get_honeypot_code() + "\n"