Skip to content

Instantly share code, notes, and snippets.

@four0four
Forked from joshwatson/microcorruption.py
Last active January 8, 2023 03:21
Show Gist options
  • Save four0four/bceccc9753d4a607d2b3b6c67a38a004 to your computer and use it in GitHub Desktop.
Save four0four/bceccc9753d4a607d2b3b6c67a38a004 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, log
)
from binaryninja.enums import (
SegmentFlag
)
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]
log.log_info(self.entry_addr)
self.add_auto_segment(0, self.entry_addr, 0, self.entry_addr,
SegmentFlag.SegmentReadable | SegmentFlag.SegmentWritable)
self.add_auto_segment(
self.entry_addr, 0x10000 - self.entry_addr,
self.entry_addr, 0x10000 - self.entry_addr,
SegmentFlag.SegmentExecutable | SegmentFlag.SegmentReadable
)
self.add_entry_point(self.entry_addr)
except:
log.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