コード例 #1
0
ファイル: base.py プロジェクト: sprout42/vivisect
 def _mcb_FileBytes(self, name, value):
     if not self.parsedbin:
         byts = viv_parsers.uncompressBytes(value)
         fmt = viv_parsers.guessFormat(byts)
         parser = viv_parsers.getBytesParser(fmt)
         if parser:
             self.parsedbin = parser(byts)
コード例 #2
0
    def _loadWorkspaces(self):

        # First, ditch any that are missing
        for wsname in self.wsdict.keys():
            wsinfo = self.wsdict.get(wsname)
            if not os.path.isfile(wsinfo[1]):
                self.wsdict.pop(wsname, None)

        for dirname, dirnames, filenames in os.walk(self.path):
            for filename in filenames:
                wspath = os.path.join(dirname, filename)
                wsname = os.path.relpath(wspath, self.path)

                if not os.path.isfile(wspath):
                    continue

                with open(wspath, 'rb') as f:
                    ext = f.read(6)

                if not ext:
                    continue

                if not v_parsers.guessFormat(ext) in ('viv', 'mpviv'):
                    continue

                wsinfo = self.wsdict.get(wsname)
                if wsinfo is None:
                    # Initialize the workspace info tuple
                    lock = threading.Lock()
                    wsinfo = [lock, wspath, [], {}]
                    logger.debug('loaded: %s', wsname)
                    self.wsdict[wsname] = wsinfo