buu [HDCTF2019]basic rsa
下载得到一个py
类型:n+e+c+p+q= m
注释中就是该脚本生成的c
使用脚本RSA各题型脚本\n+e+c+p+q= m
直接套用脚本
import random
from binascii import a2b_hex,b2a_hex
p = 262248800182277040650192055439906580479
q = 262854994239322828547925595487519915551
n = p * q
def multiplicative_inversr(a,b):x = 0y = 1lx = 1ly = 0oa = aob = bwhile b != 0:q = a // b(a, b) = (b, a % b)(x, lx) = ((lx - (q * x)), x)(y, ly) = ((ly - (q * y)), y)if lx < 0:lx += obif ly < 0:ly += oareturn lx
def gcd(a,b):while b != 0:a, b = b, a % breturn a
def generate_keypair(p,q):n = p * qphi = (p - 1) * (q -1)e = 65533g = gcd(e, phi)while g != 1:e = random.randrange(1, phi)g = gcd(e, phi)d = multiplicative_inversr(e, phi)return ((e,n),(d,n))
def encrypt(pk, plaintext):key, n = pk[0]print(b2a_hex(plaintext.encode()))cipher = pow(int(b2a_hex(plaintext.encode()),16), key , n)return cipher
def decrypt(pk, cipher):key, n = pk[1]cipher = pow(cipher, key ,n)cipher = a2b_hex(hex(cipher).split('0x')[1])return cipher
pk = generate_keypair(p,q)
cipher = 27565231154623519221597938803435789010285480123476977081867877272451638645710
plaintext = decrypt(pk, cipher)
print(plaintext)
运行得到flag 提交即可
解题思路
首先这道题题目是达芬奇密码,百度之后发现这是一部电影,当时也没想的去看一下电影的简介什么的,后面加buuctf关键字,也没有找到相应的wp。果断google,找到大佬的wp,发现在电影简介中会提到——斐波那契数列。
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309
1
对比蒙娜丽莎中的数字列,发现数值一样,但是进行了位移。
之后对比,题目中给到的两个数列的长度都是32,并且flag也是32位,可以推测,神秘数列是通过flag位移后得出的,而位移的规则是斐波那契数列的位移。
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309
1 233 3 2584 1346269 144 5 196418 21 1597 610 377 10946 89 514229 987 8 55 6765 2178309 121393 317811 46368 4181 1 832040 2 28657 75025 34 13 17711
36968853882116725547342176952286
1
2
3
4
5
6
7
规则如下:
第零位1还是1,没有位移。
第一位233是斐波那契数列的第十二位(以0开始算),因此下面神秘数字串的第一位的6是原本flag的第十二位。
第二位3是斐波那契数列的第三位,因此下面神秘数字串的第二位的9是原本flag的第三位。
以此类推…,写出如下脚本。
buu [HDCTF2019]basic rsa相关推荐
- buu [HDCTF2019]bbbbbbrsa
查看题目 #!/usr/bin/env python # -*- coding:utf-8 -*- from base64 import b64encode as b32encode from bas ...
- Buu Crypto
Buu RSA做题记录 RSA 题目 在一次RSA密钥对生成中,假设p=473398607161,q=4511491,e=17 求解出d作为flga提交 解 import gmpy2p = 47339 ...
- BUUCTF——rsa系列(2)
目录 目录 Dangerous RSA [HDCTF2019]basic rsa [GUET-CTF2019]BabyRSA rsa2 RSA5 [NCTF2019]childRSA [HDCTF20 ...
- 2021-06-14
[HDCTF2019]basic rsa 题目 import gmpy2 from Crypto.Util.number import * from binascii import a2b_hex,b ...
- [buuctf] crypto全解——前84道(不建议直接抄flag)
buuctf crypto 1.MD5 2.Url编码 3.一眼就解密 4.看我回旋踢 5.摩丝 6.[BJDCTF 2nd]签到-y1ng 7.password 8.变异凯撒 9.Quoted-pr ...
- buuctf crypto page 2
目录 robomunication Dangerous RSA Cipher [HDCTF2019]basic rsa [GXYCTF2019]CheckIn [GUET-CTF2019]BabyRS ...
- CTF CRYPTO 从零开始的RSA1
第三方库的安装及问题的解决 first of all,首先要把函数安好,编程实现过程中需要下载py的第三方库:pycrypto win+R打开cmd,打开py3所在目录,1.目的目录和当前目录在同盘: ...
- 关于Crypto.PublicKey.RSA,在generate后无法被赋值问题
前言 最近做题的时候有遇到一个问题,就是去利用求解出来的rsa的私钥去生成pem格式的私钥文件.找到网上用的都是先令RSA去generate,然后分别给RSA的n,e,d,p,q参数赋值,再导出私钥. ...
- BUUCTF Crypto题目记录
MD5 e00cf25ad42683b3df678c61f42c6bda 进行MD5加密 flag{admin1} Url编码 %66%6c%61%67%7b%61%6e%64%20%31%3d%31 ...
最新文章
- 推荐C、C++、Java、网络安全、Unix、Linux 一些编程书
- Scala的异常处理
- mysql5.7+ 虚拟列,json使用初体验
- 【⛸️拒绝手滑,我们都是稳准狠⛸️】C++のmemset函数的小探究
- Qt 多线程TCP服务端一键关闭所有客户端
- python哲学内容 多行胜于单行_Python3基础 __doc__ 单行与多行函数文档
- 插件修复数据_APP 热修复都懂了,你会 SDK 热修复吗?最全方案在这里!
- python输入两个正整数m和n用for循环求其最大公约数_输入两个正整数,m和n,求其最大公约数和最小公倍数。...
- vsftpd服务的搭建
- Qt|Linux工作笔记-异步调用ping命令,重定向获取信息,界面显示
- Sparta(斯巴达)——信息收集扫描爆破集成
- matlab bdir 排序,matlab-3次b样条(matlab - 3次b样条).doc
- exchange rate维护
- wps教程 如何恢复文档
- 如何使用Python还原村上春树笔下经典的那句“我爱你像爱春天的小熊”
- Error while Launching activity 解决方案:
- PyCharm下利用pyqt对话框打开图片,显示
- 小学如何开展创客教育教学工作
- python123判断ip地址合法性_判断IP地址的合法性
- vue拦截器设置请求头失败,laravel设置前端请求头跨域
热门文章
- qt4 与php 通讯,Qt与外部程序通信问题
- 机房配电柜、机柜线缆施工标准做法及线缆入柜方式
- 精密空调与普通空调区别及故障解析
- 云计算数据中心规划设计方案
- 成功解决TabError: inconsistent use of tabs and spaces in indentation
- 成功解决AttributeError: ‘JointGrid‘ object has no attribute ‘annotate‘
- 成功解决ValueError: cannot convert float NaN to integer
- AI:2020年6月16日晚20点陆奇博士演讲《正视挑战把握创业创新机会》
- 成功解决(Win32): 已加载“C:\Windows\SysWOW64\ntdll.dll”。无法查找或打开 PDB 文件。
- 成功解决TypeError: unsupported operand type(s) for %: 'NoneType' and 'dict'