|
1 | | -# PyClassInformer # |
2 | | -#### Yet Another RTTI Parsing IDA plugin #### |
| 1 | +# PyClassInformer |
| 2 | +## Yet Another RTTI Parsing IDA plugin |
3 | 3 |  |
4 | 4 |
|
5 | 5 | PyClassInformer is an RTTI parser. Although there are several RTTI parsers such as Class Informer and SusanRTTI, and even IDA can also parse RTTI, I created this tool. It is because they cannot be used as libraries for parsing RTTI. IDA cannot easily manage class hierarchies such as checking them as a list and filtering the information, either. |
6 | 6 |
|
7 | | -**PyClassInformer can parse RTTI on binaries compiled by MSVC++ on x86 and x64**. Since it is written in IDAPython, you can run it on IDA for Mac OS and Linux as well as Windows. You can also use results of parsing RTTI in your python code by importing this tool as a library. |
| 7 | +**PyClassInformer can parse RTTI on PE formatted binaries compiled by MSVC++ for x86, x64, ARM and ARM64**. Since it is written in IDAPython, you can run it on IDA for Mac OS and Linux as well as Windows. You can also use results of parsing RTTI in your python code by importing this tool as a library. |
8 | 8 |
|
9 | | -### Usage ### |
| 9 | +## Usage |
10 | 10 | Launch it by pressing Alt+Shift+L. Or navigate to Edit -> Plugins -> PyClassInformer. |
| 11 | +Then, select the options. In most cases, the default options should remain unchanged. |
11 | 12 |
|
12 | | -### Installation ### |
| 13 | +## Installation |
13 | 14 | Put "pyclassinformer_plugin.py" and "pyclassinformer" folder including the files under it into the "plugins" folder of IDA's user directory ($IDAUSR). |
14 | 15 |
|
15 | 16 | See the URL if you don't know about "$IDAUSR". |
16 | 17 | [https://hex-rays.com/blog/igors-tip-of-the-week-33-idas-user-directory-idausr/](https://hex-rays.com/blog/igors-tip-of-the-week-33-idas-user-directory-idausr/) |
17 | 18 | [https://www.hex-rays.com/products/ida/support/idadoc/1375.shtml](https://www.hex-rays.com/products/ida/support/idadoc/1375.shtml) |
18 | 19 |
|
19 | | -### Requirements ### |
20 | | -- IDA Pro 7.4 or later (I tested on 7.4 SP1, 7.5 SP3, 8.0, 9.0 SP1 and 9.1) |
| 20 | +## Requirements |
| 21 | +- IDA Pro 7.4 or later (I tested on 7.4 SP1 to 9.1) |
21 | 22 | - Python 3.x (I tested on Python 3.8 and 3.10) |
22 | 23 |
|
23 | | -You will need at least IDA Pro 7.4 or later because of the APIs that I use. |
| 24 | +You will need at least IDA Pro 7.4 or later because of the APIs that I use. If you want to use full features, use IDA 8.3 or later. Otherwise, some features will be limited to use or skipped. |
24 | 25 |
|
25 | | -### Example Results ### |
| 26 | +## Features (short) |
| 27 | +- Display class names, vftables and class hierarchies as a list |
| 28 | +- Display RTTI parsed results on the Output window |
| 29 | +- Display vftables, class names, virtual methods, possilbe constructors and destructors, and class hierarchies as a dir tree (IDA 7.7 or later) |
| 30 | +- Create directories for classes and move virtual methods to them in Functions and Names subviews (IDA 7.7 or later) |
| 31 | +- Move functions refer vftables to "possible ctors or dtors" folder under each class directory in Functions and Names subviews (IDA 7.7 or later) |
| 32 | +- Rename virtual methods by appending class names to them |
| 33 | +- Add the FUNC_LIB flag to methods that known classes own |
| 34 | +- Rename possible constructors and destructors |
| 35 | +- Coloring known class names and their methods on the list and the tree widgets |
| 36 | + |
| 37 | +## Features in detail |
| 38 | +### Default output |
26 | 39 |  |
27 | | -The figure above is an example of PyClassInformer result. And the figure below is an example of the original Class Informer result. |
28 | | -As you see, almost all columns are matched with the original ones. |
| 40 | +The image above is an example of PyClassInformer result. And the image below is an example of the original Class Informer result. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +As you see, almost all columns match the original ones. |
29 | 45 |
|
30 | 46 | In addition, PyClassInformer has two more columns. One is "offset", which shows the offset of a vftable in a class layout. |
31 | 47 |
|
32 | | -Another one named "Hierarchy Order" shows class hierarchy information related to a vftable of a line. The column shows the order of inheritance from the class to the top-most super class. |
| 48 | +Another one named "Hierarchy Order" shows class hierarchy information related to a vftable of a line. The column shows the order of inheritance from the class to the top-most super class. |
33 | 49 |
|
34 | | -These are useful for grasping class layouts and class hierarchies. Double-clicking a line navigates to its vftable address as weiil. |
35 | | - |
36 | | - |
37 | | -If you check the Output subview, you will also see parsed RTTI information such as Complete Object Locator as COL, Class Hierarchy Descriptor as CHD and Base Class Descriptor as BCD with their addresses. They are useful for checking more details and debugging. |
| 50 | +These are useful for grasping class layouts and class hierarchies. Double-clicking a line navigates to its vftable address as well. |
38 | 51 |
|
| 52 | +### RTTI parsed results |
| 53 | +If you check the Output window, you will also see parsed RTTI information such as Complete Object Locator as COL, Class Hierarchy Descriptor as CHD and Base Class Descriptor as BCD with their addresses. They are useful for checking more details and debugging. |
| 54 | + |
39 | 55 |  |
| 56 | + |
40 | 57 | You will also see class hierarchies by checking indents of BCDs. For example, CMFCComObject, which is the class for the vftable at 0x530fcc, inherits ATL::CAccessibleProxy. And ATL::CAccessibleProxy inherits three super classes, ATL::CComObjectRootEx, ATL::IAccessibleProxyImpl and IOleWindow. Like this, you can get class hierarchy information as a form of a tree. |
41 | 58 |
|
42 | | -### Note ### |
| 59 | +### Automatic renaming |
| 60 | +PyClassInformer can automatically append class names to their virtual method names. Therefore, you can easily find them by filtering the class name. The image below is a result appending a class name "CDC" to its methods. |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +PyClassInformer can also rename functions that refer to vftables to "class name" + "_possible_ctor_or_dtor". The image below is a result. Although some false positives will occur due to inlined ctors and dtors, and dynamic initializers, this feature is still useful to find them. |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +### Virtual method classification (<= IDA 7.7) |
| 69 | +The detected methods are moved to each class folder in Functions and Names subviews. |
| 70 | +> [!NOTE] |
| 71 | +> This is only available IDA 7.7 or later. |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +PyClassInformer also displays a new widget named "Method Classifier". It lists all detected classes, vftables, virtual methods and possible constructors and destructors, and class herarchies at once as a form of a tree. |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +> [!TIP] |
| 80 | +> Class hierarchies are represented as directories in Method Classifier. |
| 81 | +> Unfortunaltely, IDA's quick filter feature cannot filter directory contents. |
| 82 | +> To search them, use text search feture (Ctrl+T (find first text) and Alt+T (Find next text)). |
| 83 | +> For example, input a class name, a single space, and a parenthesis like "CWinApp (". |
| 84 | +
|
| 85 | +> [!NOTE] |
| 86 | +> This is only available IDA 7.7 or later. |
| 87 | +
|
| 88 | +### Known classes detection (<= IDA 8.3) |
| 89 | +PyClassInformer can color known class names for easily finding user-defined classes. |
| 90 | +The image below is an example of a coloring result. |
| 91 | +You can easily find CSimpleTestApp, CSimpleTestDoc, CSimpleTestView and CSimpleTestCtrlItem are user-defined classes. So you can forcus on checking them. |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +The coloring is also applied to Method Classifier widget. Therefore, you can easily find overridden virtual methods like the image below. |
| 96 | + |
| 97 | + |
| 98 | +> [!NOTE] |
| 99 | +> The coloring feature is only available IDA 8.3 or later. |
| 100 | + |
| 101 | +Known class names are defined in "lib_classes.json". I added many patterns related to STL, which starts with "std::", and several versions of MFC Application with MFC Application Wizard. |
| 102 | +If you find some additional legitimate classes, you can add them to it. |
| 103 | + |
| 104 | +PyClassInformer also adds the FUNC_LIB flag to the methods that match the list. Therefore, you can recognize they are a part of static linked libraries. |
| 105 | +The following images are before and after PyClassInformer execution. Many known class methods are found and IDA can recognize them a part of static linked libraries. |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | +## Note |
43 | 111 | - I **WILL NOT** support parsing GCC's RTTI. **DO NOT** open an issue about it. |
44 | 112 | - I **WILL NOT** support beta versions of IDA. **DO NOT** open an issue about it. |
45 | 113 | - Some code is from SusanRTTI and the output table is similar to Class Informer. |
|
0 commit comments