「配枪朱丽叶。」

RootのCTF学习笔记。

RSA-只有密文

怎么办,已经截获了密文和模数n!能够破解吗?请分解出RSA中的两个大素数q和p。提交格式是key{x}x为两个素数中较小的那个的MD5前8位。
题目下载

他让求的是p和q,200个密文里可能会有和n相同的质数q,
所以大概意思就是让密文分别和N求最大公约数

n = 135176830582884945708175419898330054260341730432046991449072509302750602166218145078102928897914789996197402658592881347572949256377161172079344803330624352445165759925647345536051853372740246104804540179716136644319380454884518397455488002758429914465640804944658049262500561494830899678619427468784748988379


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

print(gcd(10,5))
x = open('ciphertext.txt')
for line in x.readlines():
    if 'Ciphertext' in line:
        continue
    if len(line)>2:
        print(gcd(n,int(line[:-1])))

运行后得到其中一个为:

13038371855775914836995578093728166671103633520203033965827703187246607207039273968425501296569317295959057439253867586769212037981452712871242668046329877

再用N除以它,得到另一个:

10367615840240242845371941453623373821227053765532752994306127876946421006862147600725324340607889088707606730457021312059130583835286311559997627141422127

最后flag为key{f49d7fe6}