Description: We found this weird message being passed around on the servers, we think we have a working decryption scheme. Download the message here. Take each number mod 37 and map it to the following character set: 0-25 is the alphabet (uppercase), 26-35 are the decimal digits, and 36 is an underscore. Wrap your decrypted message in the picoCTF flag format (i.e. picoCTF{decrypted_message})
Difficulty: Medium
Author: Will Hong
Summary
This challenge introduces the concept of modulo (mod) arithmetic, a fundamental concept in cryptography.
It can be solved either manually or using a simple Python script.
Analysis
So we got a file messgae.txt:
$ file message.txtmessage.txt: ASCII text, with no line terminatorsIts content is:
350 63 353 198 114 369 346 184 202 322 94 235 114 110 185 188 225 212 366 374 261 213What is modulo?
Modulo is a mathematical operation that finds the remainder when one number is divided by another. For example:
10 mod 3 = 1 (because 10 Γ· 3 = 3 remainder 1)350 mod 37 = 17In cryptography, modulo is often used to wrap numbers into a fixed range, such as mapping numbers to letters or digits.
Challenge
According to the challenge instructions:
- Take each number mod 37
- Map the result to a character using this mapping:
0β25 β AβZ26β35 β 0β936 β _
- Combine the decoded characters.
- Wrap the result in the format:
picoCTF{decrypted_message}
Decryption
We calculate each number modulo 37 and map it to the corresponding character:
| Number | Calculation | mod 37 | Character |
|---|---|---|---|
| 350 | 350 β (37Γ9 = 333) | 17 | R |
| 63 | 63 β (37Γ1 = 37) | 26 | 0 |
| 353 | 353 β (37Γ9 = 333) | 20 | U |
| 198 | 198 β (37Γ5 = 185) | 13 | N |
| 114 | 114 β (37Γ3 = 111) | 3 | D |
| 369 | 369 β (37Γ9 = 333) | 36 | _ |
| 346 | 346 β (37Γ9 = 333) | 13 | N |
| 184 | 184 β (37Γ4 = 148) | 36 | _ |
| 202 | 202 β (37Γ5 = 185) | 17 | R |
| 322 | 322 β (37Γ8 = 296) | 26 | 0 |
| 94 | 94 β (37Γ2 = 74) | 20 | U |
| 235 | 235 β (37Γ6 = 222) | 13 | N |
| 114 | 114 β (37Γ3 = 111) | 3 | D |
| 110 | 110 β (37Γ2 = 74) | 36 | _ |
| 185 | 185 β (37Γ5 = 185) | 0 | A |
| 188 | 188 β (37Γ5 = 185) | 3 | D |
| 225 | 225 β (37Γ6 = 222) | 3 | D |
| 212 | 212 β (37Γ5 = 185) | 27 | 1 |
| 366 | 366 β (37Γ9 = 333) | 33 | 7 |
| 374 | 374 β (37Γ10 = 370) | 4 | E |
| 261 | 261 β (37Γ7 = 259) | 2 | C |
| 213 | 213 β (37Γ5 = 185) | 28 | 2 |
Decrypted Message
Putting it together:
R0UND_N_R0UND_ADD17EC2Similar can be done with Python:
numbers = [350, 63, 353, 198, 114, 369, 346, 184, 202, 322, 94, 235, 114, 110, 185, 188, 225, 212, 366, 374, 261, 213]
def decode(n): r = n % 37 if 0 <= r <= 25: return chr(ord('A') + r) elif 26 <= r <= 35: return chr(ord('0') + (r - 26)) else: return "_"
flag = "".join(decode(n) for n in numbers)print("picoCTF{" + flag + "}")β‘ Raikiriπ Flag pwned!
Wrapped in picoCTF flag format:
picoCTF{R0UND_N_R0UND_ADD17EC2}π‘ TL;DR / Lesson LearnedThis challenge demonstrates how the
modulooperation can be used in cryptography to map numbers to a fixed set of symbols, such as letters, digits, or special characters.