1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| from z3 import *
s = Solver() ymm0 = [BitVec('x%d'%i, 8) for i in range(32)]
ymm7 = [0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00] ymm1 = [0xF0, 0xFF, 0x64, 0x26, 0xF2, 0x8F, 0x40, 0xEE, 0xEE, 0x27, 0x07, 0xEF, 0x88, 0x0A, 0x21, 0x14, 0xC3, 0xFC, 0x70, 0xE5, 0xA8, 0xF3, 0xF5, 0x1A, 0xD4, 0x3C, 0xB1, 0x0C, 0xE5, 0xBC, 0xB9, 0x1B] ymm2 = [0x0D, 0xC0, 0x84, 0xC5, 0x0E, 0x80, 0x50, 0xFF, 0x28, 0x1A, 0x80, 0x48, 0x1D, 0xC1, 0xE3, 0x1D, 0x34, 0x51, 0x9B, 0x35, 0xBC, 0xD5, 0xF4, 0xC3, 0xC4, 0x40, 0x90, 0x07, 0x2A, 0xC0, 0x2D, 0x90] ymm3 = [0x89, 0xA1, 0x3E, 0xC0, 0xE5, 0x14, 0x5F, 0xC5, 0x5F, 0x14, 0xB0, 0xD0, 0x25, 0x1F, 0xE8, 0xF5, 0xB0, 0x34, 0x36, 0xC2, 0xC7, 0xA0, 0xB2, 0x3C, 0x5E, 0x7E, 0x9C, 0xA4, 0x98, 0xE8, 0x54, 0x0B] ymm4 = [0x33, 0x5F, 0x62, 0x68, 0x0D, 0x64, 0xA8, 0xFF, 0x8F, 0x99, 0xA7, 0x94, 0x9E, 0x9A, 0x29, 0x34, 0x27, 0x36, 0xD6, 0x82, 0xC2, 0x6D, 0xE8, 0xAA, 0x96, 0x4A, 0x65, 0xC0, 0x0C, 0x37, 0x19, 0xC9] ymm5 = [0x8F, 0x21, 0xA8, 0x37, 0x43, 0x09, 0x07, 0x33, 0xA6, 0x87, 0x4C, 0x4A, 0xA1, 0x74, 0x4B, 0xE6, 0x55, 0x13, 0x5B, 0x3F, 0x1C, 0xD7, 0xB9, 0x9E, 0x39, 0x60, 0x1D, 0xC6, 0x91, 0x8A, 0x36, 0x8B] ymm6 = [0x00, 0x01, 0x08, 0x09, 0x0A, 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0D, 0x0E, 0x06, 0x07, 0x0B, 0x0F, 0x00, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x02, 0x03, 0x04, 0x05, 0x0D, 0x0E, 0x0B, 0x0C, 0x01, 0x0F]
enc = [0x93, 0xCB, 0xE7, 0x93, 0xA9, 0x81, 0x0D, 0xB6, 0xD8, 0xDD, 0x9C, 0x7F, 0xC0, 0x4D, 0xCD, 0xF0, 0x00, 0xA0, 0x9F, 0x22, 0x89, 0xEF, 0x54, 0x5D, 0xEF, 0x00, 0x8D, 0xFE, 0x5E, 0x4C, 0xD0, 0xEC]
def vpermd(a, b): tmp = b[:] for i in range(8): b[4*i:4*i+4] = tmp[4*a[i*4]:4*a[i*4]+4]
def vpxor(a, b): for i in range(32): a[i] ^= b[i]
def vpaddb(a, b): for i in range(32): a[i] += b[i] def vpsubb(a, b): for i in range(32): a[i] -= b[i] def vpshufb(a, b): tmp = a[:] for i in range(16): if b[i]&0x80: a[i] = 0 else: a[i] = tmp[b[i]&0xf] if b[i+16]&0x80: a[i+16] = 0 else: a[i+16] = tmp[16+(b[i+16]&0xf)] vpermd(ymm7, ymm4) vpxor(ymm4, ymm5) vpxor(ymm0, ymm2) vpaddb(ymm0, ymm2) ... ... ... vpxor(ymm4, ymm1) vpaddb(ymm2, ymm5) vpxor(ymm0, ymm1) vpaddb(ymm0, ymm5) vpermd(ymm7, ymm5) vpaddb(ymm0, ymm4) vpshufb(ymm5, ymm6) vpsubb(ymm3, ymm1) vpaddb(ymm5, ymm1) vpermd(ymm7, ymm1)
for i in range(32): s.add(ymm0[i] == enc[i]) if s.check() == sat: m = s.model() ymm0 = [BitVec('x%d'%i, 8) for i in range(32)] flag = [m[i].as_long() for i in ymm0] print(bytes(flag)) else: print("Not Found!")
|