下载附件是一个py文件,打开之后,发现是常规的rsa,不过有几个函数不知道。

这里记录一下,

Fraction(a,b) 相当于 a/b

Derivative(f(x),x) : 当x='x’时,f(x)的导数值

from Crypto.Util.number import getPrime,bytes_to_long
from sympy import Derivative
from fractions import Fraction
from secret import flag p=getPrime(1024)
q=getPrime(1024)
e=65537
n=p*q
z=Fraction(1,Derivative(arctan(p),p))-Fraction(1,Derivative(arth(q),q))
m=bytes_to_long(flag)
c=pow(m,e,n)
print(c,z,n)
'''
output:
7922547866857761459807491502654216283012776177789511549350672958101810281348402284098310147796549430689253803510994877420135537268549410652654479620858691324110367182025648788407041599943091386227543182157746202947099572389676084392706406084307657000104665696654409155006313203957292885743791715198781974205578654792123191584957665293208390453748369182333152809882312453359706147808198922916762773721726681588977103877454119043744889164529383188077499194932909643918696646876907327364751380953182517883134591810800848971719184808713694342985458103006676013451912221080252735948993692674899399826084848622145815461035
32115748677623209667471622872185275070257924766015020072805267359839059393284316595882933372289732127274076434587519333300142473010344694803885168557548801202495933226215437763329280242113556524498457559562872900811602056944423967403777623306961880757613246328729616643032628964072931272085866928045973799374711846825157781056965164178505232524245809179235607571567174228822561697888645968559343608375331988097157145264357626738141646556353500994924115875748198318036296898604097000938272195903056733565880150540275369239637793975923329598716003350308259321436752579291000355560431542229699759955141152914708362494482
15310745161336895413406690009324766200789179248896951942047235448901612351128459309145825547569298479821101249094161867207686537607047447968708758990950136380924747359052570549594098569970632854351825950729752563502284849263730127586382522703959893392329333760927637353052250274195821469023401443841395096410231843592101426591882573405934188675124326997277775238287928403743324297705151732524641213516306585297722190780088180705070359469719869343939106529204798285957516860774384001892777525916167743272419958572055332232056095979448155082465977781482598371994798871917514767508394730447974770329967681767625495394441 '''

那这里Derivative(artan§,p)相当于是1/1+p^2,而另一边是1/1-p ^2 ,再倒一下,那么这个z实际上就是p ^ 2+q ^2

n又是p*q

这里写脚本用到一些gmpy2的库函数,这里也记录一下

 Encoding=UTF-8

import gmpy2

# gmpy2.mpz(x)

# 初始化一个大整数x

gmpy2.mpfr(x)

# 初始化一个高精度浮点数x

C = gmpy2.powmod(M,e,n)

# 幂取模,结果是 C = (M^e) mod n

d = gmpy2.invert(e,n) # 求逆元,de = 1 mod n

gmpy2.is_prime(n) # 判断n是不是素数

gmpy2.gcd(a,b) # 欧几里得算法

gmpy2.gcdext(a,b) # 扩展欧几里得算法

gmpy2.iroot(x,n) # x开n次根
from Crypto.Util.number import getPrime,bytes_to_long
from sympy import Derivative
from fractions import Fraction
from gmpy2 import *
def num2str(n):
tmp=str(hex(n))[2:]
if len(tmp)%2==0:
pass
else:
tmp='0'+tmp
s=''
for i in range(0,len(tmp),2):
temp=tmp[i]+tmp[i+1]
s+=chr(int(temp,16))
return s
c=7922547866857761459807491502654216283012776177789511549350672958101810281348402284098310147796549430689253803510994877420135537268549410652654479620858691324110367182025648788407041599943091386227543182157746202947099572389676084392706406084307657000104665696654409155006313203957292885743791715198781974205578654792123191584957665293208390453748369182333152809882312453359706147808198922916762773721726681588977103877454119043744889164529383188077499194932909643918696646876907327364751380953182517883134591810800848971719184808713694342985458103006676013451912221080252735948993692674899399826084848622145815461035
z=32115748677623209667471622872185275070257924766015020072805267359839059393284316595882933372289732127274076434587519333300142473010344694803885168557548801202495933226215437763329280242113556524498457559562872900811602056944423967403777623306961880757613246328729616643032628964072931272085866928045973799374711846825157781056965164178505232524245809179235607571567174228822561697888645968559343608375331988097157145264357626738141646556353500994924115875748198318036296898604097000938272195903056733565880150540275369239637793975923329598716003350308259321436752579291000355560431542229699759955141152914708362494482
n=15310745161336895413406690009324766200789179248896951942047235448901612351128459309145825547569298479821101249094161867207686537607047447968708758990950136380924747359052570549594098569970632854351825950729752563502284849263730127586382522703959893392329333760927637353052250274195821469023401443841395096410231843592101426591882573405934188675124326997277775238287928403743324297705151732524641213516306585297722190780088180705070359469719869343939106529204798285957516860774384001892777525916167743272419958572055332232056095979448155082465977781482598371994798871917514767508394730447974770329967681767625495394441
p_plus_q=iroot(z+2*n,2)[0]
p_sub_q=iroot(z-2*n,2)[0]
e=65537
p=(p_plus_q+p_sub_q)//2
q=(p_plus_q-p_sub_q)//2
d=invert(e,((p-1)*(q-1)))
m=pow(c,int(d),n)
print(num2str(m))

buu [BJDCTF2020]easyrsa的更多相关文章

  1. rsa special

    [ReSnAd] -- iqmp ipmq e,c,\(\phi(n)\) 题目: class Key: PRIVATE_INFO = ['P', 'Q', 'D', 'DmP1', 'DmQ1'] ...

  2. 解决centos 7.5安装openvpn,mirrors.163.com提示没有可用软件包openvpn、easy-rsa问题

    提示: yum install openvpn 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirro ...

  3. centos 7部署openvpn easy-rsa 3.0部署方法

    yum install openvpn easy-rsa openssl-devel mkdir -p /etc/openvpn/easy-rsa/cp -p /usr/share/doc/easy- ...

  4. openvpn之EasyRSA配置篇

    cd EasyRSA-2.2.2 vi vars #红色加粗的表示是我们需要修改的,其它的保持默认就可以 export EASY_RSA="`pwd`" export OPENSS ...

  5. Easy-RSA 3快速入门自述文件

    Easy-RSA 3快速入门自述文件 这是使用Easy-RSA版本3的快速入门指南.运行./easyrsa -h可以找到有关使用和特定命令的详细帮助.可以在doc /目录中找到其他文档. 如果您从Ea ...

  6. Easy-RSA 3 Quickstart README

    Easy-RSA 3 Quickstart README This is a quickstart guide to using Easy-RSA version 3. Detailed help o ...

  7. Buu刷题

    前言 希望自己能够更加的努力,希望通过多刷大赛题来提高自己的知识面.(ง •_•)ง easy_tornado 进入题目 看到render就感觉可能是模板注入的东西 hints.txt给出提示,可以看 ...

  8. BUU刷题01

    [安洵杯 2019]easy_serialize_php 直接给了源代码 <?php $function = @$_GET['f']; function filter($img){ $filte ...

  9. [BJDCTF2020]EzPHP

    [BJDCTF2020]EzPHP 解码:http://794983a5-f5dc-4a13-bc0b-ca7140ba23f3.node3.buuoj.cn/1nD3x.php 源代码: <? ...

随机推荐

  1. c# sql在where查询语句中使用字符串变量与int型变量

    使用where语句访问数据库时where语句用上文中以及定义过的变量来查询. string sql3 = string.Format("update Ships set ContainerN ...

  2. 发现新大陆 --21lic

    21lic网上发单平台 http://project.21ic.com/p/97250

  3. 七牛云-上传、删除文件,工具类(Day49)

    要求: 1. java1.8以上 2. Maven: 这里的version指定了一个版本范围,每次更新pom.xml的时候会尝试去下载7.5.x版本中的最新版本,你可以手动指定一个固定的版本. < ...

  4. 4.3 Python3进阶-函数嵌套和嵌套调用

    >>返回主目录 源码 # 函数嵌套 def func1(): print("这是外部函数") def func2(): print("这是内部函数1" ...

  5. 统信UOS - 扩展系统盘

    一.开root权限,开终端 二.执行lsblk指令,查看磁盘情况 可以发现 / 路径 对应的是loop0,查阅可知loop设备就是一个文件,挂载为一个路径操作的,这就尴尬了,好好的分区不用,你干嘛这么 ...

  6. jq slideDown后里面的A链接失效(已解决)

    jq slideDown后里面的A链接失效(解决) 用jq 的 slideDown写了一个二级下拉菜单,但是里面的a标签全部失效了,挂的链接右键菜单可以正常打开,但是左键正常点击不行 查阅了很多资料, ...

  7. ffmpeg安装之mac安装

    转发自白狼栈:查看原文 关于ffmpeg的安装,有的人可能要折腾很久,甚至折腾一个礼拜,究其原因,基本都是编译安装惹的祸. 我们提供4种安装方式,最复杂的莫过于centos7上的编译安装. ffmpe ...

  8. [leetcode] 72. 编辑距离(二维动态规划)

    72. 编辑距离 再次验证leetcode的评判机有问题啊!同样的代码,第一次提交超时,第二次提交就通过了! 此题用动态规划解决. 这题一开始还真难到我了,琢磨半天没有思路.于是乎去了网上喵了下题解看 ...

  9. 『言善信』Fiddler工具 — 7、统计选项页详解(Statistics)

    目录 1.Statistics选项页介绍 2.Statistics界面内容说明 3.Statistics选项页底部图表说明 1.Statistics选项页介绍 Statistics 页签显示当前用户选 ...

  10. Jmeter-逻辑控制器If Controller的实例运用

    一.If Controller概述 Expression (must evaluate to true or false) :表达式(值必须是true或false),也就是说,在右边文本框中输入的条件 ...