Cryptography


CybHer CTF.

Cryptography is the science of securing communication and data by transforming it into an unreadable format using mathematical algorithms, ensuring confidentiality, integrity, and authenticity. It employs techniques like encryption, where data is encoded with a key, and decryption, where the key is used to revert it to its original form. Modern cryptography underpins technologies like blockchain, secure messaging, and digital signatures, protecting information in digital systems.


Challenges

Challenge Description

In this challenge you will learn about the Caesar cipher! The Caesar cipher is one of the simplest and most well-known encryption techniques. It is a type of substitution cipher where each letter in the plaintext is shifted a certain number of places down or up the alphabet. Named after Julius Caesar, who reportedly used it to communicate with his generals, the cipher is easy to understand and implement.

How It Works:

Shift Value: The key to the Caesar cipher is the shift value, which determines how many places each letter is moved. For example, with a shift of 3:

  • A (1) becomes D (4)
  • B (2) becomes E (5)
  • Z (26) wraps around and becomes C (3)
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Encryption: To encrypt a message, each letter is replaced by the letter that is a fixed number of positions away in the alphabet. For example, the word "HELLO" with a shift of 3 becomes "KHOOR".

Decryption: To decrypt the message, the process is reversed by shifting the letters back by the same number of positions.

It is important to note that while the Caesar cipher is easy to use, it is not secure by modern standards. It can be easily broken with techniques such as frequency analysis, where common letters and patterns in the ciphertext are analyzed to reveal the original message. As a result, the Caesar cipher is primarily of historical interest and is often used for educational purposes to introduce concepts of encryption and cryptography.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encrypt a secret word and get the flag!

Challenge Description

This challenge will require you to decrypt a word! Imagine if you were an enemy soldier and intercepted a secret message from Julius Caesar - you must learn how to decrypt it!

How It Works:

Shift Value: Just like with encrypting, the shift value determines how many places each letter has been moved. This time, to decrypt a message, instead of adding, we need to subtract the shift amount. For example, with a shift of 3:

  • D (4) becomes A (1)
  • E (5) becomes B (2)
  • A (1) wraps around and becomes X (24)
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Decryption: To decrypt the message, shift the letters back.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to decrypt a secret word and get the flag!

Challenge Description

Manual encryption and decryption can be rather tedious. Unlike Julius Caesar, we have modern computers - let's write a script to do the work for us!

How It Works:

This challenge will give you an encoded word and the amount it was shifted by during the encryption process. You will need to decrypt it. The secret word will be fairly long, so a script will come in handy!

You can use any programming or scripting language to make your own Caesar cipher verifyr. Here is the algorithm:

  • Get the secret word (ciphertext)
  • Get the shift amount
  • For each character in the ciphertext:
    • Convert the character to a number
    • Subtract the original shift amount
      • Because a letter may need to wrap around, consider using mod (%)!
    • Either append or replace each letter you decode
  • Print the resulting plaintext!

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. verify will give you the ciphertext and the shift amount used to encrypt
  4. Write a script to decode your ciphertext
  5. Run verify again and enter the plaintext your script found - and get the flag!

Challenge Description

If you manage to intercept a secret message, you likely won't be given the shift amount with it. In this challenge, you will try to break the encryption on some intercepted ciphertext!

How It Works:

Brute Force: Using brute force to find the shift amount (key) requires you to try decrypting your ciphertext with every possible key. From there, you can look at all of the resulting "plaintexts", and identify the original message. Most keys will result in gibberish - but one key will work!

For these examples, we have 26 possible keys (since the Caesar Cipher wraps around), so brute force doesn't take too long. But note that with other encryption algorithms, brute forcing can take centuries to try all possible combinations.

Frequency Analysis: One way to help minimize the number of keys you need to try is to perform frequency analysis on the ciphertext. In the any language, there are several letters and combinations of letters that are used more frequently than others. For example, in English, the most commonly occuring letters and combinations are E, T, A, O, TH, HE, and IN.
To utilize frequency analysis - find the most common letters in your ciphertext and try replacing them with the common letters above.

Note that frequency analysis works best on long ciphertexts, with more letters that are repeated. There are also many encryption algorithms that are not vulnerable to this type of analysis. In this challenge specifically, frequency analysis will not be overly helpful - but you can always try it!

This challenge will give you only an encoded word. You will need to decrypt it without knowing the shift amount. Try modifying your script from the previous challenge to try every possible key (1-26)!

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. verify will give you the ciphertext
  4. Write a script to brute force and decode your ciphertext
  5. Run verify again and enter the plaintext your script found - and get the flag!

Challenge Description

In this challenge, you will learn about the Substitution Cipher! A substitution cipher is a method of encryption where each letter in the plaintext is replaced by another letter according to a substitution key. This key maps each letter of the alphabet to a unique counterpart, ensuring that no two letters share the same substitution.

Substitution ciphers have been used historically for secret communication and remain a foundational concept in cryptography.

How It Works:

Substitution Key: The key to a substitution cipher is the mapping between the original alphabet and the substituted alphabet. This key can be random or based on a secret word/pattern. For example:

   Original: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  
Substituted: Q  W  E  R  T  Y  U  I  O  P  A  S  D  F  G  H  J  K  L  Z  X  C  V  B  N  M

Each letter in the original alphabet is replaced by its counterpart in the substitution key. For example:

  • A becomes Q
  • B becomes W
  • C becomes E

Encryption: To encrypt a message, replace each letter in the plaintext with the corresponding letter from the substitution key. For instance, using the key above, the word HELLO becomes ITSSG.

Decryption: To decrypt the message, reverse the process by finding the original letter for each substituted letter. For example, ITSSG maps back to HELLO.

While the substitution cipher offers more complexity than the Caesar cipher because the mapping of letters is not limited to a simple shift, it is still not secure by modern standards. It can be broken using frequency analysis, where common letters and patterns in the ciphertext are compared to typical letter frequencies in the language.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encrypt a secret word and get the flag!

Challenge Description

This challenge will require you to decrypt a word!

How It Works:

Substitution Key: Just like with encrypting, the substitution key is used to map the original alphabet and the substituted alphabet. This time, to decrypt a message, we find the substituted letter on the bottom row, and replace it with the original letter that is directly above it. For example:

   Original: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  
Substituted: Q  W  E  R  T  Y  U  I  O  P  A  S  D  F  G  H  J  K  L  Z  X  C  V  B  N  M
  • Q becomes A
  • P becomes J
  • M becomes Z

Decryption: To decrypt the message, replace the substituted letters with the original letters.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to decrypt a secret word and get the flag!

Challenge Description

In this challenge, you will learn about ASCII Encoding! ASCII (American Standard Code for Information Interchange) is a character encoding standard that represents text using numerical values. Each character corresponds to a unique number, which computers use to store and process text.
The ASCII Table below displays the numerical values for the uppercase and lowercase alphabets. The ASCII table is used in most programming languages, and is how characters are stored numerically in memory.

How It Works:

Each character in text has a specific ASCII value, typically represented in decimal or hexadecimal form. Most humans are familiar with the decimal format - it's just normal numbers!

ASCII Table:

A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

a  b  c  d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

For example, to encode the word "HELLO", we find the numerical value for each letter:

  • H → ASCII 72
  • E → ASCII 69
  • L → ASCII 76
  • L → ASCII 76
  • O → ASCII 79

So, "HELLO" in ASCII is:
72 69 76 76 79

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encrypt a secret word and get the flag!

Challenge Description

In this challenge, you will decode a word using the ASCII table!

ASCII Table:

A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

a  b  c  d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

For example, to decode the ASCII values 87 79 82 76 68, we find the numbers in the ASCII table and replace them with the correct character:

  • 87 → W
  • 79 → O
  • 82 → R
  • 76 → L
  • 68 → D

So, the decoded message is: WORLD

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions to decode a secret message and get the flag!

Challenge Description

In this challenge, you will learn about Hexadecimal Encoding! Hexadecimal is a different way to represent numbers. Our typical way of representing numbers is called base-10. This uses the numbers 0-9, which is ten digits in total. Hexadecimal uses 0-f, which is 16 digits in total. It goes 0-9, and then a-f. To represent the number 5 in hexadecimal, it would still just be 0x5. To represent the number 11 in hexadecimal, it would be the character 0xb. To represent the number 405 in hexadecimal, it would be 0x195. Notice that with hexadecimal, you put '0x' in front of the number to denote the fact you are using hexadecimal counting. Since, hexadecimal uses characters in it's digits, the hex number 0xdeadbeef is a valid number which equates to our base-10 number 3735928559.

How It Works:

Hexadecimal encoding works the same as ASCII encoding. Each hex number is assocaited with a character.

Hex Table (note the '0x' has been ommited for space):

A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A

a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A

Another way you could encode Hex is by converting the Hex digit, into its base-10 decimal digit, and then use the ascii table found in the ascii challenge.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encode a secret word in Base64 and get the flag!

Challenge Description

In this challenge, you will decode a word using the Hexadecimal Table!

Hexadecimal Table:

Hex Table (note the '0x' has been ommited for space):

A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A

a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encode a secret word in Base64 and get the flag!

Challenge Description

In this challenge, you will learn about Binary Encoding! Binary encoding is how computers store and process data at the lowest level—using only 0s and 1s. Each character in text is stored in memory as a byte (8 bits), which represents the ASCII value of the character in binary.

How It Works:

Each character has an ASCII decimal value, and that value is then converted to an 8-bit binary number.

For example, the ASCII value of A is 65, which becomes 01000001 in binary.

Binary Table for uppercase letters:

Char: A        B        C        D        E        F        G        H        I
Dec : 65       66       67       68       69       70       71       72       73
Bin : 01000001 01000010 01000011 01000100 01000101 01000110 01000111 01001000 01001001

Char: J        K        L        M        N        O        P        Q        R
Dec : 74       75       76       77       78       79       80       81       82
Bin : 01001010 01001011 01001100 01001101 01001110 01001111 01010000 01010001 01010010

Char: S        T        U        V        W        X        Y        Z
Dec : 83       84       85       86       87       88       89       90
Bin : 01010011 01010100 01010101 01010110 01010111 01011000 01011001 01011010

For example, to encode the word HELLO:

  • H → ASCII 72 → Binary 01001000
  • E → ASCII 69 → Binary 01000101
  • L → ASCII 76 → Binary 01001100
  • L → ASCII 76 → Binary 01001100
  • O → ASCII 79 → Binary 01001111

So, "HELLO" in binary is: 01001000 01000101 01001100 01001100 01001111

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encode a secret word in binary and get the flag!

Challenge Description

In this challenge, you will decode a word using binary ASCII encoding!

How It Works:

Binary ASCII Table:

Char: A        B        C        D        E        F        G        H        I
Dec : 65       66       67       68       69       70       71       72       73
Bin : 01000001 01000010 01000011 01000100 01000101 01000110 01000111 01001000 01001001

Char: J        K        L        M        N        O        P        Q        R
Dec : 74       75       76       77       78       79       80       81       82
Bin : 01001010 01001011 01001100 01001101 01001110 01001111 01010000 01010001 01010010

Char: S        T        U        V        W        X        Y        Z
Dec : 83       84       85       86       87       88       89       90
Bin : 01010011 01010100 01010101 01010110 01010111 01011000 01011001 01011010

For example, to decode the binary values: 01010111 01001111 01010010 01001100 01000100 we find the binary in the table and replace them with the correct character:

  • 01010111 → W
  • 01001111 → O
  • 01010010 → R
  • 01001100 → L
  • 01000100 → D

So, the decoded message is: WORLD

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions to decode a secret binary message and get the flag!

Morse Code - Encoding

In this challenge, you will learn about Morse Code Encoding! Morse code is a method used in telecommunication to encode text characters as sequences of two different signal durations, called dots (.) and dashes (-). Each letter in the alphabet has a unique combination of dots and dashes, making it a simple yet effective way to transmit messages.

How It Works:

Each letter in the alphabet is represented by a specific sequence of dots and dashes. The Morse Code Table below shows the encoding for each uppercase letter.

Morse Code Table:

A .-    B -...  C -.-.  D -..   E .     F ..-.  G --.   H ....  I ..    J .---
K -.-   L .-..  M --    N -.    O ---   P .--.  Q --.-  R .-.   S ...   T -
U ..-   V ...-  W .--   X -..-  Y -.--  Z --..

For example, to encode the word "HELLO", we find the Morse code for each letter:

H → ....
E → .
L → .-..
L → .-..
O → ---

So, "HELLO" in Morse code is:

.... . .-.. .-.. ---

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encode a secret word in Morse code and get the flag!

Morse Code - Decoding

In this challenge, you will take a secret word that has been encoded using Morse code and decode it. The Morse Code Table is displayed below for you to reference in this challenge.

Morse Code Table:

A .-    B -...  C -.-.  D -..   E .     F ..-.  G --.   H ....  I ..    J .---
K -.-   L .-..  M --    N -.    O ---   P .--.  Q --.-  R .-.   S ...   T -
U ..-   V ...-  W .--   X -..-  Y -.--  Z --..

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to decode the Morse code to see the secret word and get the flag!

Challenge Description

In this challenge, you will learn about Base64 Encoding! Base64 is a group of binary-to-text encoding schemes that transforms binary data into a sequence of printable characters, limited to a set of 64 unique characters. More specifically, the source binary data is taken 6 bits at a time, then this group of 6 bits is mapped to one of 64 unique characters.

How It Works:

Encoding in Base64 is a multi-step process that also involves getting the ascii decimal number for a character, converting that decimal number into binary, and then using a Base64 table to find the character you need. I will walk through these steps in more detail using the word "FORK" which contains all capital letters.

1. Convert Each Character to their Ascii Number (Base 10)

If you did the ascii cryptography challenge, this should be familiar to you. We want to get the ascii number associated with each letter in the word "FORK". That gets us the following numbers:

F = 70
O = 79
R = 82
K = 75

2. Convert Those Ascii Numbers to Binary (8-bits)

There are many websites that can convert decimal (base 10) numbers to binary (base 2). You can google "70 in binary" and google will display the results for you. They may give it to you in 7-bits. Which means we need to just add a 0 to the start to make it a total of 8 bits. Converting all of our ascii numbers from the previous steps gives us these binary numbers:

70 = 01000110
79 = 01001111
82 = 01010010
75 = 01001011

3. Combine Those Binary Numbers

In this step, we want to take our binary numbers from the previous step, and put them into ONE continuous string of numbers. Since each character from the original word "FORK" consists of 8-bits, the total length of this string will be 32-bits.

01000110010011110101001001001011

4. Split Into 6-Bit Chunks

Now that we have our long string consisting of 0's and 1's, we want to split them into 6-Bit chunks, as opposed to the original 8-Bit chunks they were in. This will look something like this:

010001
100100
111101
010010
010010
11

Notice that we have two extra Bits at the end. In this case, we need to pad it out to fit 6-Bits. To do that, we can just add 0's AFTER the two bits that are already there. This should give us something like this:

010001
100100
111101
010010
010010
110000

5. Convert The 6-Bit Binary

The Base64 6-Bit conversion chart can be found here. Now, all you have to do is match the 6-Bit binary string to the appropriate character.

In this case, these 6-Bit binary numbers come out to:

010001 = 'R'
100100 = 'k'
111101 = '9'
010010 = 'S'
010010 = 'S'
110000 = 'w'

HOWEVER, remember that we padded '11' with 4 0's in the last step. If we just give someone the string 'Rk9SSw' it won't decode properly because it doesn't account for the padding that we added. To let someone know that we padded our initial data, we need to add an equal sign ('=') for every two zeroes we added. Since we padded our original data with 4 0's, we will add TWO equal signs.

So, "FORK" in base64 comes out to be: Rk9SSw==

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encode a secret word in Base64 and get the flag!

Challenge Description

In this challenge, you will learn about Base64 decoding! As with many other forms of cipher or encoding, to decode, just perform the steps in reverse!

How It Works:

We will start with a base64 encoded string of Q1VQ.

1. Convert Characters to 6-Bit

Using the table linked to in the previous challenge, find the 6-Bit binary string for each character.

For this Base64 encoded string we get the following 6-Bit binary numbers:

Q = 010000
1 = 110101
V = 010101
Q = 010000

2. Combine Those Binary Numbers

Now, we are to combine these binary numbers into one continuous string of characters, as follows:

3. Split Into 8-Bit Chunks

Now, instead of collecting them into 6-Bits, we will collect them into 8-Bits:

01000011
01010101
01010000

4. Convert Those Binary Numbers

We now take those three 8-Bit binary numbers, and convert them into three decimal (base 10) numbers. You can use google to do this for you if needed. The numbers we get should be:

01000011 = 67
01010101 = 85
01010000 = 80

5. Convert The Decimal Numbers

Now, using those three ascii numbers, find the character they correspond to in the ascii chart! Then you should get your word!

67 = C
85 = U
80 = P

So, decoding Q1VQ we get the word CUP in all caps!

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encode a secret word in Base64 and get the flag!

Challenge Description

In this challenge you will learn about the Playfair cipher! The Playfair cipher is a manual symmetric encryption technique. It was invented by a man named Charles Wheatstone in 1854, but is named after Lord Playfair, because he promoted its use.

How It Works:

The Playfair cipher uses a 5x5 box, where each box contains a letter of the alphabet. Since there are 26 letters in the alphabet, the letter "J" is dropped, and "I" is used to represent both itself, and a "J". You will also choose a passphrase, and this special passphrase will take up the first few boxes, and then the rest will be filled in with the remaining alphabet, in order.

Here is an example of what that 5x5 box would looke like with the passphrase: PLYFAIR

|P|L|Y|F|A|
|I|R|B|C|D|
|E|G|H|K|M|
|N|O|Q|S|T|
|U|V|W|X|Z|

NOTE: There is a keyword PLYFAIR that is used in the box. 

Using this box, I will walk through encrypting the word: HELLO.

First, divide the word you wish to encrypt into pairs of two characters. There are two cases we must look out for, though.

  1. If our word has a double letter that would be paired together, you have to split them up and add a junk character in to finish the pair. (HALL would be split into HA, LX, LX)
  2. If our word has an uneven amount of numbers, then the last pair will automatically get a "Z" to finish the pair. (BYE would be split into BY, EZ)

Following these guidlines, our word HELLO should be split like this: HE, LX, LO.

Second, we now utilize our 5x5 box to create a ciphered text. We will take each pair from the previous step, and identify where they exist on the grid. Based on their position we will do either 1 of 3 things:

  1. If they are located in the same column, then each character will become the character that is under it. If the character is at the bottom, then you wrap around to the top. For example, if you were locating the character pair AT in the grid above, you will notice they are in the same column. This means that "A" would become "D", and "T" would become "Z". So, AT becomes DZ.

  2. If they are located in the same row, then each character will become the character that is to the right of it. If your character is all the way right, then wrap around to the left side. For example, if you were locating the character pair EM in the grid above, you will notice they are in the same row. This means that "E" would become "G", and "M" would wrap around and become "E". So, EM becomes GE.

  3. If they are NOT in the same row, and NOT in the same column, then you will make a rectangle with the squares. For example, if you were locating the character pair WI then to make a rectangle, the characters B and U will be selected. Then, the original characters become the added character that shares a row with it. So, "W" will become "U", and "I" will become "B".

Putting these principles together, let's encrypt HELLO.

HE will become KG
LX will become FV
LO will become RV

So, HELLO becomes KGFVRV

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encrypt a secret word and get the flag!

Challenge Description

In this challenge you will learn about decoding a Playfair cipher.

How It Works:

To decode the playfair cipher, you need to have the passphrase that was used to encode it so that you can recreate the 5x5 grid. Then, from there, you will take your encoded word, split it up into two-character pairs, and then go through and do the reverse of the steps mentioned in the encoding challenge.

|P|L|Y|F|A|
|I|R|B|C|D|
|E|G|H|K|M|
|N|O|Q|S|T|
|U|V|W|X|Z|

NOTE: There is a keyword PLYFAIR that is used in the box. 

For example, decoding the ciphertext KGFVRV would look something like this:

  • KG -> HE (Notice, we go to the character on the left, instead of the right when decoding.)
  • FV -> LX (This case functions the same as encoding.)
  • RV -> LO (Notice, we go to the character above instead of below when decoding.)

This gives us the unciphered text HELXLO. The extra character X is added as a pad during encoding, so the true text is HELLO.

So, KGFVRV becomes HELLO!

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encrypt a secret word and get the flag!

Challenge Description

In this challenge, you will learn about Polybius Square Encoding! The Polybius Square is a simple substitution cipher that uses a 5x5 grid to encode letters by mapping each one to a pair of numbers based on its row and column position. Traditionally used for secure communication, it’s an engaging way to transform text into numerical codes.

How It Works:

The Polybius Square is a 5x5 grid containing the letters of the alphabet (with I and J typically sharing a cell due to the 25-cell limit). Each letter is represented by two numbers: the first for its row and the second for its column.

Polybius Square Table:

   1  2  3  4  5
1  A  B  C  D  E
2  F  G  H I/J K
3  L  M  N  O  P
4  Q  R  S  T  U
5  V  W  X  Y  Z

For example, to encode the word "HELLO":

  • H (row 2, column 3) → 23
  • E (row 1, column 5) → 15
  • L (row 3, column 1) → 31
  • L (row 3, column 1) → 31
  • O (row 3, column 4) → 34

So, "HELLO" in Polybius Square encoding is: 23 15 31 31 34

Note: Since I and J share the same cell (2,4), they both encode to 24. During decoding, context or convention (e.g., assuming J if rare) may be used to disambiguate.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encode a secret word using the Polybius Square and get the flag!

Challenge Description

In this challenge, you will decode a word using the Polybius Square! As a reminder, the Polybius Square is a 5x5 grid that maps each letter to a pair of numbers based on its row and column position. Your task is to take a sequence of number pairs and convert them back to the original letters to reveal the secret word.

Polybius Square Table:

   1  2  3  4  5
1  A  B  C  D  E
2  F  G  H I/J K
3  L  M  N  O  P
4  Q  R  S  T  U
5  V  W  X  Y  Z

For example, to decode the Polybius values 23 15 31 31 34, we find the corresponding letters in the Polybius Square:

  • 23 → H (row 2, column 3)
  • 15 → E (row 1, column 5)
  • 31 → L (row 3, column 1)
  • 31 → L (row 3, column 1)
  • 34 → O (row 3, column 4)

So, the decoded message is: HELLO

Note: Since I and J share the same cell (24), you may encounter ambiguity. For this challenge, assume the decoded letter is I unless context suggests otherwise.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions to decode a secret Polybius Square message and get the flag!

Challenge Description

In this challenge, you will learn about the Rail Fence (Zigzag) Cipher! The Rail Fence Cipher is a transposition cipher that arranges the plaintext in a zigzag pattern along a specified number of "rails" (rows) before reading it off row by row to create the ciphertext.

How It Works:

The Rail Fence Cipher works by writing the message in a zigzag pattern across a specified number of rails, then reading the message row by row. The key to this cipher is the number of rails used. The number of rails must be at least 2 and less than the length of the plaintext.

For example, let's encode the word "CYBER" using 3 rails:

C . . . R
. Y . E .
. . B . .
  1. First, we write the message in a zigzag pattern:

    • First letter (C) goes on the first rail
    • Second letter (Y) goes on the second rail
    • Third letter (B) goes on the third rail
    • Fourth letter (E) goes back up to the second rail
    • Fifth letter (R) goes back to the first rail
  2. Then, we read the message row by row:

    • First row: C R
    • Second row: Y E
    • Third row: B

So, "CYBER" encoded with 3 rails becomes: CRYEB

The Rail Fence Cipher is a simple transposition cipher that doesn't change the letters themselves, only their positions. While it provides some level of obfuscation, it's not considered secure for modern cryptographic purposes as it can be easily broken through pattern analysis.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to encode a secret word using the Rail Fence Cipher and get the flag!

HINT: It might be useful to open a text file to type out the zigzag pattern and your answer before submitting.

Challenge Description

In this challenge, you will learn about decoding messages using the Rail Fence (Zigzag) Cipher! As a reminder, the Rail Fence Cipher is a transposition cipher that arranges the plaintext in a zigzag pattern along a specified number of "rails" (rows) before reading it off row by row to create the ciphertext. Now, you'll learn how to reverse this process to decode messages.

How It Works:

To decode a Rail Fence Cipher message, we need to reconstruct the zigzag pattern using the number of rails and the ciphertext. The key to this cipher is the number of rails used. The number of rails must be at least 2 and less than the length of the ciphertext.

Determining the Number of Rails:

When you're given a ciphertext without knowing the number of rails, you can try different numbers of rails until you find one that produces a readable message. Here's how to approach it:

  1. Start with 2 rails and work your way up
  2. For each number of rails:
    • Calculate how many letters should be in each row
    • For a message of length L and R rails:
      • First row: L ÷ (2R-2) letters (rounded up)
      • Middle rows: 2 × (L ÷ (2R-2)) letters
      • Last row: L ÷ (2R-2) letters (rounded down)
  3. Try reconstructing the message with these calculations
  4. The correct number of rails will produce a readable message

For example, with a 5-letter message "CRYEB":

  • With 2 rails: First row gets 3 letters, second row gets 2 letters
  • With 3 rails: First row gets 2 letters, second row gets 2 letters, third row gets 1 letter
  • With 4 rails: First row gets 2 letters, middle rows get 1 letter each, last row gets 1 letter

For example, let's decode the ciphertext "CRYEB" using 3 rails:

  1. First, we need to determine the pattern of the zigzag:
C . . . R
. Y . E .
. . B . .
  1. Then, we fill in the letters from the ciphertext in the correct positions:

    • First row: C R
    • Second row: Y E
    • Third row: B
  2. Finally, we read the message by following the zigzag pattern:

    • Start at the top left (C)
    • Move diagonally down to the second row (Y)
    • Move diagonally down to the third row (B)
    • Move diagonally up to the second row (E)
    • Move diagonally up to the first row (R)

So, "CRYEB" decoded with 3 rails becomes: CYBER

The Rail Fence Cipher is a simple transposition cipher that doesn't change the letters themselves, only their positions. While it provides some level of obfuscation, it's not considered secure for modern cryptographic purposes as it can be easily broken through pattern analysis.

Challenge Steps

  1. Start the challenge
  2. Run verify
  3. Follow the instructions given in verify to decode a secret word using the Rail Fence Cipher and get the flag!

HINT: It might be useful to open a text file to draw out the zigzag pattern and your answer before submitting.

Easy Challenge #1

For this challenge, you will be given a string to decode where you do not know which cipher was used to encode it. Feel free to look back at previous examples to know which ciphers to try.

HINT: This string has only been encoded with one cipher. The answer will be recognizable and not just random characters.

Challenge Steps

  1. Start the challenge.
  2. Run verify.
  3. Decode the given string and enter the answer to receive your flag.

Medium Challenge #1

For this challenge, you will be given a string to decode where you do not know which cipher was used to encode it. Feel free to look back at previous examples to know which ciphers to try and to use online converters to help with the conversions.

HINT: The answer will be recognizable and not just random characters.

Challenge Steps

  1. Start the challenge.
  2. Run verify.
  3. Decode the given string and enter the answer to receive your flag.

Hard Challenge #1

For this challenge, you will be given a string to decode where you do not know which ciphers were used to encode it. Feel free to look back at previous examples to know which ciphers to try and to use online converters to help with the conversions.

HINT: The answer will be recognizable and not just random characters. It will also be all uppercase letters.

Challenge Steps

  1. Start the challenge.
  2. Run verify.
  3. Decode the given string and enter the answer to receive your flag.


30-Day Scoreboard:

This scoreboard reflects solves for challenges in this module after the module launched in this dojo.

Rank Hacker Badges Score