Пример #1
0
    def registerAllSnippets():
        for action in list(
                filter(lambda x: x.startswith("Snippets\\"),
                       UIAction.getAllRegisteredActions())):
            if action == "Snippets\\Snippet Editor...":
                continue
            UIActionHandler.globalActions().unbindAction(action)
            Menu.mainMenu("Tools").removeAction(action)
            UIAction.unregisterAction(action)

        for snippet in includeWalk(snippetPath, ".py"):
            snippetKeys = None
            (snippetDescription, snippetKeys,
             snippetCode) = loadSnippetFromFile(snippet)
            if not snippetDescription:
                actionText = "Snippets\\" + os.path.basename(snippet).rstrip(
                    ".py")
            else:
                actionText = "Snippets\\" + snippetDescription
            if snippetCode:
                if snippetKeys == None:
                    UIAction.registerAction(actionText)
                else:
                    UIAction.registerAction(actionText, snippetKeys)
                UIActionHandler.globalActions().bindAction(
                    actionText, UIAction(makeSnippetFunction(snippetCode)))
                Menu.mainMenu("Tools").addAction(actionText, actionText)
Пример #2
0
def add_commands(plugin):
    DbgAction = namedtuple('DbgAction', 'name, key_seq, handler')
    plugin_actions = (DbgAction("SyncEnable", QKeySequence(Qt.ALT + Qt.Key_S),
                                UIAction(plugin.cmd_sync)),
                      DbgAction("SyncDisable",
                                QKeySequence(Qt.ALT + Qt.SHIFT + Qt.Key_S),
                                UIAction(plugin.cmd_syncoff)),
                      DbgAction("SyncGo", QKeySequence(Qt.ALT + Qt.Key_F5),
                                UIAction(plugin.cmd_go)),
                      DbgAction("SyncStepOver", QKeySequence(Qt.Key_F10),
                                UIAction(plugin.cmd_so)),
                      DbgAction("SyncStepInto", QKeySequence(Qt.Key_F11),
                                UIAction(plugin.cmd_si)),
                      DbgAction("SyncTranslate",
                                QKeySequence(Qt.ALT + Qt.Key_F2),
                                UIAction(plugin.cmd_translate)),
                      DbgAction("SyncBp", QKeySequence(Qt.Key_F2),
                                UIAction(plugin.cmd_bp)),
                      DbgAction("SyncHwBp", QKeySequence(Qt.CTRL + Qt.Key_F2),
                                UIAction(plugin.cmd_hwbp)),
                      DbgAction("SyncBpOneShot",
                                QKeySequence(Qt.ALT + Qt.Key_F3),
                                UIAction(plugin.cmd_bp1)),
                      DbgAction("SyncHwBpOneShot",
                                QKeySequence(Qt.CTRL + Qt.Key_F3),
                                UIAction(plugin.cmd_hwbp1)))

    for action in plugin_actions:
        UIAction.registerAction(action.name, action.key_seq)
        UIActionHandler.globalActions().bindAction(action.name, action.handler)

    rs_log('commands added')
Пример #3
0
    def registerAllSnippets(self):
        for action in list(filter(lambda x: x.startswith("Snippet\\"), UIAction.getAllRegisteredActions())):
            UIActionHandler.globalActions().unbindAction(action)
            UIAction.unregisterAction(action)

        for snippet in includeWalk(snippetPath, ".py"):
            (snippetDescription, snippetKey, snippetCode) = loadSnippetFromFile(snippet)
            if not snippetDescription:
                actionText = "Snippet\\" + snippet
            else:
                actionText = "Snippet\\" + snippetDescription
            UIAction.registerAction(actionText, snippetKey)
            UIActionHandler.globalActions().bindAction(actionText, UIAction(makeSnippetFunction(snippetCode)))
Пример #4
0
    def _init_ui(self):
        # config dialog
        configure_binsync_id = "BinSync: Configure"
        UIAction.registerAction(configure_binsync_id)
        UIActionHandler.globalActions().bindAction(
            configure_binsync_id, UIAction(self._launch_config))
        Menu.mainMenu("Tools").addAction(configure_binsync_id, "BinSync")

        # control panel (per BV)
        dock_handler = DockHandler.getActiveDockHandler()
        dock_handler.addDockWidget(
            "BinSync: Control Panel", lambda n, p, d: create_widget(
                ControlPanelDockWidget, n, p, d, self.controllers),
            Qt.RightDockWidgetArea, Qt.Vertical, True)
Пример #5
0
		"description" : "Controls the amount of analysis performed on functions when opening for triage.",
		"enum" : ["controlFlow", "basic", "full"],
		"enumDescriptions" : [
			"Only perform control flow analysis on the binary. Cross references are valid only for direct function calls.",
			"Perform fast initial analysis of the binary. This mode does not analyze types or data flow through stack variables.",
			"Perform full analysis of the binary." ]
	}
	""")

Settings().register_setting("triage.linearSweep", """
	{
		"title" : "Triage Linear Sweep Mode",
		"type" : "string",
		"default" : "partial",
		"description" : "Controls the level of linear sweep performed when opening for triage.",
		"enum" : ["none", "partial", "full"],
		"enumDescriptions" : [
			"Do not perform linear sweep of the binary.",
			"Perform linear sweep on the binary, but skip the control flow graph analysis phase.",
			"Perform full linear sweep on the binary." ]
	}
	""")

UIAction.registerAction("Open for Triage...", QKeySequence("Ctrl+Alt+O"))
UIAction.registerAction("Open Selected Files")

UIActionHandler.globalActions().bindAction("Open for Triage...", UIAction(openForTriage))
Menu.mainMenu("File").addAction("Open for Triage...", "Open")

UIContext.registerFileOpenMode("Triage...", "Open file(s) for quick analysis in the Triage Summary view.", "Open for Triage...")
Пример #6
0
 def addToolMenuAction(self, name, function):
     """ Adds an item to the tool menu (at the top of the window) without registering a plugin command """
     UIAction.registerAction(name)
     UIActionHandler.globalActions().bindAction(name, UIAction(function))
     self._tool_menu.addAction(name, function)
Пример #7
0
        if size > 0 and size < 400 and i + size < len(data):
            byte_key = data[i:i+4]
            decrypted = bytearray()
            valid = True
            for j in range(size):
                char = data[i+8+j] ^ byte_key[j % 4]
                if char not in printables:
                    valid = False
                    break
                decrypted.append(char)
            if valid:
                sym_addr = data_section.start + i
                s = bytes(decrypted).decode()
                sym_name = s[:20].strip()
                for c in " \t\r\n":
                    sym_name = sym_name.replace(c, "_")
                sym_name = "str_" + sym_name
                symbol = Symbol(SymbolType.DataSymbol, sym_addr, sym_name)
                bv.define_user_symbol(symbol)
                bv.write(sym_addr, s + "\x00")


def launch_plugin(context):
    bv = context.binaryView
    decrypt_strings(bv)
    find_dynamic_apis(bv)


UIAction.registerAction("Emotet Deobufscator")
UIActionHandler.globalActions().bindAction("Emotet Deobufscator", UIAction(launch_plugin))
Menu.mainMenu("Tools").addAction("Emotet Deobufscator", "Emotet Deobufscator")
Пример #8
0
try:
    from binaryninjaui import (UIAction, UIActionHandler, Menu)

    from . import keypatch

    UIAction.registerAction("KEYPATCH")
    UIActionHandler.globalActions().bindAction(
        "KEYPATCH", UIAction(keypatch.launch_keypatch))
    Menu.mainMenu("Tools").addAction("KEYPATCH", "KEYPATCH")
except ModuleNotFoundError:
    # probably being loaded by headless BinaryNinja
    pass
Пример #9
0
def _registerUIActions():
    UIAction.registerAction("SENinja\\Setup argv...")
    UIActionHandler.globalActions().bindAction("SENinja\\Setup argv...",
                                               UIAction(_launchArgvDialog))
    Menu.mainMenu("Tools").addAction("SENinja\\Setup argv...", "Setup argv...")
Пример #10
0
        # Update UI according to the active frame
        if frame:
            self.datatype.setText(frame.getCurrentView())
            view = frame.getCurrentViewInterface()
            self.data = view.getData()
            self.offset.setText(hex(view.getCurrentOffset()))
        else:
            self.datatype.setText("None")
            self.data = None

    def contextMenuEvent(self, event):
        self.m_contextMenuManager.show(self.m_menu, self.actionHandler)

    @staticmethod
    def createPane(context):
        if context.context and context.binaryView:
            widget = HelloPaneWidget(context.binaryView)
            pane = WidgetPane(widget, "Hello")
            context.context.openPane(pane)

    @staticmethod
    def canCreatePane(context):
        return context.context and context.binaryView


UIAction.registerAction("Hello Pane")
UIActionHandler.globalActions().bindAction(
    "Hello Pane",
    UIAction(HelloPaneWidget.createPane, HelloPaneWidget.canCreatePane))
Menu.mainMenu("Tools").addAction("Hello Pane", "Hello")
Пример #11
0
 def _install_load_batch(self):
     action = self.ACTION_LOAD_BATCH
     UIAction.registerAction(action)
     UIActionHandler.globalActions().bindAction(action, UIAction(self._interactive_load_batch))
     Menu.mainMenu("Tools").addAction(action, "Loading", 1)
     logger.info("Installed the 'Code coverage batch' menu entry")
Пример #12
0
	def registerActions(self):
		# add all action handlers
		UIAction.registerAction("archive\\cpio_old_le")
		UIAction.registerAction("archive\\gzip")
		UIAction.registerAction("archive\\lzh")
		UIAction.registerAction("archive\\rar")
		UIAction.registerAction("archive\\zip")
		UIAction.registerAction("cad\\monomakh_sapr_chg")
		UIAction.registerAction("common\\bcd")
		UIAction.registerAction("database\\dbf")
		UIAction.registerAction("database\\gettext_mo")
		UIAction.registerAction("database\\sqlite3")
		UIAction.registerAction("database\\tsm")
		UIAction.registerAction("executable\\dex")
		UIAction.registerAction("executable\\dos_mz")
		UIAction.registerAction("executable\\elf")
		UIAction.registerAction("executable\\java_class")
		UIAction.registerAction("executable\\mach_o")
		UIAction.registerAction("executable\\microsoft_pe")
		UIAction.registerAction("executable\\python_pyc_27")
		UIAction.registerAction("executable\\swf")
		UIAction.registerAction("filesystem\\apm_partition_table")
		UIAction.registerAction("filesystem\\apple_single_double")
		UIAction.registerAction("filesystem\\cramfs")
		UIAction.registerAction("filesystem\\ext2")
		UIAction.registerAction("filesystem\\gpt_partition_table")
		UIAction.registerAction("filesystem\\iso9660")
		UIAction.registerAction("filesystem\\luks")
		UIAction.registerAction("filesystem\\lvm2")
		UIAction.registerAction("filesystem\\mbr_partition_table")
		UIAction.registerAction("filesystem\\tr_dos_image")
		UIAction.registerAction("filesystem\\vdi")
		UIAction.registerAction("filesystem\\vfat")
		UIAction.registerAction("filesystem\\vmware_vmdk")
		UIAction.registerAction("firmware\\andes_firmware")
		UIAction.registerAction("firmware\\ines")
		UIAction.registerAction("firmware\\uimage")
		UIAction.registerAction("font\\ttf")
		UIAction.registerAction("game\\allegro_dat")
		UIAction.registerAction("game\\doom_wad")
		UIAction.registerAction("game\\dune_2_pak")
		UIAction.registerAction("game\\fallout2_dat")
		UIAction.registerAction("game\\fallout_dat")
		UIAction.registerAction("game\\ftl_dat")
		UIAction.registerAction("game\\gran_turismo_vol")
		UIAction.registerAction("game\\heaps_pak")
		UIAction.registerAction("game\\heroes_of_might_and_magic_agg")
		UIAction.registerAction("game\\heroes_of_might_and_magic_bmp")
		UIAction.registerAction("game\\quake_mdl")
		UIAction.registerAction("game\\quake_pak")
		UIAction.registerAction("game\\renderware_binary_stream")
		UIAction.registerAction("game\\saints_row_2_vpp_pc")
		UIAction.registerAction("game\\warcraft_2_pud")
		UIAction.registerAction("geospatial\\shapefile_index")
		UIAction.registerAction("geospatial\\shapefile_main")
		UIAction.registerAction("hardware\\edid")
		UIAction.registerAction("hardware\\mifare\\mifare_classic")
		UIAction.registerAction("image\\bmp")
		UIAction.registerAction("image\\dicom")
		UIAction.registerAction("image\\exif")
		UIAction.registerAction("image\\exif_be")
		UIAction.registerAction("image\\exif_le")
		UIAction.registerAction("image\\gif")
		UIAction.registerAction("image\\icc_4")
		UIAction.registerAction("image\\ico")
		UIAction.registerAction("image\\jpeg")
		UIAction.registerAction("image\\pcx")
		UIAction.registerAction("image\\pcx_dcx")
		UIAction.registerAction("image\\png")
		UIAction.registerAction("image\\psx_tim")
		UIAction.registerAction("image\\tga")
		UIAction.registerAction("image\\wmf")
		UIAction.registerAction("image\\xwd")
		UIAction.registerAction("log\\aix_utmp")
		UIAction.registerAction("log\\glibc_utmp")
		UIAction.registerAction("log\\systemd_journal")
		UIAction.registerAction("log\\windows_evt_log")
		UIAction.registerAction("machine_code\\code_6502")
		UIAction.registerAction("media\\avi")
		UIAction.registerAction("media\\blender_blend")
		UIAction.registerAction("media\\creative_voice_file")
		UIAction.registerAction("media\\genmidi_op2")
		UIAction.registerAction("media\\id3v1_1")
		UIAction.registerAction("media\\id3v2_3")
		UIAction.registerAction("media\\id3v2_4")
		UIAction.registerAction("media\\magicavoxel_vox")
		UIAction.registerAction("media\\ogg")
		UIAction.registerAction("media\\quicktime_mov")
		UIAction.registerAction("media\\standard_midi_file")
		UIAction.registerAction("media\\stl")
		UIAction.registerAction("media\\tracker_modules\\fasttracker_xm_module")
		UIAction.registerAction("media\\tracker_modules\\s3m")
		UIAction.registerAction("media\\vp8_ivf")
		UIAction.registerAction("media\\wav")
		UIAction.registerAction("network\\bitcoin_transaction")
		UIAction.registerAction("network\\dns_packet")
		UIAction.registerAction("network\\hccap")
		UIAction.registerAction("network\\hccapx")
		UIAction.registerAction("network\\icmp_packet")

		# currently on py3 can handle the circular dependency hell
		if sys.version_info[0] == 3:
			UIAction.registerAction("network\\ethernet_frame")
			UIAction.registerAction("network\\ipv4_packet")
			UIAction.registerAction("network\\ipv6_packet")
			UIAction.registerAction("network\\microsoft_network_monitor_v2")
			UIAction.registerAction("network\\packet_ppi")
			UIAction.registerAction("network\\pcap")
			UIAction.registerAction("network\\protocol_body")

		UIAction.registerAction("network\\rtcp_payload")
		UIAction.registerAction("network\\rtp_packet")
		UIAction.registerAction("network\\tcp_segment")
		UIAction.registerAction("network\\tls_client_hello")
		UIAction.registerAction("network\\udp_datagram")
		UIAction.registerAction("network\\windows_systemtime")
		UIAction.registerAction("scientific\\nt_mdt\\nt_mdt")
		UIAction.registerAction("scientific\\nt_mdt\\nt_mdt_pal")
		UIAction.registerAction("scientific\\spectroscopy\\avantes_roh60")
		UIAction.registerAction("scientific\\spectroscopy\\specpr")
		UIAction.registerAction("security\\openpgp_message")
		UIAction.registerAction("security\\ssh_public_key")
		UIAction.registerAction("serialization\\asn1\\asn1_der")
		UIAction.registerAction("serialization\\bson")
		UIAction.registerAction("serialization\\google_protobuf")
		UIAction.registerAction("serialization\\microsoft_cfb")
		UIAction.registerAction("serialization\\msgpack")
		UIAction.registerAction("serialization\\ruby_marshal")
		UIAction.registerAction("windows\\regf")
		UIAction.registerAction("windows\\windows_lnk_file")
		UIAction.registerAction("windows\\windows_minidump")
		UIAction.registerAction("windows\\windows_resource_file")
		UIAction.registerAction("windows\\windows_shell_items")
		UIAction.registerAction("windows\\windows_systemtime")
Пример #13
0
    def function_updated(self, view, func):
        self._controller.push_function(func)


def start_patch_monitor(view):
    notification = PatchDataNotification(view, controller)
    view.register_notification(notification)


def start_function_monitor(view):
    notification = EditFunctionNotification(view, controller)
    view.register_notification(notification)


UIAction.registerAction("Configure BinSync...")
UIActionHandler.globalActions().bindAction("Configure BinSync...",
                                           UIAction(launch_binsync_configure))
Menu.mainMenu("Tools").addAction("Configure BinSync...", "BinSync")

open_control_panel_id = "BinSync: Open control panel"
UIAction.registerAction(open_control_panel_id)
UIActionHandler.globalActions().bindAction(open_control_panel_id,
                                           UIAction(open_control_panel))
Menu.mainMenu("Tools").addAction(open_control_panel_id, "BinSync")

# register the control panel dock widget
dock_handler = DockHandler.getActiveDockHandler()
dock_handler.addDockWidget(
    "BinSync: Control Panel",
    lambda n, p, d: create_widget(ControlPanelDockWidget, n, p, d, controller),
Пример #14
0
 def registerActions(self):
     UIAction.registerAction("IR graph")
     UIAction.registerAction("IR graph (SSA)")
     UIAction.registerAction("IR graph (SSA + unSSA)")
     UIAction.registerAction("Simplify code")
     UIAction.registerAction("Subcalls don't change stack")
     UIAction.registerAction("Load static memory")
Пример #15
0

def make_code(bv: BinaryView, start: int, end: int) -> None:
    if bv.get_basic_blocks_at(start):
        return
    if end - start <= 1:
        # find the next basic block, data variable, or segment/section end
        data_var = bv.get_next_data_var_after(start)
        if data_var is not None:
            end = data_var.address
        else:
            end = bv.end
        end = min(bv.get_next_basic_block_start_after(start), end)
        seg = bv.get_segment_at(start)
        if seg is not None:
            end = min(seg.end, end)
        section_ends = [s.end for s in bv.get_sections_at(start)]
        end = min(*section_ends, end)
    bv.define_data_var(start, Type.array(Type.int(1, False), end - start),
                       f"CODE_{start:08x}")


def make_code_helper(ctx: UIActionContext):
    make_code(ctx.binaryView, ctx.address, ctx.address + ctx.length)


CodeDataRenderer().register_type_specific()
UIAction.registerAction("Make Code", QKeySequence("C"))
UIActionHandler.globalActions().bindAction("Make Code",
                                           UIAction(make_code_helper))
Пример #16
0
        if len(snippetKey) != 0 and snippetKey[0] != self.keySequenceEdit.keySequence():
            return True
        return self.edit.toPlainText() != snippetCode or \
               self.snippetDescription.text() != snippetDescription

    def save(self):
        log_debug("Saving snippet %s" % self.currentFile)
        outputSnippet = open(self.currentFile, "w")
        outputSnippet.write("#" + self.snippetDescription.text() + "\n")
        outputSnippet.write("#" + self.keySequenceEdit.keySequence().toString() + "\n")
        outputSnippet.write(self.edit.toPlainText())
        outputSnippet.close()
        self.registerAllSnippets()

    def clearHotkey(self):
        self.keySequenceEdit.clear()

def launchPlugin(context):
    snippets = Snippets()
    snippets.exec_()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    snippets = Snippets()
    snippets.show()
    sys.exit(app.exec_())
else:
    UIAction.registerAction("Snippet Editor...")
    UIActionHandler.globalActions().bindAction("Snippet Editor...", UIAction(launchPlugin))
    Menu.mainMenu("Tools").addAction("Snippet Editor...", "Snippet")
Пример #17
0
 def _install_open_coverage_overview(self):
     action = self.ACTION_COVERAGE_OVERVIEW
     UIAction.registerAction(action)
     UIActionHandler.globalActions().bindAction(action, UIAction(self._open_coverage_overview))
     Menu.mainMenu("Tools").addAction(action, "Windows", 0)
     logger.info("Installed the 'Open Coverage Overview' menu entry")
Пример #18
0
from .types.libimport import browse_type_library
from binaryninja import PluginCommand
from binaryninjaui import UIAction, UIActionHandler, Menu, ViewType

from .types.export import export_type_library
from .types.make_struct import make_struct_here
from .functions.callgraph import CallGraphViewType

UIAction.registerAction(
    "Reverse Engineer's Toolkit\\Types\\Export Type Library")
UIActionHandler.globalActions().bindAction(
    "Reverse Engineer's Toolkit\\Types\\Export Type Library",
    UIAction(export_type_library, lambda ctx: ctx.binaryView is not None),
)
Menu.mainMenu("Tools").addAction(
    "Reverse Engineer's Toolkit\\Types\\Export Type Library",
    "Export Type Library")

UIAction.registerAction(
    "Reverse Engineer's Toolkit\\Types\\Import Type Library")
UIActionHandler.globalActions().bindAction(
    "Reverse Engineer's Toolkit\\Types\\Import Type Library",
    UIAction(browse_type_library, lambda ctx: ctx.binaryView is not None),
)
Menu.mainMenu("Tools").addAction(
    "Reverse Engineer's Toolkit\\Types\\Import Type Library",
    "Import Type Library")

PluginCommand.register_for_range(
    "Make Structure Here",
    "Make a structure from this range of data variables",