极客大挑战-三个也可以
三个也可以
密码学题目
题目给定文件如下:
# 解压后只有一个py文件
from Crypto.Util.number import getPrime,bytes_to_long
# from flag import FLAG
flag = bytes_to_long(flag)
p = getPrime(100)
q = getPrime(100)
r = getPrime(100)
n = p*q*r
e = 65537
c = pow(flag, e, n) # flag**e %n == c
print(n)
print(c)
'''
798898099277934230940128318327632478801901355882614385038310680236381399664973004454688807
249128262668727227416761229197781088291962817031744463346178556057415901512114944554308575
'''
非常简单,写个python脚本直接算就可以了(思路来源于网上的师傅)
import gmpy2
p = 821285845529489288911031313917
q = 1005682191548299165290460437397
r = 967244547191154261539598250343
c = 249128262668727227416761229197781088291962817031744463346178556057415901512114944554308575
n = 798898099277934230940128318327632478801901355882614385038310680236381399664973004454688807
e=65537
phin = (p-1)*(q-1)*(r-1)
d=gmpy2.invert(e, phin)
print(d)
m = pow(c,d,n)
print(m)
print(hex(m))
print(bytes.fromhex(hex(m)[2:]))
解答结果如下所示:
40300244384284458664389035512497982223263215867565711201073618351763565714690247279940929
121814240979386959575434948378090701383537735070845
0x5359437b6e6f775f796f755f736f6c76655f69747d
b'SYC{now_you_solve_it}'
因此本题的flag为b'SYC{now_you_solve_it}'
本文来自博客园,作者:sherlson,转载请注明原文链接:https://www.cnblogs.com/sherlson/articles/15593650.html