Created
November 25, 2020 11:21
-
-
Save pawlos/556d2353d4ce668168e17670f1636312 to your computer and use it in GitHub Desktop.
Solution to retrozeit from DragonCTF 2020
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interesting_data = [0x8b,0x84,0x9a,0x9b,0x9a,0xb1,0xd6,0xaf,0x93,0xb2,0x81,0x8c,0x84,0xab,0x9d,0x9c,0x8e,0xb9,0xb0,0xd9,0xa8,0xa4,0x9c,0x81,0x85,0xa0,0xa6,0xb4,0x87,0x9a,0xbb,0x92,0x96,0xad,0x8c,0xd7,0xb0,0x8d,0x97] | |
shuffle = [0x16,0x0c,0x24,0x17,0x13,0x19,0x07,0x09,0x0e,0x23,0x05,0x01,0x18,0x21,0x0d,0x10,0x12,0x1f,0x1a,0x1e,0x22,0x00,0x0f,0x0b,0x08,0x15,0x11,0x02,0x1d,0x1c,0x26,0x03,0x04,0x25,0x14,0x20,0x06,0x1b,0x0a] | |
interesting_data = interesting_data[:0x27] | |
m = 38 | |
j = 0 | |
for k in range(len(interesting_data)//2): | |
i = shuffle.index(m) | |
uVar1 = shuffle[i] | |
uVar2 = interesting_data[i] | |
shuffle[i] = shuffle[j] | |
interesting_data[i] = interesting_data[j] | |
shuffle[j] = uVar1 | |
interesting_data[j] = uVar2 | |
m -= 2 | |
j += 2 | |
j = 1 | |
m = 1 | |
for k in range(len(interesting_data)//2): | |
i = shuffle.index(m) | |
uVar1 = shuffle[i] | |
uVar2 = interesting_data[i] | |
shuffle[i] = shuffle[j] | |
interesting_data[i] = interesting_data[j] | |
shuffle[j] = uVar1 | |
interesting_data[j] = uVar2 | |
j += 2 | |
m += 2 | |
res = [] | |
for i,c in enumerate(interesting_data): | |
res.append(chr(((~c & 0xff) ^ i))) | |
res = ''.join(res) | |
print(f'{res}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment