Esempio n. 1
0
    def __init__(self, ctx):
        self.ctx = ctx
        ctx.vim = False

        self.COMMANDS_ALPHA = [
            "calls",
            "data",
            "dump",
            "exit",
            "help",
            "info",
            "load",
            "lrawarm",
            "lrawmips",
            "lrawmips64",
            "lrawx86",
            "lrawx64",
            "sections",
            "sym",
            "x",
        ]

        self.COMMANDS = {
            "help": Command(0, self.__exec_help, None, ["", "Display this help"]),
            "load": Command(1, self.__exec_load, self.__complete_load, ["filename", "Load a new binary file."]),
            "lrawx86": Command(1, self.__exec_lrawx86, self.__complete_load, ["filename", "Load a x86 raw file."]),
            "lrawx64": Command(1, self.__exec_lrawx64, self.__complete_load, ["filename", "Load a x64 raw file."]),
            "lrawarm": Command(1, self.__exec_lrawarm, self.__complete_load, ["filename", "Load a ARM raw file."]),
            "lrawmips": Command(1, self.__exec_lrawmips, self.__complete_load, ["filename", "Load a MIPS raw file."]),
            "lrawmips64": Command(
                1, self.__exec_lrawmips64, self.__complete_load, ["filename", "Load a MIPS64 raw file."]
            ),
            "x": Command(
                1, self.__exec_x, self.__complete_x, ["[SYMBOL|0xXXXX|EP]", "Disassemble. By default it will be main."]
            ),
            # by default it will be ctx.lines
            "data": Command(
                2,
                self.__exec_data,
                self.__complete_x,
                ["SYMBOL|0xXXXX|EP [NB_LINES]", "Print data and detect ascii strings."],
            ),
            # by default it will be ctx.lines
            "dump": Command(2, self.__exec_dump, self.__complete_x, ["SYMBOL|0xXXXX|EP [NB_LINES]", "Dump asm."]),
            "set": Command(3, None, None, ["", "Set options"]),
            "sym": Command(
                3,
                self.__exec_sym,
                self.__complete_x,
                [
                    "[SYMBOL 0xXXXX] [| FILTER]",
                    "Print all symbols or set a new symbol.",
                    "You can filter symbols by searching the word FILTER.",
                ],
            ),
            "calls": Command(
                1,
                self.__exec_calls,
                self.__complete_x,
                ["[SECTION_NAME]", "Print all calls which are in the given section"],
            ),
            "exit": Command(0, self.__exec_exit, None, ["", "Exit"]),
            "sections": Command(0, self.__exec_sections, None, ["", "Print all sections"]),
            "info": Command(0, self.__exec_info, None, ["", "Information about the current binary"]),
        }

        rl = ReadLine(self.exec_command, self.complete, self.send_control_c)
        self.rl = rl

        if ctx.filename is not None:
            self.__exec_load(["", ctx.filename])

        if ctx.entry is not None:
            self.__exec_x(["", ctx.entry])

        rl.restore_history()
        rl.loop()
        rl.save_history()
Esempio n. 2
0
    def __init__(self, ctx):
        self.ctx = ctx
        ctx.vim = False

        self.COMMANDS_ALPHA = [
            "calls",
            "dump",
            "exit",
            "help",
            "load",
            "lrawarm",
            "lrawmips",
            "lrawmips64",
            "lrawx86",
            "lrawx64",
            "sections",
            "sym",
            "x",
        ]

        self.COMMANDS = {
            "help":
            Command(0, self.__exec_help, None, ["", "Display this help"]),
            "load":
            Command(1, self.__exec_load, self.__complete_load, [
                "filename",
                "Load a new binary file.",
            ]),
            "lrawx86":
            Command(1, self.__exec_lrawx86, self.__complete_load, [
                "filename",
                "Load a x86 raw file.",
            ]),
            "lrawx64":
            Command(1, self.__exec_lrawx64, self.__complete_load, [
                "filename",
                "Load a x64 raw file.",
            ]),
            "lrawarm":
            Command(1, self.__exec_lrawarm, self.__complete_load, [
                "filename",
                "Load a ARM raw file.",
            ]),
            "lrawmips":
            Command(1, self.__exec_lrawmips, self.__complete_load, [
                "filename",
                "Load a MIPS raw file.",
            ]),
            "lrawmips64":
            Command(1, self.__exec_lrawmips64, self.__complete_load, [
                "filename",
                "Load a MIPS64 raw file.",
            ]),
            "x":
            Command(1, self.__exec_x, self.__complete_x, [
                "[SYMBOL|0xXXXX|EP]",
                "Disassemble. By default it will be main.",
            ]),

            # by default it will be ctx.lines
            "dump":
            Command(2, self.__exec_dump, self.__complete_x, [
                "SYMBOL|0xXXXX|EP [NB_LINES]",
                "Dump asm.",
            ]),
            "set":
            Command(3, None, None, ["", "Set options"]),
            "sym":
            Command(3, self.__exec_sym, self.__complete_x, [
                "[SYMBOL 0xXXXX] [| FILTER]",
                "Print all symbols or set a new symbol.",
                "You can filter symbols by searching the word FILTER."
            ]),
            "calls":
            Command(1, self.__exec_calls, self.__complete_x, [
                "[SYMBOL|0xXXXX|EP]",
                "Print all calls which are in the section containing the address.",
                "By default the address is the entry point (EP)."
            ]),
            "exit":
            Command(0, self.__exec_exit, None, ["", "Exit"]),
            "sections":
            Command(0, self.__exec_sections, None, [
                "",
                "Print all sections",
            ]),
        }

        rl = ReadLine(self.exec_command, self.complete, self.send_control_c)
        self.rl = rl

        if ctx.filename is not None:
            self.__exec_load(["", ctx.filename])

        if ctx.entry is not None:
            self.__exec_x(["", ctx.entry])

        rl.restore_history()
        rl.loop()
        rl.save_history()
Esempio n. 3
0
    def __init__(self, ctx):
        self.ctx = ctx
        ctx.vim = False

        self.COMMANDS_ALPHA = [
            "calls",
            "da",
            "db",
            "dd",
            "dw",
            "dq",
            "dump",
            "exit",
            "help",
            "info",
            "load",
            "lrawarm",
            "lrawmips",
            "lrawmips64",
            "lrawx86",
            "lrawx64",
            "sections",
            "sym",
            "x",
            "display.print_section",
            "display.print_comments",
        ]

        self.COMMANDS = {
            "help":
            Command(0, self.__exec_help, None, ["", "Display this help"]),
            "load":
            Command(1, self.__exec_load, self.__complete_load, [
                "filename",
                "Load a new binary file.",
            ]),
            "lrawx86":
            Command(1, self.__exec_lrawx86, self.__complete_load, [
                "filename",
                "Load a x86 raw file.",
            ]),
            "lrawx64":
            Command(1, self.__exec_lrawx64, self.__complete_load, [
                "filename",
                "Load a x64 raw file.",
            ]),
            "lrawarm":
            Command(1, self.__exec_lrawarm, self.__complete_load, [
                "filename",
                "Load a ARM raw file.",
            ]),
            "lrawmips":
            Command(1, self.__exec_lrawmips, self.__complete_load, [
                "filename",
                "Load a MIPS raw file.",
            ]),
            "lrawmips64":
            Command(1, self.__exec_lrawmips64, self.__complete_load, [
                "filename",
                "Load a MIPS64 raw file.",
            ]),
            "x":
            Command(1, self.__exec_x, self.__complete_x, [
                "[SYMBOL|0xXXXX|EP]",
                "Decompile. By default it will be main.",
            ]),
            "da":
            Command(2, self.__exec_data, self.__complete_x, [
                "SYMBOL|0xXXXX|EP [NB_LINES]",
                "Print data in ascii, it stops when the end of the section is found",
            ]),
            "db":
            Command(2, self.__exec_data, self.__complete_x, [
                "SYMBOL|0xXXXX|EP [NB_LINES]",
                "Print data in bytes, it stops when the end of the section is found",
            ]),
            "dd":
            Command(2, self.__exec_data, self.__complete_x, [
                "SYMBOL|0xXXXX|EP [NB_LINES]",
                "Print data in dwords, it stops when the end of the section is found",
            ]),
            "dw":
            Command(2, self.__exec_data, self.__complete_x, [
                "SYMBOL|0xXXXX|EP [NB_LINES]",
                "Print data in words, it stops when the end of the section is found",
            ]),
            "dq":
            Command(2, self.__exec_data, self.__complete_x, [
                "SYMBOL|0xXXXX|EP [NB_LINES]",
                "Print data in qwords, it stops when the end of the section is found",
            ]),

            # by default it will be ctx.lines
            "dump":
            Command(2, self.__exec_dump, self.__complete_x, [
                "SYMBOL|0xXXXX|EP [NB_LINES]",
                "Disassemble only.",
            ]),
            "set":
            Command(3, None, None, ["", "Set options"]),
            "sym":
            Command(3, self.__exec_sym, self.__complete_x, [
                "[SYMBOL 0xXXXX] [| FILTER]",
                "Print all symbols or set a new symbol.",
                "You can filter symbols by searching the word FILTER."
            ]),
            "calls":
            Command(1, self.__exec_calls, self.__complete_x, [
                "[SECTION_NAME]",
                "Print all calls which are in the given section"
            ]),
            "exit":
            Command(0, self.__exec_exit, None, ["", "Exit"]),
            "sections":
            Command(0, self.__exec_sections, None, [
                "",
                "Print all sections",
            ]),
            "info":
            Command(0, self.__exec_info, None,
                    ["", "Information about the current binary"]),
            "display.print_section":
            Command(0, self.__exec_display_print_section, None,
                    ["", "Print or not section when an address is found"]),
            "display.print_comments":
            Command(0, self.__exec_display_print_comments, None,
                    ["", "Print or not comments"]),
        }

        rl = ReadLine(self.exec_command, self.complete, self.send_control_c)
        self.rl = rl

        if ctx.filename is not None:
            self.__exec_load(["", ctx.filename])

        if ctx.entry is not None:
            self.__exec_x(["", ctx.entry])

        rl.restore_history()
        rl.loop()
        rl.save_history()