← ../

# Basic-Mod1

[Cryptography]

We found this weird message being passed around on the servers, we think we have a working decryption scheme.

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})

When you open the file, we are given a set of characters.

91 322 57 124 40 406 272 147 239 285 353 272 77 110 296 262 299 323 255 337 150 102

We are already given the steps to decode these integers. Mod 37, and then the definition of each integer. Lets make a script.

enc = "91 322 57 124 40 406 272 147 239 285 353 272 77 110 296 262 299 323 255 337 150 102".split(" ") # Add each integer into an array
enc = [int(x) for x in enc] # Convert the array into a integer type
print(enc) # Sanity test
m = ""
import string
for i in enc:
for x, y in zip(range(0, 26), string.ascii_uppercase): # Loop through all uppercase ascii
#print(x, y)
z = i % 37 # Mod 37
if z == x: # If the uppercase ascii id is equal to the integer, then add to the final string
m += str(y)
if z > 25: # If larger, then make into ascii integer values and add to final string
w = z + 22
m += chr(w)
break

print("picoCTF{" + m.replace(":", "_") + "}") # Print in picoCTF format

# 17 26 20 13 3 36 13 36 17 26 20 13 3 36 0 3 3 27 33 4 2 28
# picoCTF{R0UND_N_R0UND_ADD17EC2}

In the competition, we got our final string.

# Basic-Mod2

A new modular challenge!

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})

Same things.

enc = "104 290 356 313 262 337 354 229 146 297 118 373 221 359 338 321 288 79 214 277 131 190 377".split(" ") # Add each integer into an array
enc = [int(x) for x in enc] # Convert the array into a integer type
print(enc) # Sanity test
m = ""
import string
for i in enc:
for x, y in zip(range(1, 27), string.ascii_uppercase): # Loop through all uppercase ascii
#print(x, y)
z = i % 41 # Mod 37
if z == x: # If the uppercase ascii id is equal to the integer, then add to the final string
m += str(y)
if z > 26: # If larger, then make into ascii integer values and add to final string
w = z + 21
m += chr(w)
break

print("picoCTF{" + m + "}") # Print in picoCTF format

# picoCTF{1nv3r53ly_h4rd_8a05d939}

This is the flag.

picoCTF{1nv3r53ly_h4rd_8a05d939}

Published April 12, 2022, by ZyphenSVC.

If you enjoyed the post, consider sharing it!

Tweet