Python z3.LShR() Examples

The following are 9 code examples of z3.LShR(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module z3 , or try the search function .
Example #1
Source File: chicken_scheme.py    From acsploit with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def chicken_hash_xor(bytes, m, r):
    key = z3.BitVecVal(r, 64)
    for byte in bytes:
        key ^= ((key << 6) + (z3.LShR(key, 2)) + z3.ZeroExt(56, byte))
    return key 
Example #2
Source File: crc32.py    From acsploit with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def z3crc32(bytes, hash_table_size):  # computes the crc32 checksum in z3 format
    checksum = 0x00000000ffffffff
    for byte in bytes:
        checksum ^= z3.ZeroExt(56, byte) & 0xff
        for _ in range(8):  # test each bit in the byte we just xor'd in
            checksum = z3.If(checksum & 1 == z3.BitVecVal(1, 64),
                             z3.LShR(checksum, 1) ^ 0xedb88320,  # the binary representation of the CRC-32 polynomial
                             z3.LShR(checksum, 1))
    return (checksum ^ 0xffffffff) % hash_table_size 
Example #3
Source File: find_name_for_bits.py    From on-pwning with MIT License 5 votes vote down vote up
def hash2(name):
    h = z3.BitVecVal(0, 16)
    assert len(name) % 2 == 0  # for simplicity
    for i in range(0, len(name), 2):
        a = z3.BitVecVal(0, 16)
        a |= z3.Extract(15, 0, name[i])
        a |= z3.Extract(15, 0, name[i + 1]) << 8
        h ^= a
    a = z3.LShR(h, 10)
    b = z3.ZeroExt(8, z3.Extract(7, 0, h ^ z3.LShR(h, 5)))
    h = (a ^ b) & 0x1f
    return h 
Example #4
Source File: find_name_for_bits.py    From on-pwning with MIT License 5 votes vote down vote up
def hash3(name):
    h = z3.BitVecVal(0, 32)
    for i in range(len(name)):
        for j in range(8):
            h = z3.If(z3.LShR(name[i], j) & 1 == 1, (h + 1) & 0xff, h)
        h &= 0x1f
    return h 
Example #5
Source File: amadhj.py    From on-pwning with MIT License 5 votes vote down vote up
def f_b(a1, a2, a3):
    return (to8(z3.LShR(a1, 8 * a2)) << 8 * a3) | (
        to8(z3.LShR(a1, 8 * a3)) << 8 * a2) | ~(255 << 8 * a2) & ~(255 << 8 * a3) & a1 
Example #6
Source File: amadhj.py    From on-pwning with MIT License 5 votes vote down vote up
def f_c(a1, a2):
    return (a1 << (a2 & 0x3F)) | (z3.LShR(a1, (64 - (a2 & 0x3F)))) 
Example #7
Source File: amadhj.py    From on-pwning with MIT License 5 votes vote down vote up
def f_f(a1):
    return z3.LShR((a1 & 0xFF00000000000000), 8) | z3.LShR((a1 & 0xFF000000000000), 40) | z3.LShR(
        (a1 & 0xFF0000000000), 40) | z3.LShR((a1 & 0xFF00000000), 16) | ((to32(a1) & 0xFF000000) << 16) | (
            (a1 & 0xFF0000) << 40) | ((to16(a1) & 0xFF00) << 24) | (to16(a1) << 24) 
Example #8
Source File: crc32.py    From z3-stuff with Mozilla Public License 2.0 5 votes vote down vote up
def crc32(data,size,prev=0):
	crc = prev ^ 0xFFFFFFFF
	for i in range(0,size,8):
		crc = crc ^ (z3.LShR(data,i) & 0xFF)
		for _ in range(8):
			crc = If(crc & 1 == BitVecVal(1, size), z3.LShR(crc,1) ^ polynomial, z3.LShR(crc,1))
	return crc ^ 0xFFFFFFFF 
Example #9
Source File: amadhj.py    From on-pwning with MIT License 4 votes vote down vote up
def f_d(a1, a2):
    return (a1 << (64 - (a2 & 0x3F))) | z3.LShR(a1, (a2 & 0x3F))