예제 #1
0
파일: core.py 프로젝트: shaobingyang/rekall
    def GuessAddressSpace(self, base_as=None, **kwargs):
        """Loads an address space by stacking valid ASes on top of each other
        (priority order first).
        """
        base_as = base_as
        error = addrspace.AddrSpaceError()

        address_spaces = sorted(addrspace.BaseAddressSpace.classes.values(),
                                key=lambda x: x.order)

        while 1:
            logging.debug("Voting round")
            found = False
            for cls in address_spaces:
                # Only try address spaces which claim to support images.
                if not cls.metadata("image"):
                    continue

                logging.debug("Trying %s ", cls)
                try:
                    base_as = cls(base=base_as, session=self.session, **kwargs)
                    logging.debug("Succeeded instantiating %s", base_as)
                    found = True
                    break
                except (AssertionError, addrspace.ASAssertionError,
                        IOError), e:
                    logging.debug("Failed instantiating %s: %s", cls.__name__,
                                  e)
                    error.append_reason(cls.__name__, e)
                    continue
                except Exception, e:
                    logging.error("Fatal Error: %s", e)
                    if self.session.debug:
                        pdb.post_mortem()
                    raise
예제 #2
0
    def GuessAddressSpace(self, base_as=None, **kwargs):
        """Loads an address space by stacking valid ASes on top of each other
        (priority order first).
        """
        base_as = base_as
        error = addrspace.AddrSpaceError()

        address_spaces = sorted(addrspace.BaseAddressSpace.classes.values(),
                                key=lambda x: x.order)

        while 1:
            self.session.logging.debug("Voting round with base: %s", base_as)
            found = False
            for cls in address_spaces:
                # Only try address spaces which claim to support images.
                if not cls.metadata("image"):
                    continue

                self.session.logging.debug("Trying %s ", cls)
                try:
                    base_as = cls(base=base_as, session=self.session,
                                  **kwargs)
                    self.session.logging.debug("Succeeded instantiating %s",
                                               base_as)
                    found = True
                    break
                except (AssertionError,
                        addrspace.ASAssertionError) as e:
                    self.session.logging.debug("Failed instantiating %s: %s",
                                               cls.__name__, e)
                    error.append_reason(cls.__name__, e)
                    continue
                except Exception as e:
                    self.session.logging.info("Error: %s", e)
                    if self.session.GetParameter("debug"):
                        pdb.post_mortem()

                    raise

            # A full iteration through all the classes without anyone
            # selecting us means we are done:
            if not found:
                break

        if base_as:
            self.session.logging.info("Autodetected physical address space %s",
                                      base_as)

        return base_as