当前位置: 首页>>代码示例>>Python>>正文


Python ssdeep.hash方法代码示例

本文整理汇总了Python中ssdeep.hash方法的典型用法代码示例。如果您正苦于以下问题:Python ssdeep.hash方法的具体用法?Python ssdeep.hash怎么用?Python ssdeep.hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ssdeep的用法示例。


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

示例1: load_data_from_results_file

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def load_data_from_results_file(path):
    c2_bases = {}

    with open(path, "r") as f:
        for line in f:
            line = line.strip()
            data = json.loads(line)
            data['content'] = data['content'].decode('hex')
            data['content_ssdeep'] = ssdeep.hash(data['content'])

            if data['base_url'] not in c2_bases:
                c2_bases[data['base_url']] = {}
            data["offset"] = data["url"][len(data["base_url"]):]
            print "{0}  -  {1}  -  {2}".format(data['code'], data['base_url'], data['offset'])
            c2_bases[data['base_url']][data['offset']] = data

    return c2_bases 
开发者ID:cylance,项目名称:IntroductionToMachineLearningForSecurityPros,代码行数:19,代码来源:vectorization.py

示例2: Calculate

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def Calculate(self, string):
        if self.name == "md5":
            hash = hashlib.md5(string).hexdigest()

        elif self.name == "sha1":
            hash = hashlib.sha1(string).hexdigest()

        elif self.name == "crc":
            crc32 = crcmod.Crc(0x104c11db7, initCrc=0, xorOut=0xFFFFFFFF)
            crc32.update(string)
            hash = crc32.hexdigest()

        elif self.name == "murmur":
            hash = mmh3.hash(string)

        elif self.name == "ssdeep":
            hash = ssdeep.hash(string)

        elif self.name == "tlsh":
            hash = tlsh.hash(string)

        return hash 
开发者ID:CIRCL,项目名称:AIL-framework,代码行数:24,代码来源:Hash.py

示例3: get_spam_level

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def get_spam_level(player, message_content):
    """
    Get's a spam level for a message using a 
    fuzzy hash > 50% means it's probably spam
    """

    message_hash = ssdeep.hash(message_content)
    spam_level = 0
    spam_levels = [ssdeep.compare(message_hash, prior_hash) for prior_hash in player.last_message_hashes if
                   prior_hash is not None]
    if len(spam_levels) > 0:
        spam_level = max(spam_levels)
    player.last_message_hashes.append(message_hash)
    if spam_level > SPAM_TOLERANCE:
        player.spam_detections += 1
    return spam_level 
开发者ID:MacDue,项目名称:DueUtil,代码行数:18,代码来源:game.py

示例4: main

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def main():
    """ Determines the file type then outputs the binary md5 hash
     and the function fuzzy hashes

     Usage:
        python malget.py [FILE] """

    args = argparse_setup()

    output_file = "malgetOutput.txt"
    if args.output:
        output_file = args.output
    binary_tuple, sizes = malget(args.PATH, args.unpack)
    with open(output_file, "w") as f:
        f.write(binary_tuple[0]+"\n")
        for item in binary_tuple[1]:
            f.write(item + "\n")
    print("Output to file {0}".format(output_file)) 
开发者ID:Dynetics,项目名称:Malfunction,代码行数:20,代码来源:malget.py

示例5: should_parse

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def should_parse(repo, state, is_gist=False):
    owner_login = repo.owner.login if is_gist else repo.repository.owner.login
    if owner_login in state.bad_users:
        print(bcolors.FAIL + "Failed check: Ignore User" + bcolors.ENDC)
        return False
    if not is_gist and repo.repository.name in state.bad_repos:
        print(bcolors.FAIL + "Failed check: Ignore Repo" + bcolors.ENDC)
        return False
    if not is_gist and repo.name in state.bad_files:
        print(bcolors.FAIL + "Failed check: Ignore File" + bcolors.ENDC)
        return False

    # Fuzzy Hash Comparison
    try:
        if not is_gist:
            # Temporary fix for PyGithub until fixed upstream (PyGithub#1178)
            repo._url.value = repo._url.value.replace(
                repo._path.value,
                urllib.parse.quote(repo._path.value))

        candidate_sig = ssdeep.hash(repo.decoded_content)
        for sig in state.bad_signatures:
            similarity = ssdeep.compare(candidate_sig, sig)
            if similarity > SIMILARITY_THRESHOLD:
                print(
                    bcolors.FAIL +
                    "Failed check: Ignore Fuzzy Signature on Contents "
                    "({}% Similarity)".format(similarity) +
                    bcolors.ENDC)
                return False
    except github.UnknownObjectException:
        print(
            bcolors.FAIL +
            "API Error: File no longer exists on github.com" +
            bcolors.ENDC)
        return False
    return True 
开发者ID:BishopFox,项目名称:GitGot,代码行数:39,代码来源:gitgot.py

示例6: ui_loop

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def ui_loop(repo, log_buf, state, is_gist=False):
    choice = input_handler(state, is_gist)

    if choice == "c":
        state.bad_signatures.append(ssdeep.hash(repo.decoded_content))
    elif choice == "u":
        state.bad_users.append(repo.owner.login if is_gist
                               else repo.repository.owner.login)
    elif choice == "r" and not is_gist:
        state.bad_repos.append(repo.repository.name)
    elif choice == "f" and not is_gist:
        state.bad_files.append(repo.name)
    elif choice == "p":
        print_handler(repo.decoded_content)
        ui_loop(repo, log_buf, state, is_gist)
    elif choice == "s":
        save_state(state.query, state)
        ui_loop(repo, log_buf, state, is_gist)
    elif choice == "a":
        with open(state.logfile, "a") as fd:
            fd.write(log_buf)
    elif choice.startswith("/"):
        log_buf += regex_handler(choice, repo)
        ui_loop(repo, log_buf, state, is_gist)
    elif choice == "b":
        if state.index - 1 < state.lastInitIndex:
            print(
                bcolors.FAIL +
                "Can't go backwards past restore point "
                "because of rate-limiting/API limitations" +
                bcolors.ENDC)
            ui_loop(repo, log_buf, state, is_gist)
        else:
            state.index -= 2
    elif choice == "q":
        sys.exit(0) 
开发者ID:BishopFox,项目名称:GitGot,代码行数:38,代码来源:gitgot.py

示例7: make_request

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def make_request(url, quiet=False, raw_results=False):
    if not quiet:
        print "Requesting {0}".format(url)
    r = requests.get(url, allow_redirects=False, timeout=90)
    content = r.content
    return r.status_code, ssdeep.hash(content) if not raw_results else content.encode('hex') 
开发者ID:cylance,项目名称:IntroductionToMachineLearningForSecurityPros,代码行数:8,代码来源:utility.py

示例8: scan

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def scan(self, payload: Payload, request: Request) -> WorkerResponse:
        return WorkerResponse(results={'ssdeep': ssdeep.hash(payload.content)}) 
开发者ID:PUNCH-Cyber,项目名称:stoq-plugins-public,代码行数:4,代码来源:hash_ssdeep.py

示例9: ssdeepcompare

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def ssdeepcompare(target, IP):
    try:
        ss_target = requests.get('http://{}/'.format(target))
        ssdeep_target_fuzz = ssdeep.hash(ss_target.text)
        print target, ssdeep_target_fuzz
        content = requests.get('https://{}'.format(IP), verify=False, timeout = 5, headers = {'Host': target})
        ssdeep_fuzz = ssdeep.hash(content.text)
        print IP, ssdeep_fuzz
        print "ssdeep score for", IP, "is", ssdeep.compare(ssdeep_target_fuzz, ssdeep_fuzz)
    except(requests.exceptions.ConnectionError):
        print "cant connect to", IP 
开发者ID:RhinoSecurityLabs,项目名称:Security-Research,代码行数:13,代码来源:cfire.py

示例10: getSsdeep

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def getSsdeep(data):
    try:
        res = ssdeep.hash(data)
        return res
    except Exception, e:
        logging.exception(str(e))
        return ''

# ****************TEST_CODE****************** 
开发者ID:codexgigassys,项目名称:codex-backend,代码行数:11,代码来源:InfoExtractor.py

示例11: get_digest_size

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def get_digest_size(file_handle: IO[bytes]) -> int:
        """ The size of the resulting hash in bytes."""
        pass 
开发者ID:obscuritylabs,项目名称:PeFixup,代码行数:5,代码来源:core_hash.py

示例12: get_hash_digest

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def get_hash_digest(file_handle: IO[bytes]) -> bytes:
        return bytes(str.encode(ssdeep.hash(file_handle))) 
开发者ID:obscuritylabs,项目名称:PeFixup,代码行数:4,代码来源:core_hash.py

示例13: get_hash_hexdigest

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def get_hash_hexdigest(file_handle: IO[bytes]) -> str:
        return ssdeep.hash(file_handle) 
开发者ID:obscuritylabs,项目名称:PeFixup,代码行数:4,代码来源:core_hash.py

示例14: META_BASIC_INFO

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def META_BASIC_INFO(s, buff):

   BASIC_INFO = OrderedDict([('MD5', hashlib.md5(buff).hexdigest()),
                           ('SHA1', hashlib.sha1(buff).hexdigest()),
                           ('SHA256', hashlib.sha256(buff).hexdigest()),
                           ('SHA512', hashlib.sha512(buff).hexdigest()),
                           ('ssdeep' , ssdeep.hash(buff)),
                           ('Size', '%s bytes' % len(buff))])

   return BASIC_INFO 
开发者ID:EmersonElectricCo,项目名称:fsf,代码行数:12,代码来源:META_BASIC_INFO.py

示例15: get_binary_hash

# 需要导入模块: import ssdeep [as 别名]
# 或者: from ssdeep import hash [as 别名]
def get_binary_hash(filename):
    """ Get the md5 hash of the file to put at the top of the document """

    blocksize = 65536
    hasher = hashlib.md5()
    with open(filename, "rb") as afile:
        buf = afile.read(blocksize)
        while len(buf) > 0:
            hasher.update(buf)
            buf = afile.read(blocksize)
    return hasher.hexdigest() 
开发者ID:Dynetics,项目名称:Malfunction,代码行数:13,代码来源:malget.py


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