\> PicoCTF 2022 Writeups

This website contains Jackwin Hui's writeups for the 2022 PicoCTF competition.

PicoCTF2022 - basic-mod2

Description

A new modular challenge! Download the message here. Take each number mod 41 and find the modular inverse for the result. Then map to the following character set: 1-26 are the alphabet, 27-36 are the decimal digits, and 37 is an underscore. Wrap your decrypted message in the picoCTF flag format (i.e. picoCTF{decrypted_message})

Information

Point Value: 100 points

Category: Cryptography

Hints

  1. Do you know what the modular inverse is?
  2. The inverse modulo z of x is the number, y that when multiplied by x is 1 modulo z
  3. It's recommended to use a tool to find the modular inverses

Solution

Looking at the txt file, we see that it consists of a line of multiple numbers. Similar to basic-mod1, we can create a simple Python program that translates the given instructions into code. Running the following Python program gives us the flag. charString = " abcdefghijklmnopqrstuvwxyz0123456789_"

with open('basicMod2.txt') as f:
    lines = f.readline()

nums = lines.split()

flag = ""
for x in nums:
    flag += charString[pow(int(x) % 41, -1, 41)]

print("picoCTF{"+flag+"}")

Flag

picoCTF{1nv3r53ly_h4rd_c680bdc1}