台州学院 2023 Baby RSA

下载附件,得到如下内容

p+q : 0x1232fecb92adead91613e7d9ae5e36fe6bb765317d6ed38ad890b4073539a6231a6620584cea5730b5af83a3e80cf30141282c97be4400e33307573af6b25e2ea
(p+1)(q+1) : 0x5248becef1d925d45705a7302700d6a0ffe5877fddf9451a9c1181c4d82365806085fd86fbaab08b6fc66a967b2566d743c626547203b34ea3fdb1bc06dd3bb765fd8b919e3bd2cb15bc175c9498f9d9a0e216c2dde64d81255fa4c05a1ee619fc1fc505285a239e7bc655ec6605d9693078b800ee80931a7a0c84f33c851740
e : 0xe6b1bee47bd63f615c7d0a43c529d219
d : 0x2dde7fbaed477f6d62838d55b0d0964868cf6efb2c282a5f13e6008ce7317a24cb57aec49ef0d738919f47cdcd9677cd52ac2293ec5938aa198f962678b5cd0da344453f521a69b2ac03647cdd8339f4e38cec452d54e60698833d67f9315c02ddaa4c79ebaa902c605d7bda32ce970541b2d9a17d62b52df813b2fb0c5ab1a5
enc_flag : 0xca3df19844c617ad8a41f88f8ea554eb993a4a61255bc46adfeabe205c2a2049a06816bc2cf46d61f193dee5c25958c7961029a9fafd9cd81cff5dfa51518f55b59e900c594287e6c48727660ce768ad7637d5f43dbd909bc53e07eb6a8f1acffcb3bb98bf1ce0af78dc9c5a04bb940cb91a2740d180f03ffa8e5a9b953ffc9

编写解密脚本

from Crypto.Util.number import *

#p+q
s = 0x1232fecb92adead91613e7d9ae5e36fe6bb765317d6ed38ad890b4073539a6231a6620584cea5730b5af83a3e80cf30141282c97be4400e33307573af6b25e2ea
#(p+1)(q+1)
k = 0x5248becef1d925d45705a7302700d6a0ffe5877fddf9451a9c1181c4d82365806085fd86fbaab08b6fc66a967b2566d743c626547203b34ea3fdb1bc06dd3bb765fd8b919e3bd2cb15bc175c9498f9d9a0e216c2dde64d81255fa4c05a1ee619fc1fc505285a239e7bc655ec6605d9693078b800ee80931a7a0c84f33c851740
e = 0xe6b1bee47bd63f615c7d0a43c529d219
d = 0x2dde7fbaed477f6d62838d55b0d0964868cf6efb2c282a5f13e6008ce7317a24cb57aec49ef0d738919f47cdcd9677cd52ac2293ec5938aa198f962678b5cd0da344453f521a69b2ac03647cdd8339f4e38cec452d54e60698833d67f9315c02ddaa4c79ebaa902c605d7bda32ce970541b2d9a17d62b52df813b2fb0c5ab1a5
enc_flag = 0xca3df19844c617ad8a41f88f8ea554eb993a4a61255bc46adfeabe205c2a2049a06816bc2cf46d61f193dee5c25958c7961029a9fafd9cd81cff5dfa51518f55b59e900c594287e6c48727660ce768ad7637d5f43dbd909bc53e07eb6a8f1acffcb3bb98bf1ce0af78dc9c5a04bb940cb91a2740d180f03ffa8e5a9b953ffc9

n=k-s-1
print(
long_to_bytes(
pow(enc_flag, d, n)
)
)