SourceSync is both a set of plugins for synchronisation between debugger and decompiler and a library for generating pdb from decompiler data. In the case of plugins, it establishes a connection between the debugger (Windbg, client) and the decompiler (Ida Pro, server) to dynamically generate pdb for functions in the current thread call stack that belong to the decompiled module.
Generated pdb contains information about:
- Structs/Unions/Enums
- Public symbols
- Global variables and their types
- Mapping between assembly and decompiler function pseudo code lines
- Function variables from pseudo code and their types
In case of library it provides both c++ and python api to generate pdb from arbitrary data.
The entire project consists of:
PdbGeneratorPy is python wrapper for c++ code used to generate pdb based on provided data.
SourceSync\Ida
is python based plugin for IDA Pro which extracts required data to generate pdb.
SourceSync\SourceSyncServer.py
is python (decompiler independent) grpc server which is responsible for whole communication/synchronisation between debugger and decompiler.
SourceSync\SourceSyncClient.cpp
is c++ (debugger independent) grpc client which is responsible for sending and fetching necessary data for generating a pdb for thread callstack.
Is c++ plugin for windbg used for synchronisation with decompiler.
This short video shows how SourceSync works when reverse engineering the ntoskrnl.exe!MiReadWriteVirtualMemory function
Example.webm
Supported architectures:
- x86_64
- x86
Supported decompilers:
- IDA Pro
Supported debuggers:
- Windbg
- Copy content of IdaPlugin folder into
C:\Program Files\IDA Pro xxx\plugins
directory
- Change
PE_LOAD_ALL_SECTIONS
inC:\Program Files\IDA Pro xxx\cfg\pe.cfg
formNO
toYES
. For idb that have already been generated without this SourceSync will not work. If you want it to work without re-generating the whole idb, use theTools\PeHeaderCreator.py
script inside IDA (the original .exe file must be in the same directory as the idb).
- Install python requirements
pip install -r requirements.txt
- Rename one of existing versions of
PdbGeneratorPy.python_version.pyd
toPdbGeneratorPy.pyd
to match the currently selected python version used in IDA Pro.
Copy WindbgSync.dll into %localappdata%\Microsoft\WindowsApps
- Launch/Attach to target
- Load extension
.load WindbgSync
- Synchronise with decompiler
!EnableSync
Supported commands:
!EnableSync
- Try to synchronise with decompiler!EnableSync 'ModuleName'
- Used when decompiled .exe file name is different from module name in windbg, e.g. in ntoskrnl.exe!DisableSync
- Disable synchronisation!RestartSync
- Restart synchornisation i.e. perform disable and enable sync.!RestartSync 'ModuleName'
- Used when decompiled .exe file name is different from module name in windbg, e.g. in ntoskrnl.exe
There is also an optional configuration file called .srcsync where the host IP address and port can be defined. This should be located in the %userprofile% directory. If there is no configuration file, windbg will try to connect to the server using localhost as the host ip and 5111 as the port.
Open Edit/Plugins/SourceSync Plugin
If check box Synchronisation enable
is checked that means that synchronisation server is running and nothing more is needed to do.
In order to restart server you can click on Restart
button.
In order to generate pdb for whole file with all functions click Generate Pdb
(In case of large pe files it may take some time).
There is also an optional configuration file called .srcsync where the host IP address and port can be defined. This should be located in the idb or %userprofile% directory (the former takes precedence over the latter). If there is no configuration file, IDA Pro will create the server using localhost as the host ip and 5111 as the port.
Currently, the main limitation is that you can only have one server (one decompiler with running SourceSync), so if you want to change what is synchronised with the debugger, you need to disable the previous synchronisation before enabling the new one.
In order to build you need to:
- Create environment variable named %IDA_PYTHON% which value should point to location of python directory used by IDA Pro, in my case it is
%localappdata%\Programs\Python\Python311
- Download and configure vcpkg as c++ projects dependencies are managed with vcpkg manifests
- Select desired configuration and click Build Solution
- Go to build directory and follow Installation
SourceSync is under Apache Version 2.0 license.