little RSA

点击此处获得更好的阅读体验


WriteUp来源

https://dunsp4rce.github.io/csictf-2020/crypto/2020/07/21/little-RSA.html

by anishbadhri

题目描述

The flag.zip contains the flag I am looking for but it is password protected. The password is the encrypted message which has to be correctly decrypted so I can useit to open the zip file. I tried using RSA but the zip doesn’t open by it. Can you help me get the flag please?

Files:

题目考点

  • RSA n分解

解题思路

The file a.txt has a really small value of n. The factors of this value can be brute-forced for directly and then an integer is obtained. The only file in flag.zip is flag.txt which is password-protected. The password to this file is the integer which is obtained.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import mod

c=32949
n=64741
e=42667

p = None
for i in range(2,n):
if n % i == 0:
p = i
break

q = n // p
em = mod.Mod(e, (p-1) * (q-1))
d = int(1//em)
cm = mod.Mod(c,n)
ans = int(cm ** d)
print(ans)

Flag

1
csictf{gr34t_m1nds_th1nk_4l1ke}