dexsect 4.1.0__py3-none-any.whl

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 (74) hide show
  1. dexsect/__init__.py +4 -0
  2. dexsect/__main__.py +5 -0
  3. dexsect/catalog/EXTRACTION_CATALOG.json +4057 -0
  4. dexsect/catalog/__init__.py +0 -0
  5. dexsect/cli.py +1272 -0
  6. dexsect/core/__init__.py +0 -0
  7. dexsect/core/config.py +177 -0
  8. dexsect/core/context.py +181 -0
  9. dexsect/core/i18n.py +40 -0
  10. dexsect/core/pipeline.py +153 -0
  11. dexsect/core/platform_utils.py +164 -0
  12. dexsect/core/runner.py +124 -0
  13. dexsect/core/theme.py +64 -0
  14. dexsect/core/ui.py +405 -0
  15. dexsect/core/utils.py +150 -0
  16. dexsect/inspectors/__init__.py +0 -0
  17. dexsect/inspectors/assets_db_inspector.py +235 -0
  18. dexsect/inspectors/base.py +46 -0
  19. dexsect/inspectors/bundle_inspector.py +55 -0
  20. dexsect/inspectors/code_inspector.py +341 -0
  21. dexsect/inspectors/custom_rules_inspector.py +178 -0
  22. dexsect/inspectors/dex_inspector.py +144 -0
  23. dexsect/inspectors/manifest_inspector.py +503 -0
  24. dexsect/inspectors/native_fw_inspector.py +167 -0
  25. dexsect/inspectors/resources_inspector.py +195 -0
  26. dexsect/inspectors/scanner_inspector.py +153 -0
  27. dexsect/inspectors/signing_inspector.py +423 -0
  28. dexsect/inspectors/text_scanner.py +336 -0
  29. dexsect/locales/__init__.py +0 -0
  30. dexsect/locales/ar.json +130 -0
  31. dexsect/locales/de.json +51 -0
  32. dexsect/locales/en.json +110 -0
  33. dexsect/locales/es.json +51 -0
  34. dexsect/locales/fr.json +51 -0
  35. dexsect/locales/ja.json +51 -0
  36. dexsect/locales/pt.json +51 -0
  37. dexsect/locales/ru.json +51 -0
  38. dexsect/locales/tr.json +51 -0
  39. dexsect/locales/zh.json +51 -0
  40. dexsect/parsers/__init__.py +0 -0
  41. dexsect/parsers/axml.py +264 -0
  42. dexsect/parsers/bundle.py +214 -0
  43. dexsect/parsers/elf.py +396 -0
  44. dexsect/phases/__init__.py +0 -0
  45. dexsect/phases/base.py +102 -0
  46. dexsect/phases/decode.py +507 -0
  47. dexsect/phases/decompile.py +408 -0
  48. dexsect/phases/fingerprint.py +341 -0
  49. dexsect/phases/frameworks.py +377 -0
  50. dexsect/phases/mapper.py +41 -0
  51. dexsect/phases/native.py +188 -0
  52. dexsect/plugins/__init__.py +0 -0
  53. dexsect/plugins/base.py +20 -0
  54. dexsect/plugins/diff.py +162 -0
  55. dexsect/plugins/inspect.py +172 -0
  56. dexsect/plugins/report.py +80 -0
  57. dexsect/plugins/trace.py +141 -0
  58. dexsect/reporting/__init__.py +0 -0
  59. dexsect/reporting/analysis_report.py +1190 -0
  60. dexsect/reporting/diff_report.py +144 -0
  61. dexsect/reporting/sarif_report.py +109 -0
  62. dexsect/reporting/unpack_map.py +149 -0
  63. dexsect/rules/__init__.py +0 -0
  64. dexsect/rules/anti_analysis.json +45 -0
  65. dexsect/rules/crypto_audit.json +41 -0
  66. dexsect/rules/secrets_extended.json +46 -0
  67. dexsect/storage/__init__.py +0 -0
  68. dexsect/storage/findings_db.py +460 -0
  69. dexsect-4.1.0.dist-info/METADATA +532 -0
  70. dexsect-4.1.0.dist-info/RECORD +74 -0
  71. dexsect-4.1.0.dist-info/WHEEL +5 -0
  72. dexsect-4.1.0.dist-info/entry_points.txt +2 -0
  73. dexsect-4.1.0.dist-info/licenses/LICENSE +21 -0
  74. dexsect-4.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,144 @@
1
+ import html
2
+ import json
3
+ from typing import Any, Dict
4
+
5
+ from .. import __version__
6
+
7
+
8
+ def _esc(v: Any) -> str:
9
+ return html.escape(str(v if v is not None else ""), quote=True)
10
+
11
+
12
+ DIFF_HTML_TEMPLATE = r"""<!DOCTYPE html>
13
+ <html lang="en" data-theme="dark">
14
+ <head>
15
+ <meta charset="utf-8">
16
+ <meta name="viewport" content="width=device-width, initial-scale=1">
17
+ <title>DexSect Differential Report</title>
18
+ <style>
19
+ :root[data-theme="dark"] {
20
+ --bg:#111015; --card:#1B1823; --card2:#231F2D; --border:#35293A;
21
+ --text:#F5EFE6; --muted:#A39AA8; --accent:#FF8C24; --accent2:#B83B5E;
22
+ --add:#34D399; --rem:#F87171; --grid:rgba(184,59,94,0.06);
23
+ }
24
+ :root[data-theme="light"] {
25
+ --bg:#FAF7F2; --card:#FFFFFF; --card2:#F4EFE8; --border:#E5D9CF;
26
+ --text:#1B1622; --muted:#6E6273; --accent:#EA580C; --accent2:#9E2A4B;
27
+ --add:#059669; --rem:#DC2626; --grid:rgba(158,42,75,0.04);
28
+ }
29
+ * { box-sizing:border-box; }
30
+ body {
31
+ margin:0; font-family: system-ui, -apple-system, sans-serif; background:var(--bg);
32
+ background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px), linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
33
+ background-size: 34px 34px; color:var(--text); padding:14px;
34
+ }
35
+ .wrap { max-width:1200px; margin:0 auto; }
36
+ .hdr { background:var(--card); border:1px solid var(--border); border-radius:12px; padding:16px; margin-bottom:14px; display:flex; justify-content:space-between; align-items:flex-start; flex-wrap:wrap; gap:12px; }
37
+ .brand { display:flex; align-items:center; gap:12px; }
38
+ .logo {
39
+ width:42px; height:42px; border-radius:10px; flex-shrink:0;
40
+ background: radial-gradient(circle at 70% 35%, rgba(255,140,36,0.22), rgba(184,59,94,0.18) 70%, transparent);
41
+ border: 1px solid rgba(184, 59, 94, 0.55); display:flex; align-items:center; justify-content:center;
42
+ }
43
+ .hdr h1 { margin:0 0 4px; font-size:18px; }
44
+ .dex { color:var(--accent); } .sect { color:var(--text); }
45
+ .ver { font-size:11px; color:var(--muted); font-weight:600; }
46
+ .hdr p { margin:2px 0; font-size:12px; color:var(--muted); word-break:break-all; }
47
+ .kpis { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:10px; margin-bottom:12px; }
48
+ .kpi { background:var(--card); border:1px solid var(--border); border-radius:10px; padding:12px; border-top:3px solid var(--accent); }
49
+ .val { font-size:22px; font-weight:800; }
50
+ .add { color:var(--add); } .rem { color:var(--rem); }
51
+ .toolbar { display:flex; gap:8px; flex-wrap:wrap; background:var(--card); border:1px solid var(--border); border-radius:10px; padding:10px; margin-bottom:12px; }
52
+ input, select, button { background:var(--card2); color:var(--text); border:1px solid var(--border); border-radius:8px; padding:7px 11px; font-size:13px; min-height:36px; }
53
+ input { flex:1; min-width:200px; }
54
+ input:focus, select:focus { outline:none; border-color:var(--accent); }
55
+ button { cursor:pointer; font-weight:600; }
56
+ button:hover { border-color:var(--accent); }
57
+ .sec { background:var(--card); border:1px solid var(--border); border-radius:12px; margin-bottom:10px; overflow:hidden; }
58
+ .sec summary { padding:12px 15px; background:var(--card2); cursor:pointer; font-weight:700; font-size:14px; display:flex; justify-content:space-between; list-style:none; }
59
+ .sec-body { padding:10px 15px; }
60
+ .row { display:flex; gap:10px; align-items:flex-start; padding:8px 0; border-bottom:1px dashed var(--border); font-size:12.5px; }
61
+ .row:last-child { border-bottom:none; }
62
+ .tag { padding:2px 8px; border-radius:5px; font-weight:700; font-family:monospace; flex-shrink:0; font-size:11px; }
63
+ .t-add { background:rgba(52,211,153,0.15); color:var(--add); }
64
+ .t-rem { background:rgba(248,113,113,0.15); color:var(--rem); }
65
+ .mono { font-family: ui-monospace, monospace; word-break:break-word; }
66
+ </style>
67
+ </head>
68
+ <body>
69
+ <div class="wrap">
70
+ <div class="hdr">
71
+ <div class="brand">
72
+ <div class="logo">
73
+ <svg width="26" height="26" viewBox="0 0 24 24" fill="none">
74
+ <defs><linearGradient id="dsGrad" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#B83B5E"/><stop offset="100%" stop-color="#FF8C24"/></linearGradient></defs>
75
+ <path d="M12 2L4 5.5V11.5C4 16.8 7.4 21.1 12 22.5C16.6 21.1 20 16.8 20 11.5V5.5L12 2Z" stroke="url(#dsGrad)" stroke-width="1.8" fill="rgba(184,59,94,0.12)"/>
76
+ <line x1="12" y1="3.2" x2="12" y2="21.5" stroke="#B83B5E" stroke-width="1.2" opacity="0.8"/>
77
+ <path d="M7 9H9.5V12H8M7 15H9.5" stroke="#B83B5E" stroke-width="1.3" stroke-linecap="round"/>
78
+ <circle cx="15.5" cy="9" r="1.2" fill="#FF8C24"/>
79
+ <path d="M14.5 13H17M15.5 16H17.5" stroke="#FF8C24" stroke-width="1.4" stroke-linecap="round"/>
80
+ </svg>
81
+ </div>
82
+ <div>
83
+ <h1><span class="dex">Dex</span><span class="sect">Sect</span> Differential Report <span class="ver">v__VERSION__</span></h1>
84
+ <p><strong>Baseline (-):</strong> __BASELINE__</p>
85
+ <p><strong>Target (+):</strong> __TARGET__</p>
86
+ </div>
87
+ </div>
88
+ <button onclick="document.documentElement.setAttribute('data-theme', document.documentElement.getAttribute('data-theme')==='dark'?'light':'dark')">Theme</button>
89
+ </div>
90
+ <div class="kpis">
91
+ <div class="kpi"><div class="val add">+__ADDED__</div><div>Added Items</div></div>
92
+ <div class="kpi"><div class="val rem">-__REMOVED__</div><div>Removed Items</div></div>
93
+ <div class="kpi"><div class="val">__SCOPE__</div><div>Scope Filter</div></div>
94
+ </div>
95
+ <div class="toolbar">
96
+ <input type="text" id="qBox" placeholder="Search added/removed findings..." oninput="render()">
97
+ <select id="chgFilter" onchange="render()">
98
+ <option value="">All Changes (+ & -)</option>
99
+ <option value="add">Added Only (+)</option>
100
+ <option value="rem">Removed Only (-)</option>
101
+ </select>
102
+ </div>
103
+ <div id="sections"></div>
104
+ </div>
105
+ <script>
106
+ const DIFF = __DIFF_JSON__;
107
+ function esc(s) { return String(s ?? "").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"); }
108
+ function render() {
109
+ const q = document.getElementById("qBox").value.trim().toLowerCase();
110
+ const cf = document.getElementById("chgFilter").value;
111
+ const root = document.getElementById("sections");
112
+ root.innerHTML = "";
113
+ Object.values(DIFF.sections).forEach(sec => {
114
+ const addRows = cf === "rem" ? [] : sec.added.filter(x => !q || `${x.catalog_id} ${x.title} ${x.value}`.toLowerCase().includes(q));
115
+ const remRows = cf === "add" ? [] : sec.removed.filter(x => !q || `${x.catalog_id} ${x.title} ${x.value}`.toLowerCase().includes(q));
116
+ if (!addRows.length && !remRows.length) return;
117
+ const htmlRows = [
118
+ ...addRows.map(x => `<div class="row"><span class="tag t-add">+ ${esc(x.catalog_id)}</span><span class="mono"><strong>${esc(x.title)}:</strong> ${esc(x.value)}</span></div>`),
119
+ ...remRows.map(x => `<div class="row"><span class="tag t-rem">- ${esc(x.catalog_id)}</span><span class="mono"><strong>${esc(x.title)}:</strong> ${esc(x.value)}</span></div>`),
120
+ ].join("");
121
+ root.innerHTML += `<details class="sec" open><summary><span>${esc(sec.title)}</span><span>+${addRows.length} / -${remRows.length}</span></summary><div class="sec-body">${htmlRows}</div></details>`;
122
+ });
123
+ }
124
+ render();
125
+ </script>
126
+ </body>
127
+ </html>
128
+ """
129
+
130
+
131
+ def generate_diff_html(diff_data: Dict[str, Any]) -> str:
132
+ safe_json = json.dumps(diff_data, ensure_ascii=False).replace("</", "<\\/")
133
+ doc = DIFF_HTML_TEMPLATE
134
+ for k, v in {
135
+ "__VERSION__": _esc(__version__),
136
+ "__BASELINE__": _esc(diff_data.get("baseline")),
137
+ "__TARGET__": _esc(diff_data.get("target")),
138
+ "__ADDED__": str(diff_data["summary"]["total_added"]),
139
+ "__REMOVED__": str(diff_data["summary"]["total_removed"]),
140
+ "__SCOPE__": _esc(", ".join(diff_data.get("scope_filter", ["all"]))),
141
+ "__DIFF_JSON__": safe_json,
142
+ }.items():
143
+ doc = doc.replace(k, v)
144
+ return doc
@@ -0,0 +1,109 @@
1
+ import json
2
+ from pathlib import Path
3
+ from typing import Any, Dict, List
4
+
5
+ from .. import __version__
6
+ from ..core.context import WorkspaceState
7
+ from ..storage.findings_db import FindingsDB
8
+
9
+
10
+ HIGH_SEVERITY_CIDS = {"SEC-001", "SEC-003", "SEC-004", "SEC-008", "ACT-005", "CFG-004", "CFG-005", "SIG-006"}
11
+ MEDIUM_SEVERITY_CIDS = {"SEC-002", "SEC-005", "SEC-006", "SEC-007", "PER-011", "REF-001", "REF-003", "NAT-003", "COD-GAP-001", "COD-GAP-002"}
12
+
13
+
14
+ def _sarif_level(cid: str, value: str) -> str:
15
+ low = value.lower()
16
+ if cid == "SEC-001" and ("debuggable=true" in low or "cleartext=true" in low):
17
+ return "error"
18
+ if cid == "SIG-006" and low == "true":
19
+ return "error"
20
+ if cid in HIGH_SEVERITY_CIDS or cid.startswith("CUSTOM-"):
21
+ return "warning"
22
+ if cid in MEDIUM_SEVERITY_CIDS:
23
+ return "warning"
24
+ return "note"
25
+
26
+
27
+ def generate_sarif_report(state: WorkspaceState, db: FindingsDB, out_path: Path, include_noise: bool = False) -> Path:
28
+ cat_specs: Dict[str, Dict[str, Any]] = {}
29
+ cat_file = Path(__file__).resolve().parent.parent / "catalog" / "EXTRACTION_CATALOG.json"
30
+ if cat_file.is_file():
31
+ try:
32
+ for it in json.loads(cat_file.read_text(encoding="utf-8")).get("items", []):
33
+ cat_specs[it["id"]] = it
34
+ except Exception:
35
+ pass
36
+
37
+ target_cids = [
38
+ "SEC-*", "ACT-005", "SRV-002", "REC-002", "PRO-003",
39
+ "CFG-004", "CFG-005", "PER-011", "SIG-006",
40
+ "REF-001", "REF-003", "NAT-003", "COD-GAP-*", "CUSTOM-*",
41
+ ]
42
+ rows = db.query_findings(catalog_ids=target_cids, limit=5000)
43
+ if not include_noise:
44
+ rows = [r for r in rows if r.get("scope") != "boilerplate"]
45
+
46
+ rules_map: Dict[str, Dict[str, Any]] = {}
47
+ results: List[Dict[str, Any]] = []
48
+ ws_root_str = str(state.root)
49
+
50
+ for r in rows:
51
+ cid = r["catalog_id"]
52
+ lvl = _sarif_level(cid, r["value"])
53
+ if cid not in rules_map:
54
+ spec = cat_specs.get(cid, {})
55
+ rules_map[cid] = {
56
+ "id": cid,
57
+ "name": spec.get("name", r.get("title") or cid).replace(" ", ""),
58
+ "shortDescription": {"text": spec.get("name", r.get("title") or cid)},
59
+ "fullDescription": {"text": spec.get("description", r.get("title") or cid)},
60
+ "defaultConfiguration": {"level": lvl},
61
+ "properties": {
62
+ "domain": r.get("domain", ""),
63
+ "reliability": spec.get("reliability", r.get("confidence", "high")),
64
+ },
65
+ }
66
+
67
+ raw_fp = r.get("file_path") or "workspace.json"
68
+ try:
69
+ rel_uri = Path(raw_fp).relative_to(state.root).as_posix()
70
+ except Exception:
71
+ rel_uri = raw_fp.replace(ws_root_str, "").lstrip("/\\") or "workspace.json"
72
+
73
+ line_no = max(1, int(r.get("line_no") or 1))
74
+ results.append({
75
+ "ruleId": cid,
76
+ "level": lvl,
77
+ "message": {"text": f"[{r.get('title') or cid}] {r['value']}"},
78
+ "locations": [{
79
+ "physicalLocation": {
80
+ "artifactLocation": {"uri": rel_uri},
81
+ "region": {"startLine": line_no},
82
+ }
83
+ }],
84
+ "properties": {
85
+ "unit_id": r["unit_id"],
86
+ "scope": r.get("scope", "app"),
87
+ "layer": r.get("layer", ""),
88
+ "confidence": r.get("confidence", "high"),
89
+ },
90
+ })
91
+
92
+ sarif_doc = {
93
+ "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
94
+ "version": "2.1.0",
95
+ "runs": [{
96
+ "tool": {
97
+ "driver": {
98
+ "name": "DexSect",
99
+ "version": __version__,
100
+ "informationUri": "https://github.com/moAbdulqader/dexsect",
101
+ "rules": list(rules_map.values()),
102
+ }
103
+ },
104
+ "results": results,
105
+ }],
106
+ }
107
+ out_path.parent.mkdir(parents=True, exist_ok=True)
108
+ out_path.write_text(json.dumps(sarif_doc, indent=2, ensure_ascii=False), encoding="utf-8")
109
+ return out_path
@@ -0,0 +1,149 @@
1
+ from pathlib import Path
2
+ from typing import Any, Dict, List
3
+
4
+ from ..core.context import WorkspaceState
5
+ from ..core.utils import format_bytes, format_duration
6
+
7
+
8
+ def generate_unpack_maps(state: WorkspaceState) -> Dict[str, Path]:
9
+ state.report_dir.mkdir(parents=True, exist_ok=True)
10
+ data = state.data
11
+ phases: Dict[str, Any] = data.get("phases", {})
12
+ units = state.get_units()
13
+ errors: List[Dict[str, Any]] = data.get("errors", [])
14
+
15
+ txt_path = state.report_dir / "UNPACK_MAP.txt"
16
+ md_path = state.report_dir / "UNPACK_MAP.md"
17
+
18
+ # ---------------- TXT MAP ----------------
19
+ t_lines = [
20
+ "====================================================================",
21
+ " DEXSECT :: EXECUTION & UNPACK MAP",
22
+ "====================================================================",
23
+ f"Version : {data.get('dexsect_version')}",
24
+ f"Schema : {data.get('schema_version')}",
25
+ f"Updated : {data.get('updated_at')}",
26
+ f"Target : {data.get('target_input')} ({data.get('input_kind')})",
27
+ f"Workspace : {data.get('workspace_root')}",
28
+ "",
29
+ "[1] PHASE EXECUTION SUMMARY",
30
+ "-" * 68,
31
+ ]
32
+ if not phases:
33
+ t_lines.append(" (No phases recorded yet)")
34
+ else:
35
+ for pname, pinfo in phases.items():
36
+ dur = format_duration(pinfo.get("duration_sec", 0))
37
+ t_lines.append(f" * {pname:<12} | Status: {pinfo.get('status', '-'):<11} | Time: {dur} | Info: { {k: v for k, v in pinfo.items() if k not in ('status', 'duration_sec', 'top_extensions')} }")
38
+
39
+ t_lines.extend(["", "[2] UNPACKED ARTIFACT UNITS MAP", "-" * 68])
40
+ for u in units:
41
+ m = u.metrics
42
+ t_lines.extend([
43
+ f" [{u.unit_id}] {u.name} (Role: {u.role} | Depth: {u.depth})",
44
+ f" SHA256 : {u.sha256}",
45
+ f" Source : {u.source_path}",
46
+ f" Stack : {u.primary_stack or '(not fingerprinted)'}",
47
+ f" Phase Status : {u.phase_status}",
48
+ f" Metrics : files={m.get('files_count', 0)} ({format_bytes(m.get('bytes_total', 0))}), "
49
+ f"java={m.get('java_files', 0)}, so_unpacked={len(m.get('native_libs_unpacked', []))}",
50
+ f" Decode Dir : {u.decode_dir or '-'}",
51
+ f" Manifest XML : {u.manifest_xml or '-'}",
52
+ f" Java Dir : {u.java_dir or '-'}",
53
+ f" Frameworks : {u.frameworks_dir or '-'}",
54
+ f" Native Dir : {u.native_dir or '-'}",
55
+ ])
56
+ if u.packer_hints:
57
+ t_lines.append(f" Packer Hints : {', '.join(u.packer_hints)}")
58
+
59
+ t_lines.extend(["", f"[3] ERRORS & WARNINGS LOGGED ({len(errors)})", "-" * 68])
60
+ if not errors:
61
+ t_lines.append(" No errors recorded.")
62
+ else:
63
+ for e in errors:
64
+ t_lines.append(f" - [{e.get('phase')}] {e.get('target')} (rc={e.get('exit_code')}): {e.get('message')}")
65
+ if e.get("log_file"):
66
+ t_lines.append(f" Log: {e.get('log_file')}")
67
+
68
+ t_lines.extend([
69
+ "",
70
+ "[4] WORKSPACE DIRECTORY MAP",
71
+ "-" * 68,
72
+ " workspace.json -> Central structured index for future inspect/report plugins",
73
+ " 00_Bundle_Extracted/ -> Split APKs extracted from .xapk/.apks/.apkm",
74
+ " 01_Main_APK/ -> Decoded main APK (Manifest, res, smali, assets, lib)",
75
+ " 02_Split_APKs/ -> Decoded split APKs",
76
+ " 03_Embedded_APKs/ -> Recursively decoded embedded APKs",
77
+ " 04_Java_Src/ -> JADX Java/Kotlin sources",
78
+ " 05_Frameworks/ -> Unpacked Flutter / React Native / Unity / Web artifacts",
79
+ " 06_Native_Libs/ -> Unpacked ELF metadata, JNI exports, symbols & strings",
80
+ " 07_Logs/ -> session.log, errors.log, errors.json, tasks/*.log",
81
+ " 08_Inventory/ -> apks.tsv, files.tsv, bundle_manifest.json",
82
+ " 09_Reports/ -> UNPACK_MAP.txt, UNPACK_MAP.md",
83
+ "====================================================================",
84
+ ])
85
+ txt_path.write_text("\n".join(t_lines) + "\n", encoding="utf-8")
86
+
87
+ # ---------------- MARKDOWN MAP ----------------
88
+ md_lines = [
89
+ "# DexSect Execution & Unpack Map",
90
+ "",
91
+ f"- **Version:** `{data.get('dexsect_version')}`",
92
+ f"- **Target:** `{data.get('target_input')}` (`{data.get('input_kind')}`)",
93
+ f"- **Workspace:** `{data.get('workspace_root')}`",
94
+ f"- **Updated:** `{data.get('updated_at')}`",
95
+ "",
96
+ "## 1. Phases Summary",
97
+ "",
98
+ "| Phase | Status | Duration | Details |",
99
+ "| :--- | :--- | :--- | :--- |",
100
+ ]
101
+ for pname, pinfo in phases.items():
102
+ dur = format_duration(pinfo.get("duration_sec", 0))
103
+ compact = ", ".join(
104
+ f"{k}={v}" for k, v in pinfo.items()
105
+ if k not in ("status", "duration_sec", "top_extensions")
106
+ )
107
+ md_lines.append(f"| `{pname}` | `{pinfo.get('status', '-')}` | `{dur}` | {compact} |")
108
+
109
+ md_lines.extend([
110
+ "",
111
+ "## 2. Unpacked Units Map",
112
+ "",
113
+ "| ID | Name | Role | Depth | Stack | Decoded Files | Java Files | Native Libs |",
114
+ "| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |",
115
+ ])
116
+ for u in units:
117
+ m = u.metrics
118
+ md_lines.append(
119
+ f"| `{u.unit_id}` | `{u.name}` | `{u.role}` | {u.depth} | {u.primary_stack or '-'} | "
120
+ f"{m.get('files_count', 0)} ({format_bytes(m.get('bytes_total', 0))}) | "
121
+ f"{m.get('java_files', 0)} | {len(m.get('native_libs_unpacked', []))} |"
122
+ )
123
+
124
+ md_lines.extend(["", "## 3. Artifact Paths", ""])
125
+ for u in units:
126
+ md_lines.extend([
127
+ f"### `[{u.unit_id}] {u.name}`",
128
+ f"- **Source:** `{u.source_path}`",
129
+ f"- **Decode Dir:** `{u.decode_dir or '-'}`",
130
+ f"- **Manifest XML:** `{u.manifest_xml or '-'}`",
131
+ f"- **Java Src Dir:** `{u.java_dir or '-'}`",
132
+ f"- **Frameworks Dir:** `{u.frameworks_dir or '-'}`",
133
+ f"- **Native Libs Dir:** `{u.native_dir or '-'}`",
134
+ "",
135
+ ])
136
+
137
+ md_lines.extend([f"## 4. Errors & Warnings ({len(errors)})", ""])
138
+ if not errors:
139
+ md_lines.append("No errors recorded.")
140
+ else:
141
+ md_lines.extend(["| Phase | Target | Exit Code | Message | Log |", "| :--- | :--- | :--- | :--- | :--- |"])
142
+ for e in errors:
143
+ md_lines.append(
144
+ f"| `{e.get('phase')}` | `{e.get('target')}` | `{e.get('exit_code')}` | "
145
+ f"{e.get('message')} | `{e.get('log_file')}` |"
146
+ )
147
+
148
+ md_path.write_text("\n".join(md_lines) + "\n", encoding="utf-8")
149
+ return {"txt": txt_path, "md": md_path}
File without changes
@@ -0,0 +1,45 @@
1
+ {
2
+ "pack_name": "Built-in Anti-Analysis & Tamper Signals",
3
+ "version": "1.0",
4
+ "rules": [
5
+ {
6
+ "id": "CUSTOM-ANTI-001",
7
+ "title": "Frida Gadget / Port / Gum Indicator",
8
+ "domain": "Custom Rules",
9
+ "subdomain": "Anti-Analysis",
10
+ "layers": [
11
+ "java",
12
+ "smali",
13
+ "native",
14
+ "assets"
15
+ ],
16
+ "regex": "(?:frida-gadget|frida-agent|re\\.frida\\.server|27042|LIBFRIDA)",
17
+ "case_insensitive": true
18
+ },
19
+ {
20
+ "id": "CUSTOM-ANTI-002",
21
+ "title": "Magisk / KernelSU / Zygisk Indicator",
22
+ "domain": "Custom Rules",
23
+ "subdomain": "Anti-Analysis",
24
+ "layers": [
25
+ "java",
26
+ "smali",
27
+ "native"
28
+ ],
29
+ "regex": "(?:/sbin/magisk|/data/adb/magisk|kernelsu|zygisk|com\\.topjohnwu\\.magisk)",
30
+ "case_insensitive": true
31
+ },
32
+ {
33
+ "id": "CUSTOM-ANTI-003",
34
+ "title": "TracerPid / ptrace Inspection",
35
+ "domain": "Custom Rules",
36
+ "subdomain": "Anti-Analysis",
37
+ "layers": [
38
+ "java",
39
+ "native"
40
+ ],
41
+ "regex": "(?:/proc/self/status|TracerPid|ptrace\\s*\\()",
42
+ "case_insensitive": false
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "pack_name": "Built-in Crypto Audit",
3
+ "version": "1.0",
4
+ "rules": [
5
+ {
6
+ "id": "CUSTOM-CRYPTO-001",
7
+ "title": "Weak Cipher or ECB Mode",
8
+ "domain": "Custom Rules",
9
+ "subdomain": "Cryptography",
10
+ "layers": [
11
+ "java",
12
+ "smali"
13
+ ],
14
+ "regex": "Cipher\\.getInstance\\s*\\(\\s*\"(?:AES(?:/ECB)?|DES|DESede|RC4|ARCFOUR|Blowfish)[^\"]*\"",
15
+ "case_insensitive": false
16
+ },
17
+ {
18
+ "id": "CUSTOM-CRYPTO-002",
19
+ "title": "Weak Hash Algorithm (MD5/SHA-1)",
20
+ "domain": "Custom Rules",
21
+ "subdomain": "Cryptography",
22
+ "layers": [
23
+ "java",
24
+ "smali"
25
+ ],
26
+ "regex": "MessageDigest\\.getInstance\\s*\\(\\s*\"(?:MD5|SHA-?1)\"",
27
+ "case_insensitive": true
28
+ },
29
+ {
30
+ "id": "CUSTOM-CRYPTO-003",
31
+ "title": "Predictable Static Byte Key/IV Pattern",
32
+ "domain": "Custom Rules",
33
+ "subdomain": "Cryptography",
34
+ "layers": [
35
+ "java"
36
+ ],
37
+ "regex": "new\\s+(?:SecretKeySpec|IvParameterSpec)\\s*\\(\\s*\"[^\"]{8,}\"\\.getBytes",
38
+ "case_insensitive": false
39
+ }
40
+ ]
41
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "pack_name": "Built-in Extended Secrets & Auth Headers",
3
+ "version": "1.0",
4
+ "rules": [
5
+ {
6
+ "id": "CUSTOM-SEC-001",
7
+ "title": "Hardcoded Authorization Bearer Header",
8
+ "domain": "Custom Rules",
9
+ "subdomain": "Auth",
10
+ "layers": [
11
+ "java",
12
+ "assets",
13
+ "framework"
14
+ ],
15
+ "regex": "Authorization[\"\\']?\\s*[:=,]\\s*[\"\\']Bearer\\s+[A-Za-z0-9._\\-]{12,}[\"\\']",
16
+ "case_insensitive": true
17
+ },
18
+ {
19
+ "id": "CUSTOM-SEC-002",
20
+ "title": "Hardcoded Basic Auth Header",
21
+ "domain": "Custom Rules",
22
+ "subdomain": "Auth",
23
+ "layers": [
24
+ "java",
25
+ "assets",
26
+ "framework"
27
+ ],
28
+ "regex": "Authorization[\"\\']?\\s*[:=,]\\s*[\"\\']Basic\\s+[A-Za-z0-9+/=]{12,}[\"\\']",
29
+ "case_insensitive": true
30
+ },
31
+ {
32
+ "id": "CUSTOM-SEC-003",
33
+ "title": "Hardcoded Client Secret Assignment",
34
+ "domain": "Custom Rules",
35
+ "subdomain": "Auth",
36
+ "layers": [
37
+ "java",
38
+ "assets",
39
+ "framework",
40
+ "resources"
41
+ ],
42
+ "regex": "(?:client_secret|app_secret|api_secret)[\"\\']?\\s*[:=]\\s*[\"\\'][A-Za-z0-9_\\-]{12,}[\"\\']",
43
+ "case_insensitive": true
44
+ }
45
+ ]
46
+ }
File without changes