Skip to content

Instantly share code, notes, and snippets.

@joshwatson
Last active January 8, 2023 03:05
Show Gist options
  • Save joshwatson/3016ff23558f0bde1c8bfdead04e3dc4 to your computer and use it in GitHub Desktop.
Save joshwatson/3016ff23558f0bde1c8bfdead04e3dc4 to your computer and use it in GitHub Desktop.
Microcorruption Memory Dump BinaryView for Binary Ninja
import struct
import traceback
from binaryninja import (
BinaryView, Architecture,
SegmentReadable, SegmentExecutable, SegmentWritable
)
class MicrocorruptionView(BinaryView):
name = "Microcorruption"
long_name = "Microcorruption Memory Dump"
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):
if len(data) == 0x10000:
return True
else:
return False
def init(self):
try:
self.platform = Architecture['msp430'].standalone_platform
self.arch = Architecture['msp430']
self.entry_addr = struct.unpack('<H', self.raw.read(0xfffe, 2))[0]
self.add_entry_point(self.platform, self.entry_addr)
self.add_auto_segment(0, self.entry_addr, 0, self.entry_addr,
SegmentReadable | SegmentWritable)
self.add_auto_segment(
self.entry_addr, 0x10000 - self.entry_addr,
self.entry_addr, 0x10000 - self.entry_addr,
SegmentExecutable | SegmentReadable
)
except:
log_error(traceback.format_exc())
return False
return True
def perform_is_executable(self):
return True
def perform_get_entry_point(self):
return self.entry_addr
MicrocorruptionView.register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment