Git Product home page Git Product logo

binsync's Introduction

BinSync

BinSync Logo

BinSync is a decompiler collaboration tool built on the Git versioning system to enable fined-grained reverse engineering collaboration regardless of decompiler. BinSync is built by mahaloz, the angr team, and the SEFCOM research lab. It's also due in large part to its use by the Shellphish hacking team.

All good decompilers share common objects called Reverse Engineering Artifacts (REAs). These REAs are the center of BinSync's syncing ability. Here are the supported REAs:

  • Function headers (symbol, args, type)
  • Stack Variables (symbol, type)
  • Structs
  • Enums
  • Comments

Note: all types support user-created types like structs.

Binja Sync

Join our discord below for more online help:

Discord

Quick Start

For all installs, it's best to use our two-part installer with Python:

pip3 install binsync && binsync --install 

BinSync is also available in the Binary Ninja plugin manager. If you plan on using BS with Ghidra, you need to also do pip3 install binsync[ghidra]. If you plan on using extra BS features, like the ChatGPT User, install the package like this: pip3 install binsync[extras], which will install extra packages for support. For full install information, please read our quickstart docs.

If you are planning on installing the package to be editable (-e), like in a developer install, make sure pip>=23.0.0.

Supported Platforms

  • IDA Pro: >= 7.3
  • Binary Ninja: >= 2.4
  • angr-management: >= 9.0
  • Ghidra: >= 10.1

All versions require Python >= 3.7 and Git installed on your system. Ghidra support is still very much in early stage, so only expect the minimal features like artifact name syncing and comments.

Decompiler Support Progress

Although we support the decompilers in the earlier section, not every decompiler is supported at the same level of syncing. To understand the difference between artifact support, pull, push, and auto push, read our decompiler use introduction.

IDA Pro

Operations     Function Headers     Stack Vars     Global Vars     Structs     Enums     Comments    
Symbols
Types
Pull
Push
Auto Push

IDA Sync

Binary Ninja

Operations     Function Headers     Stack Vars     Global Vars     Structs     Enums     Comments    
Symbols
Types
Pull
Push
Auto Push

Binja Sync

Ghidra

Operations     Function Headers     Stack Vars     Global Vars     Structs     Enums     Comments    
Symbols
Types
Pull
Push
Auto Push

Ghidra Sync

angr-management

Operations     Function Headers     Stack Vars     Global Vars     Structs     Enums     Comments    
Symbols
Types
Pull
Push
Auto Push

Scripting

For scripting please see Lib BinSync, which allows you to do all lifting and data manipulation in Python.

binsync's People

Contributors

adamdoupe avatar antoniobianchi333 avatar capysix avatar cl4sm avatar coldmeekly avatar crowell avatar endeav0r avatar flipout50 avatar frqmod avatar hexf avatar jjjollyjim avatar justin-kereszturi avatar ltfish avatar lukas-dresel avatar mahaloz avatar mborgerson avatar pascal-0x90 avatar realdonkey avatar rhelmot avatar saagarjha avatar tiffanyb avatar tr1shul avatar twizmwazin avatar unknowntrojan avatar zachsez avatar zardus avatar zwimer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binsync's Issues

Function Refactor

  • remove comments from func header
  • comments should be global items
  • functions should have a size
  • update fill_function in all plugins for the new format

Ghidra: Support

This will be non-trivial to do:

  • Ghidra supports Jython, which is only Python 2.
  • Ghidra is mostly Java

The infrastructure should be something like this:

  • Use the ghidra-bridge for Python3 support to send commands that will be evaluated in Python2
    • This will require us to write a Python client program to connect to the Ghidra server.
  • Write the GUI for Ghidra in Python (I am open to ideas for a good Java one)
  • Try to use the change hooking/callback approach for pushing from Ghidra

last_push shown in panel on the right is incorrect

Background

There is currently a bug where if someone pulls from another user it will pull the changes, write those changes to their local state, and commit it back to the repo on their state. This so far is correct behavior. The bug is that when the commit back to the remote happens it marks it in the pulling user's metadata that they did a new push (because they just edited their own state). This causes the table that shows the latest pushes to now show the user that did the latest pull as the latest pusher (because they are the person to most recently push).

This problem is a deep issue in changes caused by pulling from binsync in ida causes the ida API to trigger a write (as it should), but this is shown as the user making a new write when indeed it was actually the API pulling someone else's.

Proposed Fix

First, take a look at the comment in the IDA Plugin's controller (in sync_all) function. The idea is that since we always know how many "push" operations happen after a "pull", we could create a semaphore that increments as many times as we are about to push. This way, anytime the semaphore is greater than 0, we pass a special parameter out of the IDA hook that causes it to not update the time change.

Feat: Support Struct Syncing in Binja

Open phonebook in binja, sync person_t from the globals tab

  File "/home/honululu/lukas/tools/binsync/binsync/common/ui/tables/ctx_table.py", line 110, in <lambda>
    menu.addAction("Sync", lambda: self.controller.fill_function(func_addr, user=username))
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 26, in initcheck
    return f(self, *args, **kwargs)
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 93, in state_check
    return f(self, *args, **kwargs)
  File "/home/honululu/.binaryninja/plugins/binja_binsync/controller.py", line 159, in fill_function
    type_, _ = bn_func.view.parse_type_string(stack_var.type)
  File "/home/honululu/lukas/tools/binja/binaryninja/plugins/../python/binaryninja/binaryview.py", line 6173, in parse_type_string
    raise SyntaxError(error_str)
SyntaxError: input:1: error: type 'person_t' is not defined
Traceback (most recent call last):
  File "/home/honululu/lukas/tools/binsync/binsync/common/ui/tables/globals_table.py", line 110, in <lambda>
    filler_func = lambda: self.controller.fill_struct(global_name, user=user_name)
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 26, in initcheck
    return f(self, *args, **kwargs)
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 93, in state_check
    return f(self, *args, **kwargs)
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 315, in fill_struct
    raise NotImplementedError
NotImplementedError

Binja syncing results in SyntaxError

Open phonebook in binja, go to the runner function, hit sync on honululu's version

Traceback (most recent call last):
  File "/home/honululu/lukas/tools/binsync/binsync/common/ui/tables/ctx_table.py", line 110, in <lambda>
    menu.addAction("Sync", lambda: self.controller.fill_function(func_addr, user=username))
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 26, in initcheck
    return f(self, *args, **kwargs)
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 93, in state_check
    return f(self, *args, **kwargs)
  File "/home/honululu/.binaryninja/plugins/binja_binsync/controller.py", line 158, in fill_function
    type_, _ = bn_func.view.parse_type_string(stack_var.type)
  File "/home/honululu/lukas/tools/binja/binaryninja/plugins/../python/binaryninja/binaryview.py", line 6173, in parse_type_string
    raise SyntaxError(error_str)
SyntaxError: input:1: error: syntax error

IDA crash in struct members

Version: 2.1.0

Traceback (most recent call last):
  File "/Applications/IDA Pro 7.7/ida64.app/Contents/MacOS/plugins/ida_binsync/hooks.py", line 62, in initcheck
    return f(self, *args, **kwargs)
  File "/Applications/IDA Pro 7.7/ida64.app/Contents/MacOS/plugins/ida_binsync/hooks.py", line 203, in struc_member_renamed
    stack_var_info = compat.get_func_stack_var_info(func_addr)[mptr.soff]
KeyError: 24

BinSync Repo: https://github.com/mahaloz/dreamland
Platform: IDA Pro 7.7
Challenge: dreamland (the patched version)
Function: 0x1349
Action: Sync

Options Panel

We need an options panel in the control panel that allows one to access some runtime options like:

  • Syncing Level
  • Debug Level
  • Shutting down BinSync

Here is a mockup of the design:
IMG_D1E0DDC6A3B8-1

This update can come after #67 if we are strapped for time.

IDA structs not supporting more nested types

Reproduction Info

BinSync Repo: https://github.com/mahaloz/dreamland
Platform: IDA Pro 7.7
Challenge: dreamland (the patched version)
Function: 0x1c27
Action: Sync
Binary: #107 same binary

Crash

Traceback (most recent call last):
  File "/Users/mahaloz/github/binsync/binsync/common/ui/tables/functions_table.py", line 101, in <lambda>
    menu.addAction("Sync", lambda: self.controller.fill_function(func_addr, user=self.item(selected_row, 2).text()))
  File "/Users/mahaloz/github/binsync/binsync/common/controller.py", line 26, in initcheck
    return f(self, *args, **kwargs)
  File "/Users/mahaloz/github/binsync/binsync/common/controller.py", line 93, in state_check
    return f(self, *args, **kwargs)
  File "/Applications/IDA Pro 7.7/ida64.app/Contents/MacOS/plugins/ida_binsync/controller.py", line 285, in fill_function
    data_changed |= self.fill_structs(user=user, state=state)
  File "/Users/mahaloz/github/binsync/binsync/common/controller.py", line 26, in initcheck
    return f(self, *args, **kwargs)
  File "/Users/mahaloz/github/binsync/binsync/common/controller.py", line 93, in state_check
    return f(self, *args, **kwargs)
  File "/Applications/IDA Pro 7.7/ida64.app/Contents/MacOS/plugins/ida_binsync/controller.py", line 219, in fill_structs
    data_changed |= compat.set_ida_struct(struct, self)
  File "/Applications/IDA Pro 7.7/ida64.app/Contents/MacOS/plugins/ida_binsync/compat.py", line 101, in wrapper
    thunk()
  File "/Applications/IDA Pro 7.7/ida64.app/Contents/MacOS/plugins/ida_binsync/compat.py", line 97, in thunk
    output[0] = func(*args, **kwargs)
  File "/Applications/IDA Pro 7.7/ida64.app/Contents/MacOS/plugins/ida_binsync/compat.py", line 462, in set_ida_struct
    data_changed |= ida_struct.add_struc_member(
  File "/Applications/IDA Pro 7.7/ida64.app/Contents/MacOS/python/3/ida_struct.py", line 922, in add_struc_member
    return _ida_struct.add_struc_member(*args)
TypeError: in method 'add_struc_member', argument 4 of type 'flags_t'

Speculation

I think this happens because the flags passed is not actually a flags_t and we need real support for converting nested types into a real flags_t in ida plugin

Post DEF CON Quals Refactor

Background

During the run-up to DEF CON quals (May 27), lots of rapid changes are happing in the Core that is only used fully in the IDA plugin. This issue is a list of items we need to port to the other decompilers after quals.

Items

  • goto_address for all plugins (#127)
  • enum support (#104)
  • type conversion across decompiler (#125)

Missing positional argument

Triggered when hitting Sync in the Globals tab

INFO | 2022-04-17 19:52:18,489 | ida_binsync.controller | New data synced for 'redgate' on function 0x1842.
Traceback (most recent call last):
  File "/home/honululu/lukas/tools/binsync/binsync/common/ui/tables/globals_table.py", line 110, in <lambda>
    filler_func = lambda: self.controller.fill_struct(global_name, user=user_name)
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 26, in initcheck
    return f(self, *args, **kwargs)
  File "/home/honululu/lukas/tools/binsync/binsync/common/controller.py", line 93, in state_check
    return f(self, *args, **kwargs)
  File "/home/honululu/lukas/tools/ida/idapro-7.6.2/plugins/ida_binsync/controller.py", line 212, in fill_struct
    compat.set_ida_struct(struct)
  File "/home/honululu/lukas/tools/ida/idapro-7.6.2/plugins/ida_binsync/compat.py", line 101, in wrapper
    thunk()
  File "/home/honululu/lukas/tools/ida/idapro-7.6.2/plugins/ida_binsync/compat.py", line 97, in thunk
    output[0] = func(*args, **kwargs)
TypeError: set_ida_struct() missing 1 required positional argument: 'controller'

Feat: Manual Merging

UI

For merging, we should display a single function in the declaration style of C. We can show which variable has been changed by highlighting them and making them clickable, allowing users to select which version of the change they would like.

merging

Large User Testcase

We should have a large test case that does like 20 users in the core and uses structs with possible
dependencies on other structs.

IDA: support better UNDO operations

When an undo occurs, support changing the BinSync state back to the state it was pre-last-operation. This may be harder since we will need to keep a history of changes either in memory or through the commit history.

Feat: Magic Sync

When a user first connects to a project, we should automatically (or with an ask), try to pull all the most relevant data from other users that have done work on functions this user has not.

IDA: add type syncing for variables

For IDA to really be useful, we need to be able to pull over types of variables, not just their names.

The most common example of this is casting a variable to a struct pointer of a custom struct that you have defined.

Need Harder Testing Binaries

Currently we only have fauxware, but we really ought to try some harder more messed up binaries, like the ones from DEF CON Finals 2021 as mentioned in #52.

Feat: Type Engine - Convert Types to C

Since we are using types between IDA and Binary Ninja more its time we start using a real TypeEngine as proposed in one of the internal BinSync meetings.

Proposal

In the core of BinSync, we need a to_crepr and from_crepr for every plugin that is supported in BinSync. In the BinSync database we will store everything as a crepr, then when a plugin pulls, we will detect which plugin it is and change the type as we return it to them. This will be actually not to hard to do. After this is done, it must be integrated into the diffing system.

Deadline for this will be DEF CON Quals.

Implement function list in the control panel

With the following features:

  • Select all/none.
  • Filtering displayed functions based on function names.
  • For all selected functions, setting which user to sync from.
  • For each function, display which user it is syncing from (or if it is syncing from another user at all).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.