434 words
2 minutes
πŸ” PicoGym - basic-mod1

πŸ“‚ Download challenge file.

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:

Terminal window
$ file message.txt
message.txt: ASCII text, with no line terminators

Its content is:

350 63 353 198 114 369 346 184 202 322 94 235 114 110 185 188 225 212 366 374 261 213

What 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 = 17

In 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:

  1. Take each number mod 37
  2. Map the result to a character using this mapping:
  • 0–25 β†’ A–Z
  • 26–35 β†’ 0–9
  • 36 β†’ _
  1. Combine the decoded characters.
  2. Wrap the result in the format: picoCTF{decrypted_message}

Decryption#

We calculate each number modulo 37 and map it to the corresponding character:

NumberCalculationmod 37Character
350350 βˆ’ (37Γ—9 = 333)17R
6363 βˆ’ (37Γ—1 = 37)260
353353 βˆ’ (37Γ—9 = 333)20U
198198 βˆ’ (37Γ—5 = 185)13N
114114 βˆ’ (37Γ—3 = 111)3D
369369 βˆ’ (37Γ—9 = 333)36_
346346 βˆ’ (37Γ—9 = 333)13N
184184 βˆ’ (37Γ—4 = 148)36_
202202 βˆ’ (37Γ—5 = 185)17R
322322 βˆ’ (37Γ—8 = 296)260
9494 βˆ’ (37Γ—2 = 74)20U
235235 βˆ’ (37Γ—6 = 222)13N
114114 βˆ’ (37Γ—3 = 111)3D
110110 βˆ’ (37Γ—2 = 74)36_
185185 βˆ’ (37Γ—5 = 185)0A
188188 βˆ’ (37Γ—5 = 185)3D
225225 βˆ’ (37Γ—6 = 222)3D
212212 βˆ’ (37Γ—5 = 185)271
366366 βˆ’ (37Γ—9 = 333)337
374374 βˆ’ (37Γ—10 = 370)4E
261261 βˆ’ (37Γ—7 = 259)2C
213213 βˆ’ (37Γ—5 = 185)282

Decrypted Message#

Putting it together:

R0UND_N_R0UND_ADD17EC2

Similar 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 Learned

This challenge demonstrates how the modulo operation can be used in cryptography to map numbers to a fixed set of symbols, such as letters, digits, or special characters.