scientific-method-engine 13.2.0__tar.gz → 13.3.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-13.2.0 → scientific_method_engine-13.3.0}/PKG-INFO +1 -1
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/pyproject.toml +1 -1
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/pe.py +18 -8
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_pe.py +41 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/.gitignore +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/LICENSE +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/README.md +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/__init__.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/__main__.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/cli.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ClearNoReturnFunctions.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/CreateFunctions.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ExportBoundedFlow.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ExportCallEdges.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ExportFunctionFingerprints.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ExportFunctionInventory.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/MergeFallThroughFragment.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/RecoverCitedFunctions.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/RepairReturningCallers.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportCallArguments.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportCallPaths.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportCallSitesWithScalars.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportCallsToRange.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportConstantFirstArgumentCalls.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportDataBytes.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportDecompileMatches.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportDecompileWindow.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportFilePatternInMemory.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportFirstArgumentCallSummary.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportFunctionScalarConstants.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportFunctionSummary.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportInstructionContext.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportInstructionWindow.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportMemoryBlockForFileOffset.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportMemoryBlocks.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportRandomnessCandidates.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportReferences.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportScalarConstants.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportStringReferences.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/ReportSymbolReferences.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/scientificmethod/FirstArgumentLookBack.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/scientificmethod/InstructionStart.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/ghidra/scientificmethod/OperandConstants.java +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/__init__.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/argument_frames.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/dispatch.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/effect_order.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/image.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/loops.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/machine.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/memory_scopes.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/pcode.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/pcode_backend.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/reach.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/relational.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/reports.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/result_flow.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/trace.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/src/scientific_method_engine/x86/values.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/oracle.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_continuation_budget.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_dispatch.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_effect_order.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_enter_frames.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_entry_frame.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_indirect_far_transfers.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_interrupt_models.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_loops.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_memory_scopes.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_nested_frame_request.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_oracle.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_reach.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_relational_controls.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_return_checks.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_successor_rule.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_table_continuations.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_term_limit.py +0 -0
- {scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_x86.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: scientific-method-engine
|
|
3
|
-
Version: 13.
|
|
3
|
+
Version: 13.3.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
|
|
@@ -5,7 +5,7 @@ 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 = "13.
|
|
8
|
+
version = "13.3.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"
|
|
@@ -9,9 +9,15 @@ def pe32(data):
|
|
|
9
9
|
``data`` is the whole file as bytes. Returns a dict with ``format``, ``imageBase``,
|
|
10
10
|
``sizeOfImage``, ``sizeOfHeaders``, ``mappingProvenance``, ``loadAssumption`` and ``sections``;
|
|
11
11
|
each section has ``index``, ``name``, ``rva``, ``va``, ``virtualSize``, ``rawStart``,
|
|
12
|
-
``rawSize``, ``loadedRawSize`` (raw bytes actually loaded), ``mappedExtent
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
``rawSize``, ``loadedRawSize`` (raw bytes actually loaded), ``mappedExtent``, ``rawIgnored`` and
|
|
13
|
+
``executable``. A section whose PointerToRawData is 0 has no file bytes: its SizeOfRawData still
|
|
14
|
+
counts toward ``mappedExtent``, its ``loadedRawSize`` is 0, and its ``rawIgnored`` says why
|
|
15
|
+
(None on every other section). ``rawStart`` and ``rawSize`` keep the header's PointerToRawData
|
|
16
|
+
and SizeOfRawData, so they name no file bytes there; ``loadedRawSize`` is the file extent to
|
|
17
|
+
read. What a loader puts in such a section is not assumed. Raises
|
|
18
|
+
``ValueError`` for anything other than an MZ-stubbed PE32 for i386, and for truncated,
|
|
19
|
+
overlapping or ambiguous sections, a nonzero PointerToRawData below SizeOfHeaders among them.
|
|
20
|
+
The mapping assumes the preferred image base; rebasing and imports are not simulated.
|
|
15
21
|
"""
|
|
16
22
|
def span(at, size):
|
|
17
23
|
if at < 0 or size < 0 or at + size > len(data):
|
|
@@ -47,22 +53,26 @@ def pe32(data):
|
|
|
47
53
|
at = table + i * 40
|
|
48
54
|
virtual_size, rva, raw_size, raw = (dword(at + j) for j in (8, 12, 16, 20))
|
|
49
55
|
extent = max(virtual_size, raw_size)
|
|
56
|
+
# A zero PointerToRawData gives the section no file bytes, whatever SizeOfRawData says.
|
|
57
|
+
ignored = "PointerToRawData is 0" if raw_size and not raw else None
|
|
58
|
+
file_size = 0 if ignored else raw_size
|
|
50
59
|
# Raw bytes past VirtualSize are file-alignment padding, not loaded source.
|
|
51
|
-
loaded = min(
|
|
60
|
+
loaded = min(file_size, virtual_size) if virtual_size else file_size
|
|
52
61
|
if not extent or rva < headers or rva + extent > size:
|
|
53
62
|
raise ValueError("PE section escapes image or overlaps headers")
|
|
54
|
-
if
|
|
55
|
-
span(raw,
|
|
63
|
+
if file_size:
|
|
64
|
+
span(raw, file_size)
|
|
56
65
|
if raw < headers:
|
|
57
66
|
raise ValueError("PE section raw bytes overlap headers")
|
|
58
67
|
section = {"index": i, "name": data[at:at + 8].split(b'\0')[0].decode('ascii', errors='replace'),
|
|
59
68
|
"rva": rva, "va": base + rva, "virtualSize": virtual_size,
|
|
60
69
|
"rawStart": raw, "rawSize": raw_size, "loadedRawSize": loaded, "mappedExtent": extent,
|
|
61
|
-
"executable": bool(dword(at + 36) & 0x20000000)}
|
|
70
|
+
"rawIgnored": ignored, "executable": bool(dword(at + 36) & 0x20000000)}
|
|
62
71
|
for prior in sections:
|
|
63
72
|
if max(rva, prior['rva']) < min(rva + extent, prior['rva'] + prior['mappedExtent']):
|
|
64
73
|
raise ValueError("Ambiguous PE virtual section mapping")
|
|
65
|
-
|
|
74
|
+
prior_size = 0 if prior['rawIgnored'] else prior['rawSize']
|
|
75
|
+
if file_size and prior_size and max(raw, prior['rawStart']) < min(raw + file_size, prior['rawStart'] + prior_size):
|
|
66
76
|
raise ValueError("Overlapping PE raw sections")
|
|
67
77
|
sections.append(section)
|
|
68
78
|
return {"format": "PE32/i386", "imageBase": base, "sizeOfImage": size,
|
|
@@ -365,6 +365,47 @@ class PEReporterTests(unittest.TestCase):
|
|
|
365
365
|
with self.assertRaises(ValueError):
|
|
366
366
|
Image(data, {**config, 'regions': [{**config['regions'][0], 'end': CODE_RAW + 0x11}]})
|
|
367
367
|
|
|
368
|
+
def test_a_zero_raw_pointer_gives_a_section_no_file_bytes(self):
|
|
369
|
+
# .text (raw 0x400), .bss (SizeOfRawData 0x200, PointerToRawData 0) and .data (raw 0x600),
|
|
370
|
+
# all with VirtualSize 0, behind 0x400 bytes of headers.
|
|
371
|
+
data = bytearray(0x800)
|
|
372
|
+
def d(at, n):
|
|
373
|
+
struct.pack_into('<I', data, at, n)
|
|
374
|
+
data[:2] = b'MZ'; d(60, 0x80); data[0x80:0x84] = b'PE\0\0'
|
|
375
|
+
struct.pack_into('<HH', data, 0x84, 0x14c, 3); struct.pack_into('<H', data, 0x94, 0xe0)
|
|
376
|
+
opt = 0x98
|
|
377
|
+
struct.pack_into('<H', data, opt, 0x10b); d(opt + 28, BASE); d(opt + 56, 0x4000); d(opt + 60, 0x400); d(opt + 92, 16)
|
|
378
|
+
for at, name, rva, raw, flags in ((0x178, b'.text', 0x1000, 0x400, 0x60000020),
|
|
379
|
+
(0x1a0, b'.bss', 0x2000, 0, 0xc0000080),
|
|
380
|
+
(0x1c8, b'.data', 0x3000, 0x600, 0xc0000040)):
|
|
381
|
+
data[at:at + len(name)] = name
|
|
382
|
+
for off, n in ((12, rva), (16, 0x200), (20, raw), (36, flags)):
|
|
383
|
+
d(at + off, n)
|
|
384
|
+
code = bytes.fromhex('a1 00 20 40 00 b9 78 56 34 12 c3') # mov eax, [.bss]; mov ecx, 0x12345678
|
|
385
|
+
data[0x400:0x400 + len(code)] = code
|
|
386
|
+
config = {'sourceKind': 'pe32', 'entry': 0x400, 'regions': [{'name': 'text', 'start': 0x400, 'end': 0x400 + len(code),
|
|
387
|
+
'entries': [0x400], 'evidence': 'synthetic established entries'}]}
|
|
388
|
+
image = Image(bytes(data), config)
|
|
389
|
+
bss = image.config['peMetadata']['sections'][1]
|
|
390
|
+
self.assertEqual((bss['rawStart'], bss['rawSize'], bss['loadedRawSize'], bss['mappedExtent']), (0, 0x200, 0, 0x200))
|
|
391
|
+
self.assertEqual(bss['rawIgnored'], 'PointerToRawData is 0')
|
|
392
|
+
self.assertEqual([s['rawIgnored'] for s in image.config['peMetadata']['sections']], [None, 'PointerToRawData is 0', None])
|
|
393
|
+
# The headers at file offset 0 are not read as the section's bytes.
|
|
394
|
+
self.assertIsNone(image.file_offset(BASE + 0x2000))
|
|
395
|
+
r = run_report(bytes(data), config, 'trace')
|
|
396
|
+
self.assertTrue(r['completeWithinModel'], r)
|
|
397
|
+
registers = r['paths'][0]['registers']
|
|
398
|
+
self.assertEqual(registers['ecx']['value'], 0x12345678)
|
|
399
|
+
self.assertIsNone(registers['eax'].get('value'))
|
|
400
|
+
self.assertEqual(r['sourceMapping']['sections'][1]['rawIgnored'], 'PointerToRawData is 0')
|
|
401
|
+
# A region cannot be declared over the ignored bytes.
|
|
402
|
+
with self.assertRaisesRegex(ValueError, 'loaded raw executable section bytes'):
|
|
403
|
+
Image(bytes(data), {**config, 'regions': [{**config['regions'][0], 'start': 0, 'end': 0x10}]})
|
|
404
|
+
# A nonzero pointer below SizeOfHeaders is still refused.
|
|
405
|
+
low = bytearray(data); struct.pack_into('<I', low, 0x1a0 + 20, 0x200)
|
|
406
|
+
with self.assertRaisesRegex(ValueError, 'overlap headers'):
|
|
407
|
+
Image(bytes(low), config)
|
|
408
|
+
|
|
368
409
|
def test_malformed_regions_fail_with_a_diagnosable_error(self):
|
|
369
410
|
data, config = fixture('c3')
|
|
370
411
|
for regions in ({'name': 'text'}, [1], ['text'], [None]):
|
|
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
|
|
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-13.2.0 → scientific_method_engine-13.3.0}/tests/test_effect_order.py
RENAMED
|
File without changes
|
{scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_enter_frames.py
RENAMED
|
File without changes
|
{scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_entry_frame.py
RENAMED
|
File without changes
|
|
File without changes
|
{scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_interrupt_models.py
RENAMED
|
File without changes
|
|
File without changes
|
{scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_memory_scopes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_return_checks.py
RENAMED
|
File without changes
|
{scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_successor_rule.py
RENAMED
|
File without changes
|
|
File without changes
|
{scientific_method_engine-13.2.0 → scientific_method_engine-13.3.0}/tests/test_term_limit.py
RENAMED
|
File without changes
|
|
File without changes
|