scientific-method-engine 0.9.1__tar.gz → 1.0.0__tar.gz
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.
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/PKG-INFO +2 -1
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/pyproject.toml +2 -2
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/__init__.py +1 -1
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/image.py +17 -8
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_pe.py +5 -4
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_x86.py +22 -7
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/.gitignore +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/LICENSE +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/README.md +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/__main__.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/cli.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ClearNoReturnFunctions.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/CreateFunctions.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ExportBoundedFlow.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ExportCallEdges.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ExportFunctionFingerprints.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ExportFunctionInventory.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/MergeFallThroughFragment.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/RecoverCitedFunctions.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/RepairReturningCallers.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportCallArguments.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportCallPaths.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportCallSitesWithScalars.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportCallsToRange.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportConstantFirstArgumentCalls.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportDataBytes.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportDecompileMatches.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportDecompileWindow.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportFilePatternInMemory.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportFirstArgumentCallSummary.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportFunctionScalarConstants.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportFunctionSummary.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportInstructionContext.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportInstructionWindow.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportMemoryBlockForFileOffset.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportMemoryBlocks.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportRandomnessCandidates.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportReferences.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportScalarConstants.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportStringReferences.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/ghidra/ReportSymbolReferences.java +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/__init__.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/dispatch.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/effect_order.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/machine.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/pcode.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/pcode_backend.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/pe.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/reports.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/result_flow.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/trace.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/src/scientific_method_engine/x86/values.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/oracle.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_dispatch.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_effect_order.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_nested_frame_request.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_oracle.py +0 -0
- {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_table_continuations.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: scientific-method-engine
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Bounded instruction-derived x86 evidence reports for segmented MZ/FBOV and PE32/i386 code.
|
|
5
5
|
Project-URL: Source, https://github.com/kibertoad/refurbished-dinosaurs-toolkit/tree/main/packages/scientific-method-engine
|
|
6
6
|
Author: kibertoad
|
|
@@ -9,6 +9,7 @@ License-File: LICENSE
|
|
|
9
9
|
Requires-Python: >=3.12
|
|
10
10
|
Requires-Dist: capstone==5.0.7
|
|
11
11
|
Requires-Dist: pypcode==4.0.0
|
|
12
|
+
Requires-Dist: xxhash==4.0.1
|
|
12
13
|
Provides-Extra: test
|
|
13
14
|
Requires-Dist: unicorn==2.1.4; extra == 'test'
|
|
14
15
|
Description-Content-Type: text/markdown
|
|
@@ -5,13 +5,13 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scientific-method-engine"
|
|
7
7
|
# The release workflow writes the published version from the package's release tag.
|
|
8
|
-
version = "0.
|
|
8
|
+
version = "1.0.0"
|
|
9
9
|
description = "Bounded instruction-derived x86 evidence reports for segmented MZ/FBOV and PE32/i386 code."
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3.12"
|
|
12
12
|
license = "MIT"
|
|
13
13
|
authors = [{ name = "kibertoad" }]
|
|
14
|
-
dependencies = ["capstone==5.0.7", "pypcode==4.0.0"]
|
|
14
|
+
dependencies = ["capstone==5.0.7", "pypcode==4.0.0", "xxhash==4.0.1"]
|
|
15
15
|
|
|
16
16
|
[project.optional-dependencies]
|
|
17
17
|
# Unicorn is the tests' concrete oracle (ADR 0003, decision 4). Its core is GPLv2, so it never
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"""Bounded explicit code mappings. No guessed linear disassembly domains."""
|
|
2
|
-
import
|
|
2
|
+
import re
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
import xxhash
|
|
4
5
|
from capstone import Cs, CS_ARCH_X86, CS_MODE_16, CS_MODE_32
|
|
5
6
|
from .pe import prepare_pe
|
|
6
7
|
import capstone
|
|
7
8
|
|
|
8
9
|
MAX_SOURCE = 256 * 1024 * 1024
|
|
10
|
+
XXH3_FORM = re.compile("[0-9a-f]{32}")
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
def integer(value, low, high, label):
|
|
@@ -17,21 +19,28 @@ def integer(value, low, high, label):
|
|
|
17
19
|
def read_source(config, base):
|
|
18
20
|
"""Read the source a report config names and check its hash.
|
|
19
21
|
|
|
20
|
-
``config["source"]`` is a path relative to ``base``; the file must be at most 256 MiB and
|
|
21
|
-
``config["
|
|
22
|
-
|
|
22
|
+
``config["source"]`` is a path relative to ``base``; the file must be at most 256 MiB and its
|
|
23
|
+
XXH3-128 hash must equal ``config["xxh3"]``, given as 32 lower-case hex digits. A config that
|
|
24
|
+
still names a ``sha256`` is refused, so a hash from before prepared-config protocol 2 is never
|
|
25
|
+
taken as checked. Returns ``(data, identity)`` where ``identity`` is
|
|
26
|
+
``{"size": ..., "xxh3": ...}``. Raises ``ValueError`` otherwise.
|
|
23
27
|
"""
|
|
24
28
|
path = config.get("source")
|
|
25
29
|
if not isinstance(path, str) or not path:
|
|
26
30
|
raise ValueError("source path required")
|
|
31
|
+
if "sha256" in config:
|
|
32
|
+
raise ValueError("sha256 is no longer read; name the source by its xxh3 (prepared-config protocol 2)")
|
|
33
|
+
expected = config.get("xxh3")
|
|
34
|
+
if not isinstance(expected, str) or not XXH3_FORM.fullmatch(expected):
|
|
35
|
+
raise ValueError("xxh3 must be the source's XXH3-128 hash as 32 lower-case hex digits")
|
|
27
36
|
path = Path(base) / path
|
|
28
37
|
if not path.is_file() or path.stat().st_size > MAX_SOURCE:
|
|
29
38
|
raise ValueError("source must be a regular file of at most 256 MiB")
|
|
30
39
|
data = path.read_bytes()
|
|
31
|
-
digest =
|
|
32
|
-
if digest !=
|
|
33
|
-
raise ValueError("Source
|
|
34
|
-
return data, {"size": len(data), "
|
|
40
|
+
digest = xxhash.xxh3_128_hexdigest(data)
|
|
41
|
+
if digest != expected:
|
|
42
|
+
raise ValueError("Source xxh3 differs from the supplied baseline")
|
|
43
|
+
return data, {"size": len(data), "xxh3": digest}
|
|
35
44
|
|
|
36
45
|
|
|
37
46
|
class Image:
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"""PE32 acceptance uses constructed headers and instructions only."""
|
|
2
|
-
import hashlib
|
|
3
2
|
import json
|
|
4
3
|
import os
|
|
5
4
|
from pathlib import Path
|
|
@@ -9,6 +8,8 @@ import sys
|
|
|
9
8
|
import tempfile
|
|
10
9
|
import unittest
|
|
11
10
|
|
|
11
|
+
import xxhash
|
|
12
|
+
|
|
12
13
|
SRC = Path(__file__).resolve().parents[1] / "src"
|
|
13
14
|
sys.path.insert(0, str(SRC))
|
|
14
15
|
# The engine CLI runs from this checkout's source whether or not the package is installed.
|
|
@@ -152,7 +153,7 @@ class PEReporterTests(unittest.TestCase):
|
|
|
152
153
|
with tempfile.TemporaryDirectory() as directory:
|
|
153
154
|
path = Path(directory)
|
|
154
155
|
(path / 'source.bin').write_bytes(data)
|
|
155
|
-
config.update(source='source.bin',
|
|
156
|
+
config.update(source='source.bin', xxh3=xxhash.xxh3_128_hexdigest(data), regions=[1])
|
|
156
157
|
(path / 'config.json').write_text(json.dumps(config))
|
|
157
158
|
process = subprocess.run([*ENGINE, 'trace', str(path / 'config.json')],
|
|
158
159
|
capture_output=True, text=True, env=ENGINE_ENV)
|
|
@@ -324,13 +325,13 @@ class PEReporterTests(unittest.TestCase):
|
|
|
324
325
|
with tempfile.TemporaryDirectory() as directory:
|
|
325
326
|
path = Path(directory)
|
|
326
327
|
(path / 'source.bin').write_bytes(data)
|
|
327
|
-
config.update(source='source.bin',
|
|
328
|
+
config.update(source='source.bin', xxh3=xxhash.xxh3_128_hexdigest(data))
|
|
328
329
|
environment = {**ENGINE_ENV, 'EVIDENCE_PYTHON': sys.executable}
|
|
329
330
|
(path / 'config.json').write_text(json.dumps(config))
|
|
330
331
|
process = subprocess.run(['node', str(READER), 'trace', str(path / 'config.json')], capture_output=True, text=True, env=environment)
|
|
331
332
|
self.assertEqual(process.returncode, 0, process.stderr)
|
|
332
333
|
r = json.loads(process.stdout)
|
|
333
|
-
self.assertEqual(r['sourceIdentity']['
|
|
334
|
+
self.assertEqual(r['sourceIdentity']['xxh3'], config['xxh3'])
|
|
334
335
|
self.assertEqual(r['sourceMapping']['format'], 'PE32/i386')
|
|
335
336
|
config['regions'][0]['ip'] = CODE_VA + 1
|
|
336
337
|
(path / 'config.json').write_text(json.dumps(config))
|
|
@@ -8,6 +8,8 @@ import sys
|
|
|
8
8
|
import tempfile
|
|
9
9
|
import unittest
|
|
10
10
|
|
|
11
|
+
import xxhash
|
|
12
|
+
|
|
11
13
|
SRC = Path(__file__).resolve().parents[1] / "src"
|
|
12
14
|
sys.path.insert(0, str(SRC))
|
|
13
15
|
# The engine CLI runs from this checkout's source whether or not the package is installed.
|
|
@@ -1525,20 +1527,33 @@ class ReporterTests(unittest.TestCase):
|
|
|
1525
1527
|
with tempfile.TemporaryDirectory() as folder:
|
|
1526
1528
|
root = Path(folder); data = bytes.fromhex("b8 01 00 c3")
|
|
1527
1529
|
(root/"fixture.bin").write_bytes(data)
|
|
1528
|
-
cfg = configuration(data, source="fixture.bin",
|
|
1530
|
+
cfg = configuration(data, source="fixture.bin", xxh3=xxhash.xxh3_128_hexdigest(data))
|
|
1529
1531
|
path = root/"config.json"; path.write_text(json.dumps(cfg))
|
|
1530
1532
|
args = [*ENGINE, "trace", str(path)]
|
|
1531
1533
|
result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
|
|
1532
1534
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
1533
1535
|
header = json.loads(result.stdout)
|
|
1534
|
-
self.assertEqual(header["sourceIdentity"]
|
|
1536
|
+
self.assertEqual(header["sourceIdentity"], {"size": 4, "xxh3": cfg["xxh3"]})
|
|
1535
1537
|
self.assertEqual((header["decoder"], header["instructionSemantics"]),
|
|
1536
1538
|
("capstone " + capstone.__version__, f"pypcode {pypcode.__version__} (Ghidra SLEIGH x86)"))
|
|
1537
|
-
cfg["
|
|
1539
|
+
cfg["xxh3"] = "0" * 32; path.write_text(json.dumps(cfg))
|
|
1538
1540
|
result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
|
|
1539
1541
|
self.assertEqual(result.returncode, 1)
|
|
1540
1542
|
self.assertIn("baseline", result.stderr)
|
|
1541
|
-
|
|
1543
|
+
# A SHA-256, an upper-case or a missing hash is not the standard's form.
|
|
1544
|
+
for value in ("0" * 64, xxhash.xxh3_128_hexdigest(data).upper(), None):
|
|
1545
|
+
with self.subTest(xxh3=value):
|
|
1546
|
+
path.write_text(json.dumps({**cfg, "xxh3": value}))
|
|
1547
|
+
result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
|
|
1548
|
+
self.assertEqual(result.returncode, 1)
|
|
1549
|
+
self.assertIn("32 lower-case hex digits", result.stderr)
|
|
1550
|
+
# A protocol 1 hash is refused beside a correct xxh3, so it is never taken as checked.
|
|
1551
|
+
path.write_text(json.dumps({**cfg, "xxh3": xxhash.xxh3_128_hexdigest(data),
|
|
1552
|
+
"sha256": hashlib.sha256(data).hexdigest()}))
|
|
1553
|
+
result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
|
|
1554
|
+
self.assertEqual(result.returncode, 1)
|
|
1555
|
+
self.assertIn("sha256 is no longer read", result.stderr)
|
|
1556
|
+
cfg["xxh3"] = xxhash.xxh3_128_hexdigest(data); cfg["overlayExports"] = []
|
|
1542
1557
|
path.write_text(json.dumps(cfg))
|
|
1543
1558
|
result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
|
|
1544
1559
|
self.assertEqual(result.returncode, 1)
|
|
@@ -1548,15 +1563,15 @@ class ReporterTests(unittest.TestCase):
|
|
|
1548
1563
|
with tempfile.TemporaryDirectory() as folder:
|
|
1549
1564
|
root = Path(folder); data = bytes.fromhex("b8 01 00 c3")
|
|
1550
1565
|
(root/"fixture.bin").write_bytes(data)
|
|
1551
|
-
cfg = configuration(data, source=str(root/"fixture.bin"),
|
|
1566
|
+
cfg = configuration(data, source=str(root/"fixture.bin"), xxh3=xxhash.xxh3_128_hexdigest(data))
|
|
1552
1567
|
stdin = [*ENGINE, "trace", "-"]
|
|
1553
|
-
for protocol, accepted in ((None, False), (
|
|
1568
|
+
for protocol, accepted in ((None, False), (1, False), (2, True)):
|
|
1554
1569
|
prepared = dict(cfg) if protocol is None else {**cfg, "preparedProtocol": protocol}
|
|
1555
1570
|
result = subprocess.run(stdin, input=json.dumps(prepared), capture_output=True, text=True, env=ENGINE_ENV)
|
|
1556
1571
|
self.assertEqual(result.returncode, 0 if accepted else 1, result.stderr)
|
|
1557
1572
|
if not accepted:
|
|
1558
1573
|
self.assertIn("protocol", result.stderr)
|
|
1559
|
-
path = root/"config.json"; path.write_text(json.dumps({**cfg, "preparedProtocol":
|
|
1574
|
+
path = root/"config.json"; path.write_text(json.dumps({**cfg, "preparedProtocol": 2}))
|
|
1560
1575
|
result = subprocess.run([*ENGINE, "trace", str(path)], capture_output=True, text=True, env=ENGINE_ENV)
|
|
1561
1576
|
self.assertEqual(result.returncode, 1)
|
|
1562
1577
|
self.assertIn("set by the reader", result.stderr)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_effect_order.py
RENAMED
|
File without changes
|
{scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_nested_frame_request.py
RENAMED
|
File without changes
|
|
File without changes
|
{scientific_method_engine-0.9.1 → scientific_method_engine-1.0.0}/tests/test_table_continuations.py
RENAMED
|
File without changes
|