Tags: crypto 

Rating:

Script to solve the challenge

```
#!/usr/bin/python3
import math

#function to find prime factors
def prime_factors(n):
i = 2
factors = []
while i * i <= n:
if n % i:
i += 1
else:
n //= i
factors.append(i)
if n > 1:
factors.append(n)
return factors

def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (b // a) * y, y)

#function to calculate inverse module
def modinv(a, m):
g, x, y = egcd(a, m)
if g != 1:
raise Exception('modular inverse does not exist')
else:
return x % m

#function to calculate plaintext
def rsadecrypt(x, d, n):
ch = pow(x, d, n)
return ch

def main():
n = 960242069
e = 347
ct = [346046109,295161774,616062960,790750242,259677897,945606673,321883599,625021022,731220302,556994500,118512782,843462311,321883599,202294479,725148418,725148418,636253020,70699533,475241234,530533280,860892522,530533280,657690757,110489031,271790171,221180981,221180981,278854535,202294479,231979042,725148418,787183046,346046109,657690757,530533280,770057231,271790171,584652061,405302860,137112544,137112544,851931432,118512782,683778547,616062960,508395428,271790171,185391473,923405109,227720616,563542899,770121847,185391473,546341739,851931432,657690757,851931432,284629213,289862692,788320338,770057231,770121847]
p, q = prime_factors(n)

phi = (p - 1) * (q - 1)
d = modinv(e, phi)

for c in ct:
pc = rsadecrypt(c, d, n)
print(chr(pc), end='')
print('')

if __name__ == "__main__":
main()
```

The output of this script is a Vigenere encryption with a key

```
xhBQCUIcbPf7IN88AT9FDFsqEOOjNM8uxsFrEJZRRifKB1E=|key=visionary
```

Once decrypted with the key we get: ```czJIOHIldUx7QF88MG9FMHxiMGAwNV8wckNjQWZATnxST1Q=```

We decrypt the base64:

```
$ echo -ne 'czJIOHIldUx7QF88MG9FMHxiMGAwNV8wckNjQWZATnxST1Q=' | base64 -d
s2H8r%uL{@_<0oE0|b0`05_0rCcAf@N|ROT
```
And finally we get a ROT47 text and decoding we get the flag

```
DawgCTF{Lo0k_@t_M3_1_d0_Cr4p7o}
```