Exemple #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)
Exemple #2
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)
Exemple #3
0
 def __init__(self, *__args):
     super(BinjaButtonHolderWidget, self).__init__(*__args)
     self._app = QtWidgets.QApplication.instance()
     self._main_window = [
         x for x in self._app.allWidgets()
         if x.__class__ is QtWidgets.QMainWindow
     ][0]
     self._tool_menu = Menu.mainMenu('Tools')
     self._main_window.addDockWidget(Qt.TopDockWidgetArea, self)
     self._toolbar = QtWidgets.QToolBar()
     self.setWidget(self._toolbar)
     self.hide()
Exemple #4
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")
Exemple #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...")
Exemple #6
0
            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")
Exemple #7
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
Exemple #8
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...")
 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")
 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")
Exemple #11
0

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),
    Qt.RightDockWidgetArea, Qt.Vertical, True)

PluginCommand.register_for_function("Push function upwards",
Exemple #12
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")
Exemple #13
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",