Ejemplo n.º 1
0
  def __init__(self, path, debug=0, static_engine=None):
    self.tags = {}
    self.path = path
    self.r2core = None
    self.debug = debug

    # radare doesn't seem to have a concept of names
    # doesn't matter if this is in the python
    self.rnames = {}

    # fall through on an instruction
    # 'arch'
    self.global_tags = Tags(self)
    self.global_tags['functions'] = set()
    self.global_tags['blocks'] = set()
    self.global_tags['segments'] = []

    # concept from qira_program
    self.base_memory = {}

    #pass static engine as an argument for testing
    if static_engine is None:
      static_engine = qira_config.STATIC_ENGINE

    # TODO: clean this up
    if static_engine == "r2":
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "r2"))
      import r2pipe 
      import loader 
      import analyzer
      self.r2core = r2pipe.r2pipe(path)
      # capstone is not working ok yet, so using udis for now
      self.r2core.cmd("e asm.arch=x86.udis")
      self.r2core.cmd("aa;af @ main")
    elif static_engine == "ida":
      # run the elf loader
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "ida"))
      import ida
      class loader():
        @staticmethod
        def load_binary(static):
          ida.init_with_binary(static.path)
      class analyzer():
        @staticmethod
        def analyze_functions(x):
          dat = ida.fetch_tags()
          print dat
    else:
      # run the elf loader
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "builtin"))
      import loader
      import analyzer
    self.analyzer = analyzer
    loader.load_binary(self)

    if self.debug >= 1:
      print "*** elf loaded"
Ejemplo n.º 2
0
  def __init__(self, path, debug=False):
    self.tags = {}
    self.path = path
    self.r2core = None
    self.debug = debug

    # radare doesn't seem to have a concept of names
    # doesn't matter if this is in the python
    self.rnames = {}

    # fall through on an instruction
    # 'arch'
    self.global_tags = {}
    self.global_tags['functions'] = set()
    self.global_tags['blocks'] = set()
    self.global_tags['sections'] = []

    # concept from qira_program
    self.base_memory = {}

    if qira_config.STATIC_ENGINE == "r2":
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "r2"))
      import r2pipe 
      import loader 
      import analyzer
      self.r2core = r2pipe.r2pipe(path)
      # capstone is not working ok yet, so using udis for now
      self.r2core.cmd("e asm.arch=x86.udis")
      self.r2core.cmd("aa;af @ main")
    else:
      # run the elf loader
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "builtin"))
      import loader
      import analyzer
    self.analyzer = analyzer
    loader.load_binary(self)

    print "*** elf loaded"
Ejemplo n.º 3
0
    def __init__(self, path, debug=0, static_engine=None):
        # create the static cache dir
        try:
            os.mkdir(qira_config.STATIC_CACHE_BASE)
        except:
            pass

        self.tags = {}
        self.path = path
        #self.scf = qira_config.STATIC_CACHE_BASE + sha1(open(self.path, "rb").read()).hexdigest()
        self.r2core = None
        self.debug = debug

        # radare doesn't seem to have a concept of names
        # doesn't matter if this is in the python
        self.rnames = {}

        # fall through on an instruction
        # 'arch'
        self.global_tags = Tags(self)
        self.global_tags['functions'] = set()
        self.global_tags['blocks'] = set()
        self.global_tags['segments'] = []

        # concept from qira_program
        self.base_memory = {}

        # kernel module loaded address
        self.load_address = 0xffffffffc0082000
        self.debug = 0
        #pass static engine as an argument for testing
        if static_engine is None:
            static_engine = qira_config.STATIC_ENGINE

        # TODO: clean this up
        if static_engine == "r2":
            sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "r2"))
            import r2pipe
            import loader
            import analyzer
            self.r2core = r2pipe.r2pipe(path)
            # capstone is not working ok yet, so using udis for now
            self.r2core.cmd("e asm.arch=x86.udis")
            self.r2core.cmd("aa;af @ main")
        elif static_engine == "ida":
            # run the elf loader
            sys.path.append(os.path.join(qira_config.BASEDIR, "static2",
                                         "ida"))
            import ida

            class loader():
                @staticmethod
                def load_binary(static):
                    ida.init_with_binary(static.path)

            class analyzer():
                @staticmethod
                def analyze_functions(x):
                    dat = ida.fetch_tags()
                    print dat
        elif static_engine == "kap":
            sys.path.append(
                os.path.join(qira_config.BASEDIR, "static2", "kap", "linux"))
            sys.path.append(
                os.path.join(qira_config.BASEDIR, "static2", "builtin"))
            import loader
            import analyzer
        else:
            # run the elf loader
            sys.path.append(
                os.path.join(qira_config.BASEDIR, "static2", "builtin"))
            import loader
            import analyzer

        self.analyzer = analyzer
        loader.load_binary(self)

        print "*** elf loaded"
        """
Ejemplo n.º 4
0
  def __init__(self, path, debug=0, static_engine=None):
    # create the static cache dir
    try:
      os.mkdir(qira_config.STATIC_CACHE_BASE)
    except:
      pass

    self.tags = {}
    self.path = path
    #self.scf = qira_config.STATIC_CACHE_BASE + sha1(open(self.path, "rb").read()).hexdigest()
    self.r2core = None
    self.debug = debug

    # radare doesn't seem to have a concept of names
    # doesn't matter if this is in the python
    self.rnames = {}

    # fall through on an instruction
    # 'arch'
    self.global_tags = Tags(self)
    self.global_tags['functions'] = set()
    self.global_tags['blocks'] = set()
    self.global_tags['segments'] = []

    # concept from qira_program
    self.base_memory = {}

    # kernel module loaded address
    self.load_address = 0xffffffffc0082000
    self.debug = 0
    #pass static engine as an argument for testing
    if static_engine is None:
      static_engine = qira_config.STATIC_ENGINE

    # TODO: clean this up
    if static_engine == "r2":
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "r2"))
      import r2pipe
      import loader
      import analyzer
      self.r2core = r2pipe.r2pipe(path)
      # capstone is not working ok yet, so using udis for now
      self.r2core.cmd("e asm.arch=x86.udis")
      self.r2core.cmd("aa;af @ main")
    elif static_engine == "ida":
      # run the elf loader
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "ida"))
      import ida
      class loader():
        @staticmethod
        def load_binary(static):
          ida.init_with_binary(static.path)
      class analyzer():
        @staticmethod
        def analyze_functions(x):
          dat = ida.fetch_tags()
          print dat
    elif static_engine == "kap":
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "kap", "linux"))
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "builtin"))
      import loader
      import analyzer
    else:
      # run the elf loader
      sys.path.append(os.path.join(qira_config.BASEDIR, "static2", "builtin"))
      import loader
      import analyzer

    self.analyzer = analyzer
    loader.load_binary(self)

    print "*** elf loaded"

    """