• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pydeep.hash_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pydeep.hash_file函数的典型用法代码示例。如果您正苦于以下问题:Python hash_file函数的具体用法?Python hash_file怎么用?Python hash_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了hash_file函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: buf_hashes

def buf_hashes(buf, algo='sha256'):
  if not buf:
    return None

  if algo == 'crc32':
    return "%X" % (zlib.crc32(buf) & 0xffffffff)
  elif algo == 'adler32':
    return "%X" % (zlib.adler32(buf) & 0xffffffff)
  elif algo == 'md5':
    hasher = hashlib.md5()
  elif algo == 'sha1':
    hasher = hashlib.sha1()
  elif algo == 'sha224':
    hasher = hashlib.sha224()
  elif algo == 'sha256':
    hasher = hashlib.sha256()
  elif algo == 'sha384':
    hasher = hashlib.sha384()
  elif algo == 'sha512':
    hasher = hashlib.sha512()
  elif algo == 'ssdeep':
    return pydeep.hash_file(filename)
  else:
    return None

  hasher.update(buf)
  return hasher.hexdigest()
开发者ID:xujun10110,项目名称:rudra,代码行数:27,代码来源:utils.py


示例2: file_hashes

def file_hashes(filename, algo='sha256', blocksize=65536):
  file_handle = open(filename, 'rb')
  buf = file_handle.read(blocksize)

  if algo == 'crc32':
    return "%X" % (zlib.crc32(open(filename,"rb").read()) & 0xffffffff)
  elif algo == 'adler32':
    return "%X" % (zlib.adler32(open(filename,"rb").read()) & 0xffffffff)
  elif algo == 'md5':
    hasher = hashlib.md5()
  elif algo == 'sha1':
    hasher = hashlib.sha1()
  elif algo == 'sha224':
    hasher = hashlib.sha224()
  elif algo == 'sha256':
    hasher = hashlib.sha256()
  elif algo == 'sha384':
    hasher = hashlib.sha384()
  elif algo == 'sha512':
    hasher = hashlib.sha512()
  elif algo == 'ssdeep':
    return pydeep.hash_file(filename)
  else:
    return None

  while len(buf) > 0:
    hasher.update(buf)
    buf = file_handle.read(blocksize)
  return hasher.hexdigest()
开发者ID:xujun10110,项目名称:rudra,代码行数:29,代码来源:utils.py


示例3: hashfile

def hashfile(path, targetfile):
    '''This function returns a hash from a given file.'''
    md5 = hashlib.md5()
    sha1 = hashlib.sha1()
    sha256 = hashlib.sha256()
    sha512 = hashlib.sha512()
    fullfile = path + "/" + targetfile
    with open(fullfile, 'rb') as f:
        while True:
            data = f.read(BUF_SIZE)
            if not data:
                break
            md5.update(data)
            sha1.update(data)
            sha256.update(data)
            sha512.update(data)
            hdict = {
                'fileformat': magic.from_file(fullfile, mime=True),
                'filename': str(targetfile),
                'filesize': os.path.getsize(fullfile),
                'md5': md5.hexdigest(),
                'sha1': sha1.hexdigest(),
                'sha256': sha256.hexdigest(),
                'sha512': sha512.hexdigest(),
                'ssdeep': pydeep.hash_file(fullfile)
            }
            return hdict
开发者ID:certuk,项目名称:HashSTIXer,代码行数:27,代码来源:hashinator.py


示例4: get_ssdeep

    def get_ssdeep(self):
        if not HAVE_SSDEEP:
            return ''

        try:
            return pydeep.hash_file(self.path)
        except Exception:
            return ''
开发者ID:hotelzululima,项目名称:viper,代码行数:8,代码来源:objects.py


示例5: test_pydeep

def test_pydeep():
    for test in testL:
        filename, filelen, filehash = test
        data = io.open(filename, 'rb').read()
        hash_buf = pydeep.hash_buf(data)
        hash_file = pydeep.hash_file(filename)
        assert len(data) == filelen, "File length error"
        assert hash_buf == filehash, "Error hashing %s using hash_buf"%filename
        assert hash_file == filehash, "Error hashing %s using hash_file"%filename
开发者ID:kbandla,项目名称:pydeep,代码行数:9,代码来源:test.py


示例6: get_ssdeep

 def get_ssdeep(self):
     """ Obtem o hash SSDEEP do arquivo """
     if not HAVE_SSDEEP:
         return ''
     if self.file_data is None:
         return ''
     try:
         return pydeep.hash_file(self.file_path)
     except Exception:
         return ''
开发者ID:neriberto,项目名称:pyfile,代码行数:10,代码来源:__init__.py


示例7: get_ssdeep

    def get_ssdeep(self):
        """Get SSDEEP.
        @return: SSDEEP.
        """
        if not HAVE_SSDEEP:
            return None

        try:
            return pydeep.hash_file(self.file_path)
        except Exception:
            return None
开发者ID:0day1day,项目名称:cuckoo,代码行数:11,代码来源:objects.py


示例8: get_ssdeep

    def get_ssdeep(self):
        if not HAVE_SSDEEP:
            return None

        try:
            if Config().api.use_aws:
                return pydeep.hash_buffer(self.data)
            else:
                return pydeep.hash_file(self.path)
        except Exception:
            return None
开发者ID:HerbDavisY2K,项目名称:vxcage,代码行数:11,代码来源:objects.py


示例9: get_ssdeep

    def get_ssdeep(self):
        """Get SSDEEP.
        @return: SSDEEP.
        """
        if not HAVE_PYDEEP:
            if not File.notified_pydeep:
                File.notified_pydeep = True
                log.warning("Unable to import pydeep (install with `pip install pydeep`)")
            return None

        try:
            return pydeep.hash_file(self.file_path)
        except Exception:
            return None
开发者ID:rixgit,项目名称:malice,代码行数:14,代码来源:objects.py


示例10: analyze

    def analyze(self, config, filename):
        """Analyze the file."""

        # sanity check to make sure we can run
        if self.is_activated == False:
            return False
        log = logging.getLogger('Mastiff.Plugins.' + self.name)
        log.info('Starting execution.')
        log.info('Generating fuzzy hash.')

        try:
            my_fuzzy = pydeep.hash_file(filename)
        except pydeep.error, err:
            log.error('Could not generate fuzzy hash: %s', err)
            return False
开发者ID:DeepuDon,项目名称:mastiff,代码行数:15,代码来源:GEN-fuzzy.py


示例11: ssdeepMe

	def ssdeepMe(path):
		if path is not None:
			return pydeep.hash_file(path)
		else:
			print("Ssdeep: provide a file path")
			return ""
开发者ID:MISP,项目名称:data-processing,代码行数:6,代码来源:Kinginyourcastle.py


示例12: get_ssdeep

def get_ssdeep(malware_path):
  return pydeep.hash_file(malware_path)
开发者ID:Xen0ph0n,项目名称:malwarehouse,代码行数:2,代码来源:malwarehouse.py


示例13: str

#!/usr/bin/env python
#ssdeep insto hashin'! - since ssdeep is natively an unwieldy PITA.
#https://pypi.python.org/pypi/pydeep
#PhG

import sys, pydeep
pd1 = pydeep.hash_file(sys.argv[1])
pd2 = pydeep.hash_file(sys.argv[2])
percent = str(pydeep.compare(pd1, pd2))
print "SSDeep has determined that these files are " + percent +"% alike."

#pd0 = pydeep.hash_file("VirusShare_ab208f0b517ba9850f1551c9555b5313")
#pd1 = pydeep.hash_file("VirusShare_6570163cd34454b3d1476c134d44b9d9")
开发者ID:phreakinggeek,项目名称:somedumbscripts,代码行数:13,代码来源:friendly_ssdeep.py


示例14: ssdeep

def ssdeep(filename):
	return pydeep.hash_file(filename)
开发者ID:Xen0ph0n,项目名称:MIDAS,代码行数:2,代码来源:midas.py


示例15: engine

#!/usr/bin/env python
#ssdeep massive comparision engine (fancy way of saying... shitty script)
#there's no reason to do this... idk wtf I was doing. This makes no sense. Broken.

import sys
import pydeep
pd0 = pydeep.hash_file(sys.argv[1])
pd1 = sys.argv[2]
#Import our ssdeep file.
def deepImp(pd1) :
                deepDict = []
                with open(pd1, 'r') as deepFiles:
                    for row in deepFiles:
                        deepDict.append(row[1])
                return ssdeepDir
deepImpList = deepImp(pd1)
x = str(pydeep.compare(pd0, pd1))
print "SSDeep has determined that the DeepImportHash between" + (sys.argv[1]) + " and " + deepImpList + " are " + x +"% alike."
开发者ID:phreakinggeek,项目名称:somedumbscripts,代码行数:18,代码来源:deep_imp_compare.py


示例16: get_ssdeep

def get_ssdeep(path):
    try:
        return pydeep.hash_file(path)
    except Exception:
        return ''
开发者ID:Cbrdiv,项目名称:maltelligence,代码行数:5,代码来源:utility.py


示例17: open

import pydeep
file1 = 'calc.exe'
file2 = 'notepad.exe'
file3 = 'bc'
file1hash = '1536:JEl14rQcWAkN7GAlqbkfAGQGV8aMbrNyrf1w+noPvLV6eBsCXKc:JYmZWXyaiedMbrN6pnoXL1BsC'
file2hash = '1536:0awOnbNQKLjWDyy1o5RefYMJUEbooPRrKKRl1P3:0YNQKPWDyDRefVJltZrpRl1P3'
file3hash = '1536:MsjYdR3Bul8hcURWhEcg4/btZzDcQflbCUPEBEh8wkcGDioxMYeo7:TYf8l8htRWA4ztZsGlWUPEBEh8wmxMYe'
data1 = open(file1).read()
data2 = open(file2).read()
data3 = open(file3).read()
assert len(data1) == 114688, "File length error"
assert len(data2) ==  69120, "File length error"
assert len(data3) ==  77168, "File length error"
hash01 = pydeep.hash_buf(data1)
hash02 = pydeep.hash_buf(data2)
hash03 = pydeep.hash_buf(data3)
assert hash01 == file1hash, "Error hashing file1"
assert hash02 == file2hash, "Error hashing file2"
assert hash03 == file3hash, "Error hashing file2"
hash1 = pydeep.hash_file(file1)
hash2 = pydeep.hash_file(file2)
hash3 = pydeep.hash_file(file3)
assert hash1 == file1hash, "Error hashing file1"
assert hash2 == file2hash, "Error hashing file2"
assert hash3 == file3hash, "Error hashing file3"
assert pydeep.compare(hash1,hash2) == 0, "Error fuzzy compare value"
print 'Stuff looks fine..' 
开发者ID:HardlyHaki,项目名称:pydeep,代码行数:27,代码来源:test.py



注:本文中的pydeep.hash_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pydelicious.get_popular函数代码示例发布时间:2022-05-25
下一篇:
Python pydbus.SessionBus类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap