Writeups
  • Archive
  • 2021
    • CSAW Qualification Round
      • Crypto
        • Gotta Decrypt Them All
    • TMUCTF
      • 435!
      • Common Factor
    • WORMCON 0x01
      • Fake Encryption
      • Rem, Shinobu, Asuna
      • Exclusive
      • Sir Oracle
      • Invisible Cipher
Powered by GitBook
On this page

Was this helpful?

  1. 2021
  2. WORMCON 0x01

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

🔰 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}

PreviousSir Oracle

Last updated 3 years ago

Was this helpful?

Solve Script:

solve.py
https://en.wikipedia.org/wiki/Frequency_analysis