简单的RSA题目

今天做了一道简单的RSA可惜不会写脚本,脚本还是看的WP大佬的~~~

  • 看到公钥直接丢到openssl里 openssl>>   然后输入如下命  rsa -pubin -text -modulus -in warmup -in 公钥文件名.key 

然后结果应该如下图

这样就把 e 和 n 解出来了 (不过n解出来的是十六进制,需要先换算为十进制)

用python

n=98432079271513130981267919056149161631892822707167177858831841699521774310891           (记得把后面的L去掉)

在使用大质数分解网站分解n         网站地址:http://factordb.com/index.php

  • 到这里RSA的参数已经齐全了 

    p = 302825536744096741518546212761194311477

    q = 325045504186436346209877301320131277983

    n = 98432079271513130981267919056149161631892822707167177858831841699521774310891
    e = 65537

  • 使用python脚本得到flag   (附py脚本)
import gmpy2
import rsa
p = 302825536744096741518546212761194311477
q = 325045504186436346209877301320131277983
n = 98432079271513130981267919056149161631892822707167177858831841699521774310891
e = 65537
d = int(gmpy2.invert(e , (p-1) * (q-1)))
privatekey = rsa.PrivateKey(n , e , d , p , q)              #根据已知参数,计算私钥
with open("encrypted.message1" , "rb") as f:
    print(rsa.decrypt(f.read(), privatekey).decode())       #使用私钥对密文进行解密,并打印
with open("encrypted.message2" , "rb") as f:
    print(rsa.decrypt(f.read(), privatekey).decode())       #使用私钥对密文进行解密,并打印
with open("encrypted.message3" , "rb") as f:
    print(rsa.decrypt(f.read(), privatekey).decode())       #使用私钥对密文进行解密,并打印

                                                                                                                                                                                                 脚本来源:https://www.ichunqiu.com/writeup/detail/693

  

猜你喜欢

转载自www.cnblogs.com/threesoil/p/9980209.html
RSA