Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from binaryninja import *
- from json import load
- view : BinaryView = bv
- jsonPath = interaction.get_open_filename_input("dump json file", "*.json")
- if not jsonPath:
- exit(0)
- dump = {}
- with open(jsonPath, "r") as f:
- dump = load(f)
- base = view.start
- def loadSymbols(s:dict[str, dict], symType: SymbolType):
- if not isinstance(s, dict):
- return
- for name in s:
- setSymbol(name, s[name], symType)
- def setSymbol(name: str, offObj, symType: SymbolType):
- offset = offObj["offset"]
- if (len(view.get_symbols_by_name(name)) != 0):
- return
- print("defined: ", name)
- view.define_auto_symbol(
- Symbol(symType, base + offset, name)
- )
- loadSymbols(dump["subs"], SymbolType.FunctionSymbol)
- loadSymbols(dump["offsets"], SymbolType.DataSymbol)
- refsCount = 0
- for ref in dump["refs"]:
- if not isinstance(ref, list) or len(ref) != 2:
- continue
- view.add_user_data_ref(
- base + ref[0],
- base + ref[1]
- )
- refsCount+=1
- print(f"Added {refsCount} references")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement