def do_imagebase(self, text): if len(text) == 0: self.binary.manualImagebase = None elif isHex(text): self.binary.manualImagebase = int(text, 16) else: self.help_imagebase()
def do_imagebase(self, text): if len(text) == 0: self.__options.I = None elif isHex(text): self.__options.I = int(text, 16) else: self.help_imagebase()
def do_badbytes(self, text): if len(text) ==0: self.__printInfo('badbytes cleared') elif not isHex('0x'+text): self.__printError('not allowed characters in badbytes') return self.__options.badbytes =text self.__printInfo('Gadgets have to be reloaded')
def do_badbytes(self, text): if len(text) == 0: self.__printInfo('badbytes cleared') if not isHex('0x' + text): self.__printError('not allowed characters in badbytes') return self.__options.badbytes = text self.__printInfo('Gadgets have to be reloaded')
def __handleOptions(self, options): if options.sections: self.__printData('sections') elif options.symbols: self.__printData('symbols') elif options.segments: self.__printData('segments') elif options.dllcharacteristics: self.__printData('dll_characteristics') elif options.imagebase: self.__printData('image_base') elif options.e: self.__printData('entry_point') elif options.imports: self.__printData('imports') elif options.set: self.__set(options.set, True) elif options.unset: self.__set(options.unset, False) elif options.info: self.__printData('informations') elif options.ppr: self.__searchPopPopRet() elif options.jmp: self.__searchJmpReg(options.jmp) elif options.opcode: self.__searchOpcode(self.__options.opcode) elif options.string: self.__printStrings(options.string, options.section) elif options.hex and options.section: self.__printSectionInHex(options.section) elif options.disassemble: split = options.disassemble.split(':') length = 1 if not isHex(split[0]): raise RopperError('Number have to be in hex format 0x....') if len(split) > 1: if split[1][1:].isdigit() or ( len(split[1]) >= 3 and split[1][1] == '-' and split[1][2:].isdigit()): # is L\d or L-\d length = int(split[1][1:]) else: raise RopperError( 'Length have to be in the following format L + Number e.g. L3' ) self.__disassemble(int(split[0], 16), length) #elif options.checksec: # self.__checksec() elif options.chain: self.__loadGadgets() self.__generateChain(self.binary.gadgets, options.chain) elif options.db: self.__loaddb(options.db) self.__searchAndPrintGadgets() else: self.__loadGadgets() self.__searchAndPrintGadgets()
def __handleOptions(self, options): if options.sections: self.__printData('sections') elif options.symbols: self.__printData('symbols') elif options.segments: self.__printData('segments') elif options.dllcharacteristics: self.__printData('dll_characteristics') elif options.imagebase: self.__printData('image_base') elif options.e: self.__printData('entry_point') elif options.imports: self.__printData('imports') elif options.set: self.__set(options.set, True) elif options.unset: self.__set(options.unset, False) elif options.info: self.__printData('informations') elif options.ppr: self.__searchPopPopRet() elif options.jmp: self.__searchJmpReg(options.jmp) elif options.opcode: self.__searchOpcode(self.__options.opcode) elif options.string: self.__printStrings(options.string, options.section) elif options.hex and options.section: self.__printSectionInHex(options.section) elif options.disassemble: split = options.disassemble.split(':') length = 1 if not isHex(split[0]): raise RopperError('Number have to be in hex format 0x....') if len(split) > 1: if split[1][1:].isdigit() or (len(split[1]) >= 3 and split[1][1] == '-' and split[1][2:].isdigit()): # is L\d or L-\d length = int(split[1][1:]) else: raise RopperError('Length have to be in the following format L + Number e.g. L3') self.__disassemble(int(split[0],16), length) #elif options.checksec: # self.__checksec() elif options.chain: self.__loadGadgets() self.__generateChain(self.binary.gadgets, options.chain) elif options.db: self.__loaddb(options.db) self.__searchAndPrintGadgets() else: self.__loadGadgets() self.__searchAndPrintGadgets()
def do_disassemble(self, text): split = text.split(' ') length = 1 if not isHex(split[0]): self.__cprinter.printError('Number have to be in hex format 0x....') return if len(split) > 1: if split[1][1:].isdigit() or (len(split[1]) >= 3 and split[1][1] == '-' and split[1][2:].isdigit()): # is L\d or L-\d length = int(split[1][1:]) else: self.__cprinter.printError('Length have to be in the following format L + Number e.g. L3') return addr = int(split[0], 16) self.__disassemble(addr, length)
def do_disassemble(self, text): split = text.split(' ') length = 1 if not isHex(split[0]): self.__cprinter.printError( 'Number have to be in hex format 0x....') return if len(split) > 1: if split[1][1:].isdigit() or ( len(split[1]) >= 3 and split[1][1] == '-' and split[1][2:].isdigit()): # is L\d or L-\d length = int(split[1][1:]) else: self.__cprinter.printError( 'Length have to be in the following format L + Number e.g. L3' ) return addr = int(split[0], 16) self.__disassemble(addr, length)
def _analyseArguments(self): if len(self.__argv) == 0 or (len(self.__argv) == 1 and self.__argv[0] == '--nocolor'): self.__argv.append('--console') self.__args = self.__parser.parse_args(self.__argv) self.__args.nocolor = self.__args.nocolor and not self.isWindows() if not self.__args.console and not self.__args.file and not self.__args.version: self.__missingArgument('[-f|--file]') if not self.__args.depth: self.__args.depth = 10 if not self.__args.type: self.__args.type = 'all' if self.__args.I: if not isHex(self.__args.I): raise ArgumentError('Imagebase should be in hex (0x.....)') else: self.__args.I = int(self.__args.I, 16)
def _setBadbytes(self, value): if len(value) == 0 or isHex("0x" + value): self.badbytes = value return (True, True) return False