├── .gitignore ├── LICENSE ├── README.md ├── __init__.py ├── img └── RustDemangleExample.png ├── plugin.json └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 inspier 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust Demangle (v0.1.4) 2 | Author: **inspier** 3 | 4 | ## Description: 5 | This plugin demangles Rust symbols making them easier to read. 6 | 7 | ![Image showing plugin](https://raw.githubusercontent.com/inspier/BinjaRustDemangler/master/img/RustDemangleExample.png) 8 | 9 | ## Installation Instructions 10 | 11 | Install Dependencies 12 | 13 | ```python 14 | pip install -r requirements.txt 15 | ``` 16 | 17 | ### Windows 18 | 19 | Clone this repository into `%APPDATA%/Binary Ninja/plugins/` 20 | 21 | ### Darwin 22 | 23 | Clone this repository into `~/Library/Application Support/Binary Ninja/plugins/` 24 | 25 | ### Linux 26 | 27 | Clone this repository into `~/.binaryninja/plugins/` 28 | 29 | ## Minimum Version 30 | 31 | Binary Ninja v1200 32 | 33 | ## License 34 | 35 | This plugin is released under a MIT license. 36 | ## Metadata Version 37 | 38 | 2 39 | 40 | ## Credits: 41 | * [Alex Crichton for rustc-demangle](https://github.com/alexcrichton/rustc-demangle) 42 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | from binaryninja import BinaryView 2 | from binaryninja import PluginCommand 3 | from binaryninja import Symbol, SymbolType 4 | from rust_demangler import demangle 5 | from rust_demangler.rust import TypeNotFoundError 6 | from rust_demangler.rust_legacy import UnableToLegacyDemangle 7 | from rust_demangler.rust_v0 import UnableTov0Demangle 8 | 9 | def demangle_functions(bv: BinaryView): 10 | bv.begin_undo_actions() 11 | for f in bv.functions: 12 | try: 13 | f.name = demangle(f.symbol.raw_name) 14 | # Not a valid mangled name 15 | except TypeNotFoundError: 16 | pass 17 | except UnableToLegacyDemangle: 18 | pass 19 | except UnableTov0Demangle: 20 | pass 21 | for sym in bv.symbols.values(): 22 | for symbol in sym: 23 | if symbol.type == SymbolType.ExternalSymbol: 24 | try: 25 | user_sym = Symbol(symbol.type, symbol.address, demangle(symbol.raw_name)) 26 | except TypeNotFoundError: 27 | continue 28 | except UnableToLegacyDemangle: 29 | continue 30 | except UnableTov0Demangle: 31 | continue 32 | bv.define_user_symbol(user_sym) 33 | 34 | bv.commit_undo_actions() 35 | 36 | PluginCommand.register("Rust Demangle", "Demangles Rust symbols.", demangle_functions) 37 | -------------------------------------------------------------------------------- /img/RustDemangleExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inspier/BinjaRustDemangler/d8e92c49a9615d2bc401cea922c82da408c802c5/img/RustDemangleExample.png -------------------------------------------------------------------------------- /plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugin": { 3 | "name": "Rust Demangle", 4 | "type": [ 5 | "helper" 6 | ], 7 | "api": "python3", 8 | "description": "Demangles Rust symbols.", 9 | "longdescription": "This plugin demangles Rust symbols making them easier to read.\n\n![Image showing plugin](https://raw.githubusercontent.com/inspier/BinjaRustDemangler/master/img/RustDemangleExample.png)", 10 | "platforms": [ 11 | "Darwin", 12 | "Linux", 13 | "Windows" 14 | ], 15 | "installinstructions": { 16 | "Darwin": "", 17 | "Linux": "", 18 | "Windows": "" 19 | }, 20 | "dependencies": { 21 | "pip": [ 22 | "rust_demangler" 23 | ], 24 | "apt": [], 25 | "installers": [], 26 | "other": [] 27 | }, 28 | "license": { 29 | "name": "MIT", 30 | "text": "Copyright (c) 2020 inspier\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." 31 | }, 32 | "version": "0.1.4", 33 | "author": "inspier", 34 | "minimumBinaryNinjaVersion": { 35 | "dev": "1.0.dev-576", 36 | "release": "9999" 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | rust_demangler==1.0 2 | --------------------------------------------------------------------------------