示例#1
0
 def get_operation(self, op):
     binary = Binary(self.__options.binary)
     parser = Parser(op)
     arch = binary.get_arch()
     mode = binary.get_arch_mode()
     md = Cs(arch, mode)
     md.detail = True
     operation = parser.get_operation()
     return md, operation, parser
示例#2
0
    def check_args(self):
        if self.__args.version:
            self.print_version()
            sys.exit(0)

        elif not (self.__args.test_os or self.__args.test_binary):
            if self.__args.dlls and not self.__args.ropattack:
                print(
                    "[Error] dlls option without a ropattack file (--ropattack or help)"
                )
                sys.exit(-1)
            elif not self.__args.binary and not (self.__args.ropattack
                                                 and self.__args.dlls):
                print("[Error] Need a binary filename (--help)")
                sys.exit(-1)

            elif self.__args.depth < 2:
                print("[Error] The depth must be >= 2")
                sys.exit(-1)

            elif not self.__args.op and (self.__args.reg_src
                                         or self.__args.reg_dst):
                print("[Error] reg specified without an opcode (--help)")
                sys.exit(-1)

            elif self.__args.bad_chars and (not re.match(
                    r'^(/x[0-9a-f]{2})+$', self.__args.bad_chars,
                    re.IGNORECASE)):
                print("[Error] invalid format for --bad-chars parameter")
                sys.exit(-1)

            elif not self.__args.op and self.__args.ropchain:
                print("[Error] ropchain generation without an opcode (--help)")
                sys.exit(-1)
            elif self.__args.op and self.__args.ropchain:
                parser = Parser(self.__args.op)
                operation = parser.get_operation()
                if (operation.need_src() and not self.__args.reg_src) or (
                        operation.need_dst() and not self.__args.reg_dst):
                    warnings = []
                    if operation.need_dst():
                        warnings += ["dst"]
                    if operation.need_src():
                        warnings += ["src"]
                    print("[Error] op \'%s\' need %s to generate ropchains" %
                          (self.__args.op, " and ".join(warnings)))
                    sys.exit(-1)

            self.do_opcodes()
示例#3
0
文件: args.py 项目: wflk/EasyROP
    def check_args(self):
        if self.__args.version:
            self.print_version()
            sys.exit(0)

        elif not (self.__args.test_os or self.__args.test_binary):
            if not self.__args.binary:
                print(
                    "[Error] Need a binary/folder filename (--binary or --help)"
                )
                sys.exit(-1)

            elif self.__args.depth < 2:
                print("[Error] The depth must be >= 2")
                sys.exit(-1)

            elif not self.__args.op and (self.__args.reg_src
                                         or self.__args.reg_dst):
                print("[Error] reg specified without an opcode (--help)")
                sys.exit(-1)

            elif not self.__args.op and self.__args.ropchain:
                print("[Error] ropchain generation without an opcode (--help)")
                sys.exit(-1)
            elif self.__args.op and self.__args.ropchain:
                parser = Parser(self.__args.op)
                operation = parser.get_operation()
                if (operation.need_src() and not self.__args.reg_src) or (
                        operation.need_dst() and not self.__args.reg_dst):
                    warnings = []
                    if operation.need_dst():
                        warnings += ["dst"]
                    if operation.need_src():
                        warnings += ["src"]
                    print("[Error] op \'%s\' need %s to generate ropchains" %
                          (self.__args.op, " and ".join(warnings)))
                    sys.exit(-1)

            self.do_opcodes()