سبحان الله و بحمده سبحان الله العظيم ❤️

← BACK TO WRITEUPS
Cryptography picoCTF HIGH

Playfair — 6×6 Variant Cipher Decryption

Server: nc mercury.picoctf.net 19354

Challenge

The server provides a randomly generated 36-character alphabet, encrypts a message using a 6×6 Playfair variant, and expects decryption. The plaintext doesn't follow standard picoCTF{...} format.

6×6 Playfair Decryption Rules

def decrypt_pair(pair, matrix):
    p1 = get_index(pair[0], matrix)
    p2 = get_index(pair[1], matrix)
    if p1[0] == p2[0]:  # Same row - shift left
        return matrix[p1[0]][(p1[1]-1) % 6] + \
               matrix[p2[0]][(p2[1]-1) % 6]
    elif p1[1] == p2[1]:  # Same column - shift up
        return matrix[(p1[0]-1) % 6][p1[1]] + \
               matrix[(p2[0]-1) % 6][p2[1]]
    else:  # Rectangle - swap columns
        return matrix[p1[0]][p2[1]] + matrix[p2[0]][p1[1]]

Key Insights

Flag

dbc8bf9bae7152d35d3c200c46a0fa30