Tags: modulus 

Rating:

```py
#!/usr/bin/python3
import random
from Crypto.Util.number import *
flag = open('flag.txt').read()
alpha = 'abcdefghijklmnopqrstuvwxyz'.upper()
to_guess = ''
for i in range(16):
to_guess += random.choice(alpha)
for i in range(len(to_guess)):
for j in range(3):
inp = int(input(f'Guessing letter {i}, Enter Guess: '))
guess = inp << 16
print(guess % ord(to_guess[i]))
last_guess = input('Enter Guess: ')
if last_guess == to_guess:
print(flag)
else:
print('Incorrect! Bye!')
exit()
```

I tried to find a modulus number where for each character the output was unique. Then use that modulus and decrypt the flag.

```py
alpha = 'abcdefghijklmnopqrstuvwxyz'.upper()

for q in range(1,1000000):
c = []
for i in range(26):
c.append((q<<16) % ord(alpha[i]))
b = 0
for a in c:
s = 0
for d in c:
if a == d:
s += 1
if s > 1:
b = 1
break

if not b:
break

# print(q)
# print(c)

from pwn import *

context.log_level = 'error'
r = remote("challs.n00bzunit3d.xyz", 51081)

f = ""
for i in range(16):
r.recv()
r.sendline(bytes(str(q),'utf-8'))
f += alpha[c.index(int(r.recvline().decode()))]
for i in range(2):
r.recv()
r.sendline(bytes(str(q),'utf-8'))

r.recv()
r.sendline(bytes(f,"utf-8"))
print(r.recv().decode('utf-8').strip())
```

Flag: `n00bz{M0dul0_f7w_1a4d3f5c!}`

Original writeup (https://jp-ch.gq/cryptography/n00bzCTF-2023.html#maas).