virusshare.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:Cortex-Analyzers 作者: CERT-BDF 项目源码 文件源码
def run(self):
        searchhash = ''
        if self.data_type == 'hash':
            searchhash = self.getData()
            if len(searchhash) != 32:
                self.report({'isonvs': 'unknown',
                             'hash': searchhash})
        elif self.data_type == 'file':
            filepath = self.getParam('file')
            hasher = hashlib.md5()
            with io.open(filepath, mode='rb') as afile:
                for chunk in iter(lambda: afile.read(65536), b''):
                    hasher.update(chunk)
            searchhash = hasher.hexdigest()
        else:
            self.error('Unsupported data type.')

        # Read files
        for file in self.filelist:
            filepath = os.path.join(self.path, file)
            if not os.path.isfile(filepath):
                continue
            with io.open(filepath, 'r') as afile:
                for line in afile:
                    # Skipping comments
                    if line[0] == '#':
                        continue
                    if searchhash.lower() in line:
                        self.report({'isonvs': True,
                                     'md5': searchhash})
        self.report({'isonvs': False,
                     'md5': searchhash})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号