def __init__(self, ctx): self.ctx = ctx ctx.vim = False self.COMMANDS_ALPHA = [ "calls", "da", "db", "dd", "dw", "dq", "dump", "exit", "help", "info", "jmptable", "load", "lrawarm", "lrawmips", "lrawmips64", "lrawx86", "lrawx64", "mips_set_gp", "py", "save", "sections", "sym", "x", "v", "display.print_section", "display.print_comments", ] self.COMMANDS = { "help": Command(0, self.__exec_help, None, ["", "Display this help"]), "save": Command(0, self.__exec_save, None, [ "", "Save the database (only symbols and history currently).", ]), "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.", ]), "v": Command(1, self.__exec_v, self.__complete_x, [ "[SYMBOL|0xXXXX|EP]", "Same as x, but in visual mode.", "Shortcuts:", "g top", "G bottom", "z set current line on the middle", "q quit", "; edit inline comment (enter/escape to validate/cancel)", "% goto next bracket", "* highlight current word (ctrl-k to clear)", "enter follow address", "escape go back", "u re-enter (for undo)", ]), "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.", "If FILTER starts with -, the match is inversed." ]), "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"]), "jmptable": Command(4, self.__exec_jmptable, None, [ "INST_ADDR TABLE_ADDR NB_ENTRIES SIZE_ENTRY", "Create a jump table referenced at TABLE_ADDR and called", "from INST_ADDR." ]), "py": Command(0, self.__exec_py, None, ["", "Run an interactive python shell."]), "mips_set_gp": Command(1, self.__exec_mips_set_gp, None, ["ADDR", "Set the register $gp to a fixed value."]), } self.ctx.db_modified = False 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.reload_cursor_line() while 1: rl.loop() if not self.ctx.db_modified: break print("the database was modified, run save or exit to force")
def __init__(self, ctx): self.ctx = ctx ctx.vim = False self.COMMANDS_ALPHA = [ "calls", "da", "db", "dd", "dw", "dq", "dump", "exit", "help", "info", "jmptable", "load", "lrawarm", "lrawmips", "lrawmips64", "lrawx86", "lrawx64", "mips_set_gp", "py", "save", "sections", "sym", "x", "v", "display.print_section", "display.print_comments", ] self.COMMANDS = { "help": Command( 0, self.__exec_help, None, [ "", "Display this help" ] ), "save": Command( 0, self.__exec_save, None, [ "", "Save the database (only symbols and history currently).", ] ), "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.", ] ), "v": Command( 1, self.__exec_v, self.__complete_x, [ "[SYMBOL|0xXXXX|EP]", "Same as x, but in visual mode.", "Shortcuts:", "g top", "G bottom", "z set current line on the middle", "q quit", "; edit inline comment (enter/escape to validate/cancel)", "% goto next bracket", "* highlight current word (ctrl-k to clear)", "enter follow address", "escape go back", "u re-enter (for undo)", ] ), "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.", "If FILTER starts with -, the match is inversed." ] ), "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" ] ), "jmptable": Command( 4, self.__exec_jmptable, None, [ "INST_ADDR TABLE_ADDR NB_ENTRIES SIZE_ENTRY", "Create a jump table referenced at TABLE_ADDR and called", "from INST_ADDR." ] ), "py": Command( 0, self.__exec_py, None, [ "", "Run an interactive python shell." ] ), "mips_set_gp": Command( 1, self.__exec_mips_set_gp, None, [ "ADDR", "Set the register $gp to a fixed value." ] ), } self.ctx.db_modified = False 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.reload_cursor_line() while 1: rl.loop() if not self.ctx.db_modified: break print("the database was modified, run save or exit to force")
def __init__(self, ctx): self.ctx = ctx ctx.vim = False self.COMMANDS_ALPHA = [ "calls", "da", "db", "dd", "dw", "dq", "dump", "exit", "help", "info", "jmptable", "load", "lrawarm", "lrawmips", "lrawmips64", "lrawx86", "lrawx64", "py", "save", "sections", "sym", "x", "display.print_section", "display.print_comments", ] self.COMMANDS = { "help": Command( 0, self.__exec_help, None, [ "", "Display this help" ] ), "save": Command( 0, self.__exec_save, None, [ "", "Save the database (only symbols and history currently).", ] ), "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" ] ), "jmptable": Command( 4, self.__exec_jmptable, None, [ "INST_ADDR TABLE_ADDR NB_ENTRIES SIZE_ENTRY", "Create a jump table referenced at TABLE_ADDR and called", "from INST_ADDR." ] ), "py": Command( 0, self.__exec_py, None, [ "", "Run an interactive python shell." ] ), } self.database_modified = False 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.reload_cursor_line() while 1: rl.loop() if not self.database_modified: break print("the database was modified, run save or exit to force")
def __init__(self, ctx): self.ctx = ctx ctx.vim = False self.COMMANDS_ALPHA = [ "calls", "da", "db", "dd", "dw", "dq", "dump", "exit", "help", "info", "jmptable", "load", "lrawarm", "lrawmips", "lrawmips64", "lrawx86", "lrawx64", "py", "save", "sections", "sym", "x", "display.print_section", "display.print_comments", ] self.COMMANDS = { "help": Command(0, self.__exec_help, None, ["", "Display this help"]), "save": Command(0, self.__exec_save, None, [ "", "Save the database (only symbols and history currently).", ]), "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"]), "jmptable": Command(4, self.__exec_jmptable, None, [ "INST_ADDR TABLE_ADDR NB_ENTRIES SIZE_ENTRY", "Create a jump table referenced at TABLE_ADDR and called", "from INST_ADDR." ]), "py": Command(0, self.__exec_py, None, ["", "Run an interactive python shell."]), } self.database_modified = False 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.reload_cursor_line() while 1: rl.loop() if not self.database_modified: break print("the database was modified, run save or exit to force")