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
| from __future__ import print_function
rol = lambda val, r_bits, max_bits: \ (val << r_bits % max_bits) & (2 ** max_bits - 1) | \ ((val & (2 ** max_bits - 1)) >> (max_bits - (r_bits % max_bits)))
ror = lambda val, r_bits, max_bits: \ ((val & (2 ** max_bits - 1)) >> r_bits % max_bits) | \ (val << (max_bits - (r_bits % max_bits)) & (2 ** max_bits - 1)) a1=[0xD6,0x90,0x0E9,0x0FE,0x0CC,0x0E1,0x3D,0x0B7,0x16,0x0B6,0x14,0x0C2,0x28,0x0FB,0x2C,0x5,0x2B,0x67,0x9A,0x76,0x2A,0x0BE,0x4,0x0C3,0x0AA,0x44,0x13,0x26,0x49,0x86,0x6,0x99,0x9C,0x42,0x50,0x0F4,0x91,0x0EF,0x98,0x7A,0x33,0x54,0x0B,0x43,0x0ED,0x0CF,0x0AC,0x62,0x0E4,0x0B3,0x1C,0x0A9,0x0C9,0x8,0x0E8,0x95,0x80,0x0DF,0x94,0x0FA,0x75,0x8F,0x3F,0x0A6,0x47,0x7,0x0A7,0x0FC,0x0F3,0x73,0x17,0x0BA,0x83,0x59,0x3C,0x19,0x0E6,0x85,0x4F,0x0A8,0x68,0x6B,0x81,0x0B2,0x71,0x64,0x0DA,0x8B,0x0F8,0x0EB,0x0F,0x4B,0x70,0x56,0x9D,0x35,0x1E,0x24,0x0E,0x5E,0x63,0x58,0x0D1,0x0A2,0x25,0x22,0x7C,0x3B,0x1,0x21,0x78,0x87,0x0D4,0,0x46,0x57,0x9F,0x0D3,0x27,0x52,0x4C,0x36,0x2,0x0E7,0x0A0,0x0C4,0x0C8,0x9E,0x0EA,0x0BF,0x8A,0x0D2,0x40,0x0C7,0x38,0x0B5,0x0A3,0x0F7,0x0F2,0x0CE,0x0F9,0x61,0x15,0x0A1,0x0E0,0x0AE,0x5D,0x0A4,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BF,0x92,0x0EF,0x80]
def xor2(key): new_val=a1[key>>24] << 0x18 | a1[0xff&(key>>16)] << 0x10 | a1[0xff&(key>>8)] << 0x8 | a1[0xff&key] return rol(new_val, 8, 32)^ror(new_val,2,32)^rol(new_val, 0xc, 32)^ror(new_val,6,32) def xor1(a,b,c,d): tp=xor2(b^c^d) return hex(tp^a)[2:-1] def decry1(a,b,c,d): f1=a^xor2(b^c^d) return f1
value=0x635e0e24 newval = rol(value, 8, 32)^ror(value,2,32)^rol(value, 0xc, 32)^ror(value,6,32)
print("0x%08x >> 0x%02x --> 0x%08x" % (value, 8, newval))
flag='dcbahgfe43218765' msg=[flag[0:4].encode('hex'),flag[4:8].encode('hex'),flag[8:12].encode('hex'),flag[12:16].encode('hex')] for i in range(26): msg.append(xor1(int(msg[i],16),int(msg[i+1],16),int(msg[i+2],16),int(msg[i+3],16)))
flag=[0xd8bf92ef,0x9fcc401f,0xc5af7647,0xbe040680] for i in range(26): flag.append(decry1(flag[i],flag[i+1],flag[i+2],flag[i+3])) print (flag)
|