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


Python mmh3.hash64方法代码示例

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


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

示例1: copy_bitmap

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def copy_bitmap(self, shm, num, size, bitmap, payload, payload_size, effector_mode=False):
        new_hash = mmh3.hash64(bitmap)
        if not (self.crashed or self.kasan or self.timeout):
            if new_hash in self.lookup.non_finding:
                if effector_mode:
                    shm.seek(size * num)
                    shm.write(bitmap)
                    return True
                else:
                    shm.seek((size * num) + len(bitmap))
                    return False

        if not (self.crashed or self.kasan or self.timeout) and not self.check_for_unseen_bits(bitmap):
            self.lookup.non_finding[new_hash] = None
            return False
        if not (self.timeout):
            bitmap = self.verifiy_input(payload, bitmap, payload_size)
            shm.seek(size * num)
            shm.write(bitmap)
        self.lookup.non_finding[new_hash] = None
        return True 
开发者ID:RUB-SysSec,项目名称:kAFL,代码行数:23,代码来源:qemu.py

示例2: sim_shi4_mm3_text

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def sim_shi4_mm3_text(text):
    text = HTML_COMMENT_RE.sub(" ", text)
    text = SCRIPT_RE.sub(" ", text)
    text = STYLE_RE.sub(" ", text)
    text = HTML_TAGS_RE.sub(" ", text)
    text = HTML_ENTITIES_RE.sub(" ", text)
    text = NONTEXT_RE.sub(" ", text)  # replace all runs of spaces and punctuation

    i1, i2 = itertools.tee(WORD_RE.finditer(text))
    for _ in xrange(3):  # 4 words per shingle
        next(i2, None)

    hash64 = mmh3.hash64
    # NB: `array` of i64 & ui64 is Python 3.3+
    mm = [
        hash64(text[m1.start() : m2.end()])[0] & 0xFFFFFFFFFFFFFFFF
        for m1, m2 in itertools.izip(i1, i2)
    ]
    r = simhash.compute(mm)
    return r - 0x10000000000000000 if r > 0x7FFFFFFFFFFFFFFF else r 
开发者ID:ooni,项目名称:pipeline,代码行数:22,代码来源:sim.py

示例3: hash_string

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def hash_string(string: str) -> int:
    """Create a hash for a given string. 
    Hashes created by this functions will be used everywhere by
    SyferText to represent tokens.
    """

    key = mmh3.hash64(string, signed=False, seed=1)[0]

    return key 
开发者ID:OpenMined,项目名称:SyferText,代码行数:11,代码来源:utils.py

示例4: debug_execution

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def debug_execution(config, execs, qemu_verbose=False, notifiers=True):
    log_info("Starting...")

    zero_hash = mmh3.hash64(("\x00" * config.config_values['BITMAP_SHM_SIZE']))
    q = qemu(1337, config, debug_mode=True, notifiers=notifiers)
    q.start(verbose=qemu_verbose)
    q.set_payload(open(config.argument_values["payload"][0]).read())
    # try:
    start = time.time()
    for i in range(execs):
        if i % 3 == 0:
            q.set_payload(open(config.argument_values["payload"][0]).read())
        # time.sleep(0.01 * randint(0, 9))
        print("+----------------------------------------------+")
        # a = str(q.send_payload())
        # hexdump(a)
        current_hash = q.send_payload().hash()
        if zero_hash == current_hash:
            print("Hash: " + str(
                current_hash) + common.color.WARNING + " (WARNING: Zero hash found!)" + common.color.ENDC)
        else:
            print("Hash: " + str(current_hash))
    end = time.time()
    print("Performance: " + str(execs / (end - start)) + "t/s")
    # except:
    #    print("EXC")

    q.__del__()
    try:
        for i in range(512):
            if os.path.exists("/tmp/kAFL_printf.txt." + str(i)):
                os.remove("/tmp/kAFL_printf.txt." + str(i))
            else:
                break
    except:
        pass
    os.system("stty sane")
    return 0 
开发者ID:RUB-SysSec,项目名称:grimoire,代码行数:40,代码来源:core.py

示例5: murmur3_64bit

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def murmur3_64bit(obj):
    """
    Use murmur3_64bit for 64 bit hash by passing this method:
    hasher=DeepHash.murmur3_64bit
    """
    if isinstance(obj, str):
        obj = obj.encode('utf-8')
    # This version of murmur3 returns two 64bit integers.
    return mmh3.hash64(obj, MURMUR_SEED)[0] 
开发者ID:seperman,项目名称:deepdiff,代码行数:11,代码来源:deephash.py

示例6: __req_effector_tag_handler

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def __req_effector_tag_handler(self, request):
        #log_mapserver("New Effector Map (" + str(len(request.data)) + ")")
        self.effector_initial_bitmap = mmh3.hash64(request.data)
        for i in range(self.config.config_values['PAYLOAD_SHM_SIZE']):
            self.effector_map.append(False) 
开发者ID:RUB-SysSec,项目名称:kAFL,代码行数:7,代码来源:mapserver.py

示例7: sim_shi4_mm3_layout

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def sim_shi4_mm3_layout(text):
    text = SPACE_RE.sub(" ", text)  # replace all runs of spaces

    i1, i2 = itertools.tee(WORD_RE.finditer(text))
    for _ in xrange(3):  # 4 words per shingle
        next(i2, None)

    hash64 = mmh3.hash64
    # NB: `array` of i64 & ui64 is Python 3.3+
    mm = [
        hash64(text[m1.start() : m2.end()])[0] & 0xFFFFFFFFFFFFFFFF
        for m1, m2 in itertools.izip(i1, i2)
    ]
    r = simhash.compute(mm)
    return r - 0x10000000000000000 if r > 0x7FFFFFFFFFFFFFFF else r 
开发者ID:ooni,项目名称:pipeline,代码行数:17,代码来源:sim.py

示例8: sim_shi4_mm3

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def sim_shi4_mm3(text):
    # NB: It makes quite little sense to use both 64bit numbers to compare
    # hashes as pairwise Hamming distance using high 64bit is highly correlated
    # with the distance computed using low 64bit. It's actually expected, but
    # it means, that summing these distances is not linear and should be avoided.
    # -- https://gist.github.com/darkk/e2b2762c4fe053a3cf8a299520f0490e
    i1, i2 = itertools.tee(WORD_RE.finditer(text))
    for _ in xrange(3): # 4 words per shingle
        next(i2, None)
    mm = [mmh3.hash64(text[m1.start():m2.end()]) for m1, m2 in itertools.izip(i1, i2)]
    return (simhash.compute([_[0] & 0xffffffffffffffff for _ in mm]),
            simhash.compute([_[1] & 0xffffffffffffffff for _ in mm])) 
开发者ID:ooni,项目名称:pipeline,代码行数:14,代码来源:simhash_seomoz.py

示例9: main

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def main():
    simhash.Simhash(unicode(TEXT, 'utf-8'), reg=RE_WORD, hashfunc=lambda x: mmh3.hash64(x)[0]) 
开发者ID:ooni,项目名称:pipeline,代码行数:4,代码来源:simhash_leonsim.py

示例10: triple_hash

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def triple_hash(self, item):
        '''Returns a triple i, val, aug hashed values, where i is bucketbits,
        val is the position of the leading one in a 64-bit integer, and aug is the bits
        to go in the subbuckets'''

        y, h2 = mmh3.hash64(str(item).encode())
        val = 64 + 1 - int(np.uint64(y)).bit_length()
        val = min(val, 2**self.bucketsize)

        h2prime = int(np.uint64(h2))
        i = h2prime >> self._bucketbit_shift
        aug = h2prime & self._bbit_mask

        return (i, val, aug) 
开发者ID:yunwilliamyu,项目名称:hyperminhash,代码行数:16,代码来源:hyperminhash.py

示例11: benchmark

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def benchmark(config):
    log_info("Starting...")

    q = qemu(1337, config, debug_mode=False)
    q.start(verbose=False)
    q.set_payload(open(config.argument_values["payload"][0]).read())
    print(mmh3.hash64(q.send_payload()))
    try:
        while True:
            start = time.time()
            execs = 0
            while (time.time()-start < REFRESH):
                q.set_payload(open(config.argument_values["payload"][0]).read())
                q.send_payload()
                execs += 1
            end = time.time()
            stdout.write(common.color.FLUSH_LINE + "Performance: " + str(execs/(end - start)) + "t/s")
            stdout.flush()
    except:
        print("\nExit")
  
    q.__del__()
    try:
        for i in range(512):
            if os.path.exists("/tmp/kAFL_printf.txt." + str(i)):
                os.remove("/tmp/kAFL_printf.txt." + str(i))
            else:
                break
    except:
        pass
    return 0 
开发者ID:RUB-SysSec,项目名称:redqueen,代码行数:33,代码来源:core.py

示例12: debug_execution

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def debug_execution(config, execs, qemu_verbose=False, notifiers=True):
    log_info("Starting...")

    zero_hash = mmh3.hash64(("\xFF" * config.config_values['BITMAP_SHM_SIZE']))
    q = qemu(1337, config, debug_mode=True, notifiers=notifiers)
    q.start(verbose=qemu_verbose)
    q.set_payload(open(config.argument_values["payload"][0]).read())
    start = time.time()
    for i in range(execs):
        print("+----------------------------------------------+")
        current_hash = mmh3.hash64(q.send_payload())
        if zero_hash == current_hash:
            print("Hash: " + str(current_hash) + common.color.WARNING + " (WARNING: Zero hash found!)" + common.color.ENDC)
        else:
            print("Hash: " + str(current_hash))
    end = time.time()
    print("Performance: " + str(execs/(end - start)) + "t/s")
  
    q.__del__()
    try:
        for i in range(512):
            if os.path.exists("/tmp/kAFL_printf.txt." + str(i)):
                os.remove("/tmp/kAFL_printf.txt." + str(i))
            else:
                break
    except:
        pass
    os.system("stty sane")
    return 0 
开发者ID:RUB-SysSec,项目名称:redqueen,代码行数:31,代码来源:core.py

示例13: __req_effector_tag_handler

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def __req_effector_tag_handler(self, request):
        log_mapserver("New Effector Map (" + str(len(request.data)) + ")")
        self.effector_initial_bitmap = mmh3.hash64(request.data)
        for i in range(self.config.config_values['PAYLOAD_SHM_SIZE']):
            self.effector_map.append(False) 
开发者ID:RUB-SysSec,项目名称:redqueen,代码行数:7,代码来源:mapserver.py

示例14: __respond_bitmap_hash_req

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def __respond_bitmap_hash_req(self, response):
        self.q.set_payload(response.data)
        while True:
            try:
                bitmap = self.q.send_payload()
                break
            except:
                log_slave("__respond_bitmap_hash_req failed...", self.slave_id)
                log_slave("%s"%traceback.format_exc(), self.slave_id)
                self.__restart_vm()
        send_msg(KAFL_TAG_REQ_BITMAP_HASH, mmh3.hash64(bitmap), self.comm.to_master_from_slave_queue, source=self.slave_id) 
开发者ID:RUB-SysSec,项目名称:redqueen,代码行数:13,代码来源:slave.py

示例15: __result_tag_handler

# 需要导入模块: import mmh3 [as 别名]
# 或者: from mmh3 import hash64 [as 别名]
def __result_tag_handler(self, request):
        self.comm.slave_locks_B[request.source].acquire()
        results = request.data
        payloads = []
        bitmaps = []
        payload_shm = self.comm.get_mapserver_payload_shm(request.source)
        bitmap_shm = self.comm.get_bitmap_shm(request.source)

        for result in results:
            if result.new_bits:
                bitmap_shm.seek(result.pos * self.comm.get_bitmap_shm_size())
                payload_shm.seek(result.pos * self.comm.get_mapserver_payload_shm_size())
                length = payload_shm.read(4)
                data_len = (ord(length[3]) << 24) + (ord(length[2]) << 16) + (ord(length[1]) << 8) + \
                           (ord(length[0]))
                payloads.append(payload_shm.read(data_len))
                bitmaps.append(bitmap_shm.read(self.comm.get_bitmap_shm_size()))
            else:
                payloads.append(None)
                bitmaps.append(None)
                #log_mapserver("[MAPS]\t\ SKIP")
        self.comm.slave_locks_A[request.source].release()
        for i in range(len(results)):
            if results[i].reloaded:
                self.abortion_counter += 1

            if results[i].new_bits:
                if results[i].timeout:
                    self.mapserver_state_obj.timeout += 1
                new_hash = mmh3.hash64(bitmaps[i])

                self.__check_hash(new_hash, bitmaps[i], payloads[i], results[i].crash, results[i].timeout, results[i].kasan, results[i].slave_id, results[i].reloaded, results[i].performance, results[i].qid, results[i].pos)
                self.last_hash = new_hash
                self.round_counter += 1
                if self.effector_initial_bitmap:
                    if self.effector_initial_bitmap != new_hash:
                        for j in results[i].affected_bytes:
                            if not self.effector_map[j]:
                                self.effector_map[j] = True
            else:
                self.round_counter += 1

        # TODO: Replace const value by performance*(1/50)s
        if self.abortion_counter >= self.abortion_threshold:
            if not self.abortion_alredy_sent:
                log_mapserver("Stage abortion limit (" + str(self.abortion_threshold) + ") reached!")
                send_msg(KAFL_TAG_ABORT_REQ, self.mapserver_state_obj, self.comm.to_master_queue)
                self.abortion_alredy_sent = True
                self.comm.stage_abortion_notifier.value = True 
开发者ID:RUB-SysSec,项目名称:kAFL,代码行数:51,代码来源:mapserver.py


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