当前位置:网站首页>CTF中常见的RSA相关问题总结:基础RSA加密与解密
CTF中常见的RSA相关问题总结:基础RSA加密与解密
2022-07-28 09:17:00 【biyusr】
原文首发自Github,出于学习目的转载至此
原文地址:https://github.com/findneo/RSA-ATTACK
特此声明
准备工具
python
git clone https://github.com/hellman/libnum.git && cd libnum && python setup.py install
Windows:可从https://pypi.org/project/gmpy2/#files 直接下载已编译的安装包。
Linux:
sudo apt install python-gmpy2
gmpy2库
libnum库:
yafu
https://sourceforge.net/projects/yafu/
RSATool2v17.exe
基础RSA加密脚本
from Crypto.Util.number import *
import gmpy2
msg = 'flag is :testflag'
hex_msg=int(msg.encode("hex"),16)
print(hex_msg)
p=getPrime(100)
q=getPrime(100)
n=p*q
e=0x10001
phi=(p-1)*(q-1)
d=gmpy2.invert(e,phi)
print("d=",hex(d))
c=pow(hex_msg,e,n)
print("e=",hex(e))
print("n=",hex(n))
print("c=",hex(c))
rsa原理部分:
https://xz.aliyun.com/t/2446?utm_source=tuicool&utm_medium=referral
基础RSA解密脚本
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import binascii
import gmpy2
n=0x80b32f2ce68da974f25310a23144977d76732fa78fa29fdcbf
#这边我用yafu分解了n
p=780900790334269659443297956843
q=1034526559407993507734818408829
e=0x10001
c=0x534280240c65bb1104ce3000bc8181363806e7173418d15762
phi=(p-1)*(q-1)
d=gmpy2.invert(e,phi)
m=pow(c,d,n)
print(hex(m))
print(binascii.unhexlify(hex(m)[2:].strip("L")))边栏推荐
猜你喜欢

Salted fish esp32 instance - mqtt lit LED

JDBC连接数据库

Oracle creates users with query permission only

Pytorch deep learning practice lesson 9 multi classification problems (handwritten numeral MNIST)

The secret behind three salary increases a year

使用 OpenSSL 创建ssl证书

Pulse style | exclusive interview with Committee -- Tencent engineer Zhang Dawei calls you to eat "crab"

21 day learning challenge - "AUTOSAR from introduction to mastery - practical part"

MySQL中各类型文件详解

Talk to the father of MySQL: code completion at one time is a good programmer
随机推荐
[multithreading] non atomic agreement of long and double
HashSet内部原理解析
Which system table is the keyword of SQL Server in?
CakePHP 4.4.3 release, PHP rapid development framework
go语言切片Slice和数组Array对比panic runtime error index out of range问题解决
Network engineering -- ranking of Chinese universities in Soft Science
MySQL master-slave architecture. After the master database is suspended and restarted, how can the slave database automatically connect to the master database
2.9.5 Ext JS的Object类型处理及便捷方法
matlab基本操作
Scalable search bar, imitating Huawei application market
数据库高级学习笔记--系统包
【AUTOSAR-RTE】-2-Composition,Component和VFB的介绍
Personal blog applet
ECCV 2022 | can be promoted without fine adjustment! Registration based anomaly detection framework for small samples
SQL Server、MySQL主从搭建,EF Core读写分离代码实现
Introduction to shardingsphere (I)
MATLAB的符号运算
3分钟带你了解微信小程序开发
Activiti startup error: cannot create poolableconnectionfactory (could not create connection to database server
pycharm使用conda调用远程服务器