예제 #1
0
def test_bin_reverse():
    assert p8(0x12) == b"\x12"
    assert p8(0x34) == b"\x34"
    assert p8(0xff) == b"\xff"

    assert p16(0x5678) == b"\x78\x56"
    assert p16(0xffff) == b"\xff\xff"

    assert p32(0x87654321) == b"\x21\x43\x65\x87"
    assert p32(0xffffffff) == b"\xff\xff\xff\xff"

    assert p64(0x8877665544332211) == b"\x11\x22\x33\x44\x55\x66\x77\x88"
    assert p64(0xffffffffffffffff) == b"\xff\xff\xff\xff\xff\xff\xff\xff"
예제 #2
0
def test_unsigned():
    assert UInt8(255) + 10 + 256 == 9
    n = UInt8(-1)
    n -= 1
    assert n == 254

    assert UInt16(0xF0F0) << 8 == 0xF000
    assert UInt16(0x4000) << 1 == 0x8000
    assert UInt64(0xFFFFFFFF) << 32 == 0xFFFFFFFF00000000
    assert UInt64(0xFFFFFFFF) << 48 == 0xFFFF000000000000
    assert UInt64(0xFFFFFFFF) >> 32 == 0
    assert UInt32(0xFFFFFFFF) << 32 == 0

    assert UInt8(-1) == 255
    assert UInt16(-1) == 65535
    assert UInt16(-1) * -1 == 1
    assert UInt16(-4) / 2 == UInt16(-4) >> 1
    assert UInt32(-65535) > UInt32(65535)

    assert UInt32(0x4444FFFF) << 16 | 0x8080 == 0xFFFF8080

    assert UInt8(UInt32(0xF0F0F0F0)) == 0xF0

    assert 255 + UInt8(1) == 256
    assert UInt8(255) + 1 == 0

    assert -UInt8(-1) == 1
    assert -UInt8(1) == UInt8(-1)

    assert ~UInt8(0xFF) == 0

    assert abs(UInt8(-1)) == UInt8(-1)

    assert p64(0x12345678) == b"\x78\x56\x34\x12\x00\x00\x00\x00"
    assert p32(0x12345678) == b"\x78\x56\x34\x12"
    assert p8(0x12345678) == b"\x78"

    assert p16(-1) == b"\xFF\xFF"
    assert p16(-32768) == b"\x00\x80"

    assert u32(b"\x78\x56\x34\x12") == 0x12345678

    assert u64(b"\x78\x56\x34\x12") is None
예제 #3
0
              mem[11] == 3917315412)
    r11 = And(mem[8] == 4025255646, mem[9] == 2813168974, mem[10] == 614968622,
              mem[11] == 1827055294)
    r12 = And(mem[8] == 3747612986, mem[9] == 1340672294,
              mem[10] == 1301225350, mem[11] == 3708166042)
    r13 = And(mem[8] == 3098492862, mem[9] == 3064954302,
              mem[10] == 3086875838, mem[11] == 3120414398)
    r14 = And(mem[8] == 2130820044, mem[9] == 2115580844,
              mem[10] == 2130523044, mem[11] == 2145762244)

    s.add(Or(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14))

s_count = 0
s.add(args[0] == u32(b"zer0"))
s.add(args[1] == u32(b"pts{"))

while s_count < 4 and s.check() == sat:
    model = s.model()
    args_sol = [model[args[i]].as_long() for i in range(14)]

    print(''.join([p32(a).decode("utf-8") for a in args_sol]))

    cond = True
    for i in range(0, 14):
        cond = And(cond, args[i] == args_sol[i])

    s.add(Not(cond))
    s_count += 1

print("Done")