Tags: crypto 

Rating:

alien-transmissions-v2
The aliens are at it again! We've discovered that their communications are in base 512 and have transcribed them in base 10. However, it seems like they used XOR encryption twice with two different keys! We do have some information:

This alien language consists of words delimitated by the character represented as 481
The two keys appear to be of length 21 and 19
The value of each character in these keys does not exceed 255
Find these two keys for me; concatenate their ASCII encodings and wrap it in the flag format.
Based on the hints, we know that the plaintext xored with 21 length key1, and xored with 19 length key2, so the plaintext will xored with the same key every lcm(19,21) => 399 bytes.

Because of the flag is the key, we need to find the keys value instead of the plaintext.

We know that '481' is the most frequent char in the plaintext, so we need to list the ciphertext every 399 bytes for the same subkey, and then we will got the result of (key1^key2 for every permutations) .

```
def most_frequent(List):
return max(set(List), key = List.count)

keys=[]
for a in list(open('encrypted.txt','r')):
keys.append(int(a.strip()))

strs = [keys[i::399] for i in range(0, 399)]
key = []
pt_pieces = []
for s in strs:
high = most_frequent(s)
k = high ^ 0x1e1
key.append(k)

print key
#[55, 71, 26, 0, 120, 0, 108, 23, 88, 93, 59, 57, 0, 71, 106, 0, 55, 89, 1, 51, 18, 0, 0, 45, 6, 20, 86, 111, 26, 12, 108,
#110, 83, 110, 6, 93, 69, 106, 55, 64, 4, 85, 55, 6, 65, 80, 23, 91, 59, 43, 89, 6, 0, 18, 89, 67, 0, 43, 43, 0, 7, 51, 83,
#91, 80, 66, 93, 67, 106, 110, 65, 55, 71, 55, 87, 4, 45, 65, 28, 108, 55, 1, 95, 5, 88, 93, 22, 108, 22, 0, 0, 0, 0, 2, 106,
#57, 69, 26, 6, 43, 106, 91, 87, 92, 8, 12, 108, 67, 6, 120, 65, 55, 69, 93, 108, 43, 14, 2, 45, 0, 71, 60, 88, 90, 8, 57, 89,
#6, 45, 71, 79, 4, 106, 43, 28, 91, 108, 57, 4, 65, 86, 68, 49, 12, 107, 93, 83, 55, 71, 26, 2, 18, 106, 43, 28, 91, 108, 106, 85,
#82, 66, 91, 16, 0, 89, 1, 51, 18, 0, 2, 71, 108, 83, 93, 108, 43, 93, 0, 60, 86, 95, 22, 106, 69, 106, 55, 64, 4, 87, 93, 108, 6,
#91, 20, 106, 106, 71, 11, 3, 49, 2, 110, 67, 0, 43, 43, 0, 5, 89, 57, 28, 91, 65, 108, 18, 6, 60, 68, 6, 87, 0, 87, 4, 45, 65,
#28, 110, 93, 107, 24, 14, 91, 108, 71, 0, 68, 5, 49, 16, 55, 2, 106, 57, 69, 26, 4, 65, 0, 28, 92, 95, 57, 93, 0, 17, 3, 73,
#81, 0, 69, 93, 108, 43, 14, 0, 71, 106, 0, 55, 91, 107, 89, 85, 11, 3, 28, 87, 120, 4, 106, 43, 28, 91, 110, 83, 110, 6, 93,
#71, 0, 93, 7, 15, 86, 6, 87, 45, 2, 18, 106, 43, 28, 89, 6, 0, 18, 89, 65, 106, 65, 108, 11, 4, 2, 2, 55, 2, 71, 108, 83, 93,
#110, 65, 55, 71, 55, 85, 110, 71, 6, 23, 111, 6, 80, 51, 87, 93, 108, 6, 91, 22, 0, 0, 0, 0, 0, 0, 83, 2, 17, 5, 26, 59, 55,
#5, 89, 57, 28, 91, 67, 6, 120, 65, 55, 71, 55, 6, 108, 5, 1, 28, 81, 43, 110, 93, 107, 24, 14, 89, 6, 45, 71, 79, 6, 0, 65,
#91, 80, 111, 8, 85, 45, 4, 65, 0, 28, 92, 93, 83]
```

the next thing is we need to find about the value of key1 and key2.

Since we already got equation for every permutation key1^key2, try to bruteforce all the possibility of the key using z3.

And we got the flag :

**flag{h3r3'5_th3_f1r5t_h4lf_th3_53c0nd_15_th15}**

Linz3July 3, 2020, 1:45 p.m.

GG