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
| from z3 import *
FLAG_LEN = 30 sub = [24, 12, 28, 21, 14, 7, 13, 10, 3, 0, 18, 9, 22, 25, 6, 8, 20, 19, 23, 11, 29, 27, 17, 16, 26, 2, 5, 4, 15, 1] key = b'\xa4r\xa9\xf6\xad\xc2\x11\x18?\xc8\xd01\x01\xd8\xf3\x8cV[8\xce\x9ew\xbb\x179\n\xbaP\x8f\xec_u\xe4Y4\xd0Q\xf0s\x99\x8f\xd1\\\xde4\x8fBZOE=Z\x8bo\x91\xea\x03\xca\xd1C\xf7-6<-_m\x18\x07L\xc48\xf1\x91l\xa7\x01aG\x91\xc5\x0c\xe8\x87\xbc\xb5\xc6\xc7@\xf3%\xa6\x0c\x98"/M\xa1\x80\xaeT#,\xf0\xdc\xb6\xcb#1\x8f\xf5A\x8ap\x10NE\xe69\x0eO\xcaK\x9d\xa9\x06p\\\xba\xa5X\xdf\x82\xe9}\xad\xe3]P\xd7\x7f\xe4\x9b:&\x00\xaa3\xca>x:\xa31\xd2\xcf\xbd\xd2\xf4\xd9\x89\xe9A\xf3G\x89C\x02\xd7\x98=\xed\xd5(\xe2\xdf6fZ\x12\xcbd\xd4 89"\xd0\xdea\xd9\x8eQ&>&f\xc8\xfaX\xf3\xc4V\x13\x83\x97\x88u\x7f\x8a \xa1\xa9\xa3\x0e-\xcf\xe4\xd2\x9a\x85\xed-\\\xe4q\xd9\xbcV\xb3\xe4y\x8c\x83\xddJ\x04V\xf8\xc5g4i\xf6\xc2%\xa1\xc4=\x8a\x828\x8a\xaey\xfbL\xbf\xcer\x96f\xc7,b\xd4U\x81\xd8=\'[k\xee3\xb4B\x03As\x86W\xe1\xa7R\x01\xc3\xbb\xf3\xb4\x14\xfdP\xd9aq\xcfo\xfd\xf9\xc2r\xe6.\x8f\xf8eT\xa8\xde^\xd5\xe0x\xe8\xbcD\xacJR!\xf4>\xa5\xc3V\xe2\x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\x12\x1aj\xab\xfd\xd4\xf8Zx\x04\x1a%\xed\x9c\xd2\x84\xed\x8dz\xbfA"%;3\xdf\x914>\xf4\xf7jl\xd6\x19E\xb4U\xad\r\xcf\x9fJ\x07\x8c\x87\x14aq \xe3v\x84uQz\xd8\xa1*\xc4\xc2\xea\x1bv.\x07\x88\x1f)\x8cD[\x12 \x92]\x9b\xb6\x1fz\x9f\xb4\xf3XI\xe3S\xe0\xc8\xdd\xb5w\xe4\x10Eo\x9f\xf0x\xba\xfd\x13\xcc(Y#\xcfO}\x1f\xde\xf1\xa9\xfc\xee\xee\xf4\x8aD\xff{\x8a\xe9\x7f,(\xb2/g\x84w\x80p\x93|\x87f\xf4\xc1nC)4\x10q\x1fc<\xa0\xdf0\xfa\xb0\xcf{_\xb0\xe5\xc1#\x1a\x0653\xb9\xccJ\x84o\xdc\x1b\xef\xc5m\x18>b\x03<"\x803 \x13)\x9e\x94)\xce' enc = [12, 115, 141, 48, 115, 115, 121, 96, 85, 91, 115, 187, 28, 42, 62, 40, 200, 95, 192, 112, 15, 17, 75, 173, 123, 243, 156, 32, 182, 222] tmp = [BitVec('tmp%d' % i, 8) for i in range(FLAG_LEN)] matrixA = [] for i in range(FLAG_LEN): line = [0] * FLAG_LEN for j in range(FLAG_LEN): line[j] = key[FLAG_LEN * j + i] matrixA.append(line) solver = Solver() for i in range(FLAG_LEN): sum = 0 for j in range(FLAG_LEN): sum = (sum + ((tmp[j] * matrixA[i][j]) % 256)) % 256 solver.add(sum == enc[i]) if solver.check() != sat: raise RuntimeError() m = solver.model() print(solver.model()) flag = "" for i in range(FLAG_LEN): tmp[i] = m[tmp[i]].as_long().real flag = [0] * 30 for i in range(30): flag[sub[i]] = tmp[i] for i in range(30): print(chr(flag[i]), end="")
|