Skip to content

Commit caa6a62

Browse files
committed
📝 Create README for examples
1 parent d59be84 commit caa6a62

File tree

4 files changed

+69
-41
lines changed

4 files changed

+69
-41
lines changed

delphi_analyser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __repr__(self):
5757
def __str__(self):
5858
if not self._is_valid:
5959
return f'<InvalidVmt address=0x{self._vmt_address:08X}>'
60-
return f'<{self._class_name} start=0x{self.start:08X} size=0x{self._instance_size:X}>'
60+
return f'<{self._class_name} start=0x{self.start:08X} instance_size=0x{self._instance_size:X}>'
6161

6262

6363
## Properties

examples/README.md

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,92 @@
11
# Examples
22

3-
## list_class.py
3+
## list_vmts.py
44

55
**Description**:
66

7-
TODO
7+
A simple script displaying all VMTs found for a Delphi binary.
8+
It displays, for each VMT, its start address as well as the size of the instances of its class.
89

9-
**Example**:
10+
**Dependencies**:
1011

11-
> python3 list_class.py binary.exe 7
12+
- N/A
13+
14+
**Usage**:
15+
16+
> python3 examples/list_vmts.py
17+
Usage: examples/list_vmts.py <file_name> <delphi_version>
18+
19+
> python3 examples/list_vmts.py binary.exe 7
1220
<DelphiNinja> [13:37:42.724] [InfoLog] File loaded
1321
<DelphiNinja> [13:37:42.724] [InfoLog] -----------------------------
1422
<DelphiNinja> [13:37:42.725] [InfoLog] Searching for VMT...
15-
<DelphiNinja> [13:37:42.730] [InfoLog] <TObject start=0x00401058 size=0x4>
16-
<DelphiNinja> [13:37:42.763] [InfoLog] <Exception start=0x00404F20 size=0xC>
17-
<DelphiNinja> [13:37:42.764] [InfoLog] <EHeapException start=0x00404F88 size=0x10>
18-
<DelphiNinja> [13:37:42.765] [InfoLog] <EOutOfMemory start=0x00404FE4 size=0x10>
19-
<DelphiNinja> [13:37:42.765] [InfoLog] <EInOutError start=0x00405040 size=0x10>
20-
<DelphiNinja> [13:37:42.766] [InfoLog] <EExternal start=0x00405098 size=0x10>
21-
<DelphiNinja> [13:37:42.766] [InfoLog] <EExternalException start=0x004050F0 size=0x10>
22-
<DelphiNinja> [13:37:42.767] [InfoLog] <EIntError start=0x00405150 size=0x10>
23-
<DelphiNinja> [13:37:42.767] [InfoLog] <EDivByZero start=0x004051A8 size=0x10>
24-
<DelphiNinja> [13:37:42.768] [InfoLog] <ERangeError start=0x00405200 size=0x10>
25-
<DelphiNinja> [13:37:42.775] [InfoLog] <EIntOverflow start=0x00405258 size=0x10>
26-
<DelphiNinja> [13:37:42.781] [InfoLog] <EMathError start=0x004052B4 size=0x10>
27-
<DelphiNinja> [13:37:42.782] [InfoLog] <EInvalidOp start=0x0040530C size=0x10>
28-
<DelphiNinja> [13:37:42.786] [InfoLog] <EZeroDivide start=0x00405364 size=0x10>
29-
<DelphiNinja> [13:37:42.812] [InfoLog] <EOverflow start=0x004053BC size=0x10>
30-
<DelphiNinja> [13:37:42.820] [InfoLog] <EUnderflow start=0x00405414 size=0x10>
31-
<DelphiNinja> [13:37:42.822] [InfoLog] <EInvalidPointer start=0x0040546C size=0x10>
32-
<DelphiNinja> [13:37:42.824] [InfoLog] <EInvalidCast start=0x004054C8 size=0xC>
33-
<DelphiNinja> [13:37:42.842] [InfoLog] <EConvertError start=0x00405524 size=0xC>
34-
<DelphiNinja> [13:37:42.843] [InfoLog] <EAccessViolation start=0x00405580 size=0x10>
35-
<DelphiNinja> [13:37:42.844] [InfoLog] <EPrivilege start=0x004055E0 size=0x10>
36-
<DelphiNinja> [13:37:42.845] [InfoLog] <EStackOverflow start=0x00405638 size=0x10>
37-
<DelphiNinja> [13:37:42.846] [InfoLog] <EControlC start=0x00405694 size=0x10>
38-
<DelphiNinja> [13:37:42.847] [InfoLog] <EVariantError start=0x004056EC size=0xC>
39-
<DelphiNinja> [13:37:42.848] [InfoLog] <EAssertionFailed start=0x00405748 size=0xC>
40-
<DelphiNinja> [13:37:42.849] [InfoLog] <EAbstractError start=0x004057A8 size=0xC>
41-
<DelphiNinja> [13:37:42.851] [InfoLog] <EIntfCastError start=0x00405804 size=0xC>
42-
<DelphiNinja> [13:37:42.868] [InfoLog] <ESafecallException start=0x00405860 size=0xC>
43-
44-
## vmt_visualize.py
23+
<DelphiNinja> [13:37:42.730] [InfoLog] <TObject start=0x00401058 instance_size=0x4>
24+
<DelphiNinja> [13:37:42.763] [InfoLog] <Exception start=0x00404F20 instance_size=0xC>
25+
<DelphiNinja> [13:37:42.764] [InfoLog] <EHeapException start=0x00404F88 instance_size=0x10>
26+
<DelphiNinja> [13:37:42.765] [InfoLog] <EOutOfMemory start=0x00404FE4 instance_size=0x10>
27+
<DelphiNinja> [13:37:42.765] [InfoLog] <EInOutError start=0x00405040 instance_size=0x10>
28+
<DelphiNinja> [13:37:42.766] [InfoLog] <EExternal start=0x00405098 instance_size=0x10>
29+
<DelphiNinja> [13:37:42.766] [InfoLog] <EExternalException start=0x004050F0 instance_size=0x10>
30+
<DelphiNinja> [13:37:42.767] [InfoLog] <EIntError start=0x00405150 instance_size=0x10>
31+
<DelphiNinja> [13:37:42.767] [InfoLog] <EDivByZero start=0x004051A8 instance_size=0x10>
32+
<DelphiNinja> [13:37:42.768] [InfoLog] <ERangeError start=0x00405200 instance_size=0x10>
33+
<DelphiNinja> [13:37:42.775] [InfoLog] <EIntOverflow start=0x00405258 instance_size=0x10>
34+
<DelphiNinja> [13:37:42.781] [InfoLog] <EMathError start=0x004052B4 instance_size=0x10>
35+
<DelphiNinja> [13:37:42.782] [InfoLog] <EInvalidOp start=0x0040530C instance_size=0x10>
36+
<DelphiNinja> [13:37:42.786] [InfoLog] <EZeroDivide start=0x00405364 instance_size=0x10>
37+
<DelphiNinja> [13:37:42.812] [InfoLog] <EOverflow start=0x004053BC instance_size=0x10>
38+
<DelphiNinja> [13:37:42.820] [InfoLog] <EUnderflow start=0x00405414 instance_size=0x10>
39+
<DelphiNinja> [13:37:42.822] [InfoLog] <EInvalidPointer start=0x0040546C instance_size=0x10>
40+
<DelphiNinja> [13:37:42.824] [InfoLog] <EInvalidCast start=0x004054C8 instance_size=0xC>
41+
<DelphiNinja> [13:37:42.842] [InfoLog] <EConvertError start=0x00405524 instance_size=0xC>
42+
<DelphiNinja> [13:37:42.843] [InfoLog] <EAccessViolation start=0x00405580 instance_size=0x10>
43+
<DelphiNinja> [13:37:42.844] [InfoLog] <EPrivilege start=0x004055E0 instance_size=0x10>
44+
<DelphiNinja> [13:37:42.845] [InfoLog] <EStackOverflow start=0x00405638 instance_size=0x10>
45+
<DelphiNinja> [13:37:42.846] [InfoLog] <EControlC start=0x00405694 instance_size=0x10>
46+
<DelphiNinja> [13:37:42.847] [InfoLog] <EVariantError start=0x004056EC instance_size=0xC>
47+
<DelphiNinja> [13:37:42.848] [InfoLog] <EAssertionFailed start=0x00405748 instance_size=0xC>
48+
<DelphiNinja> [13:37:42.849] [InfoLog] <EAbstractError start=0x004057A8 instance_size=0xC>
49+
<DelphiNinja> [13:37:42.851] [InfoLog] <EIntfCastError start=0x00405804 instance_size=0xC>
50+
<DelphiNinja> [13:37:42.868] [InfoLog] <ESafecallException start=0x00405860 instance_size=0xC>
51+
52+
## vmt_visualizer.py
4553

4654
**Description**:
4755

48-
TODO
56+
A script to graphically represent the inheritance of all classes for a Delphi binary.
57+
58+
**Dependencies**:
59+
60+
- pip install graphviz
61+
- Graphviz binaries ([https://graphviz.org/download/](https://graphviz.org/download/#executable-packages))
4962

50-
**Example**:
63+
**Usage**:
5164

52-
> python3 vmt_visualize.py binary.exe 7
65+
> python3 examples/vmt_visualizer.py
66+
Usage: examples/vmt_visualizer.py <file_name> <delphi_version>
67+
68+
> python3 examples/vmt_visualizer.py binary.exe 7
5369

5470
![graph](./assets/graph.png)
5571

5672
## create_vmt_struct.py
5773

5874
**Description**:
5975

60-
TODO
76+
This script finds the VMTs of a binary, creates the corresponding structures and saves them in a Binary Ninja (`.bndb`) database.
77+
It's the equivalent of the `DelphiNinja\Analyze current binary` command in graphical mode.
78+
79+
**Dependencies**:
80+
81+
- N/A
82+
83+
**Usage**:
6184

62-
**Example**:
85+
> python3 examples/create_vmt_structs.py
86+
Usage: examples/create_vmt_structs.py <file_name> <delphi_version>
6387

64-
> python3 create_vmt_struct.py binary.exe 7
88+
> python3 examples/create_vmt_structs.py binary.exe 7
89+
[...]
90+
<DelphiNinja> [13:37:42.089] [InfoLog] Saving database: `binary.exe.bndb`...
6591

6692
![graph](./assets/vmt_struct.png)

examples/assets/vmt_struct.png

334 KB
Loading

examples/create_vmt_structs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def main(target: str, delphi_version: int):
4848
finder.update_analysis_and_wait(lambda vmt: analyze_callback(vmt, bv))
4949

5050
bv.update_analysis_and_wait()
51+
52+
BNLogger.log(f'Saving database: `{target}.bndb`...')
5153
bv.create_database(f'{target}.bndb')
5254

5355

0 commit comments

Comments
 (0)