From 8849fb2b2b8dc824bd3f17ce1026a04856477a94 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Sun, 4 Mar 2018 18:08:04 -0500 Subject: working division, prints, and metaclasses, but imports broken, still needs work --- python/examples/nsf.py | 145 ------------------------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 python/examples/nsf.py (limited to 'python/examples/nsf.py') diff --git a/python/examples/nsf.py b/python/examples/nsf.py deleted file mode 100644 index b0164065..00000000 --- a/python/examples/nsf.py +++ /dev/null @@ -1,145 +0,0 @@ -# Copyright (c) 2015-2017 Vector 35 LLC -# -# Permission 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: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE 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. -# -# -# Simple NSF file loader, primarily for analyzing: -# https://scarybeastsecurity.blogspot.com/2016/11/0day-exploit-compromising-linux-desktop.html -# - -from binaryninja.binaryview import BinaryView -from binaryninja.architecture import Architecture -from binaryninja.log import log_error, log_info -from binaryninja.types import Symbol -from binaryninja.enums import SymbolType, SegmentFlag - -import struct -import traceback - - -class NSFView(BinaryView): - name = "NSF" - long_name = "Nintendo Sound Format" - - def __init__(self, data): - BinaryView.__init__(self, parent_view=data, file_metadata=data.file) - self.platform = Architecture["6502"].standalone_platform - - @classmethod - def is_valid_for_data(self, data): - hdr = data.read(0, 128) - if len(hdr) < 128: - return False - if hdr[0:5] != "NESM\x1a": - return False - song_count = struct.unpack("B", hdr[6])[0] - if song_count < 1: - log_info("Appears to be an NSF, but no songs.") - return False - return True - - def init(self): - try: - hdr = self.parent_view.read(0, 128) - self.version = struct.unpack("B", hdr[5])[0] - self.song_count = struct.unpack("B", hdr[6])[0] - self.starting_song = struct.unpack("B", hdr[7])[0] - self.load_address = struct.unpack("