Invisible Cipher

#!/usr/bin/env python3

def encrypt(pt, PTALPHA, CTALPHA):
	ct = ''
	for ch in pt:
		i = PTALPHA.index(ch)
		ct += CTALPHA[i]
	return ct


PTALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '
CTALPHA = open('CTALPHA.txt').read().strip()
FLAG = open('flag.txt').read().strip()

assert len(CTALPHA) == len(PTALPHA)
assert all(x in PTALPHA for x in FLAG)

enc_flag = encrypt(FLAG, PTALPHA, CTALPHA)

with open('flag.enc','w') as f:
	f.write(enc_flag)
	print('DONE')

This was a basic Frequency analysis challenge and the ciphertext key-space/map was random Unicode characters. So,

  • Pick up the nonsense phrase "ETAOIN SHRDLU" that represents the 12 most frequent letters in typical English language text.

  • Check the frequency of each of the letters occurring in the ciphertext

  • Start to map them to the original English Alphabet/map/key-space

  • Assume the remaining common English words and totally recover the plaintext + FLAG

Solve Script: solve.py

🔰 you can uncomment this part in the solve script to see what's happening

# visualize with
# pt = viz_us(pt)
pt = viz_idx(pt, enc_flag)

Flag: wormcon{CAREFUL_FREQUENCY_ANALYSIS_BREAKS_SUBSTITUTION_CIPHER}

Last updated