【Crypto | CTF】BugKu 简单的RSA

天命:这题也不算简单了,要反编译,要灵活一点

首先收到pyc文件,拿去反编译出来,可以用在线反编译,也可以用工具反编译

在线:python反编译 - 在线工具

工具:https://download.csdn.net/download/OrientalGlass/87388859

工具反编译一下,然后将代码复制去新的Python文件

拿到新的.py文件后,开始排坑

坑点1:把那两行c的计算和打印c去掉

坑点2:把16进制的数转成10进制才能计算正确的答案

python 复制代码
import gmpy2,base64
from Crypto.Util.number import *
from binascii import a2b_hex, b2a_hex

# 转成字节编码
flag = '******************'.encode("ascii")

# 转成10进制
p = int('0xED7FCFABD3C81C78E212323329DC1EE2BEB6945AB29AB51B9E3A2F9D8B0A22101E467',16)
q = int('0xAD85852F9964DA87880E48ADA5C4487480AA4023A4DE2C0321C170AD801C9',16)
e = 65537
n = p * q

# 这两行是个坑,干扰你的
# c = pow(int(b2a_hex(flag), 16), e, n)
# print(long_to_bytes(c))

# 转成10进制
c = int("0x75AB3202DE3E103B03C680F2BEBBD1EA689C8BF260963FE347B3533B99FB391F0A358FFAE5160D6DCB9FCD75CD3E46B2FE3CFFE9FA2E9508702FD6E4CE43486631",16)

# 欧拉函数
T = (p-1) * (q-1)

D = int(gmpy2.invert(e,T))

# 解密明文
M = pow(c,D,n)

# 先用字节转字符串,然后发现是base64编码,然后再解码
print(base64.b64decode(long_to_bytes(M)))

flag{IlikeCTFbutCTFdon'tlikeme}

相关推荐
阿尔的代码屋4 小时前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python
AI探索者21 小时前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者21 小时前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
FishCoderh1 天前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅1 天前
Python函数入门详解(定义+调用+参数)
python
曲幽1 天前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama
两万五千个小时1 天前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
哈里谢顿1 天前
Python 高并发服务限流终极方案:从原理到生产落地(2026 实战指南)
python
用户8356290780512 天前
无需 Office:Python 批量转换 PPT 为图片
后端·python
markfeng82 天前
Python+Django+H5+MySQL项目搭建
python·django