Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import traceback
from binaryninja import (BinaryView, Architecture, SegmentFlag, log_error,
get_address_input, log_info, SectionSemantics)
offset = 0x08000000
entry_addr = 0x080001c0
class FwImgView(BinaryView):
name = "fwimg"
long_name = "Firmware Image"
def __init__(self, data):
BinaryView.__init__(self, file_metadata=data.file, parent_view=data)
self.raw = data
@classmethod
def is_valid_for_data(self, data):
return True
def init(self):
try:
self.load_addr = get_address_input("Load address", "Load Address")
self.entry_addr = get_address_input("Entry point", "Entry Point")
log_info("Offset 0x{:08X}, entry 0x{:08X}".format(
self.load_addr, self.entry_addr))
self.platform = Architecture['thumb2'].standalone_platform
self.arch = Architecture['thumb2']
self.add_auto_segment(self.load_addr, len(self.raw), 0,
len(self.raw),
SegmentFlag.SegmentReadable |
SegmentFlag.SegmentExecutable)
self.add_auto_section(
"text", self.load_addr, len(self.raw),
SectionSemantics.ReadOnlyCodeSectionSemantics)
self.add_entry_point(self.entry_addr)
return True
except:
log_error(traceback.format_exc())
return False
def platform_is_executable(self):
return True
FwImgView.register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.