首页 > 其他分享 >Crypto|[NPUCTF2020]EzRSA

Crypto|[NPUCTF2020]EzRSA

时间:2023-05-06 14:35:31浏览次数:58  
标签:gmpy2 gift Crypto print flag EzRSA import NPUCTF2020

attachment.py

from gmpy2 import lcm , powmod , invert , gcd , mpz
from Crypto.Util.number import getPrime
from sympy import nextprime
from random import randint
p = getPrime(1024)
q = getPrime(1024)
n = p * q
gift = lcm(p - 1 , q - 1)
e = 54722
flag = b'NPUCTF{******************}'
m = int.from_bytes(flag , 'big')
c = powmod(m , e , n)
print('n: ' , n)
print('gift: ' , gift)
print('c: ' , c)

#n:  17083941230213489700426636484487738282426471494607098847295335339638177583685457921198569105417734668692072727759139358207667248703952436680183153327606147421932365889983347282046439156176685765143620637107347870401946946501620531665573668068349080410807996582297505889946205052879002028936125315312256470583622913646319779125559691270916064588684997382451412747432722966919513413709987353038375477178385125453567111965259721484997156799355617642131569095810304077131053588483057244340742751804935494087687363416921314041547093118565767609667033859583125275322077617576783247853718516166743858265291135353895239981121
#gift:  2135492653776686212553329560560967285303308936825887355911916917454772197960682240149821138177216833586509090969892419775958406087994054585022894165950768427741545736247918410255804894522085720642952579638418483800243368312702566458196708508543635051350999572787188236243275631609875253617015664414032058822919469443284453403064076232765024248435543326597418851751586308514540124571309152787559712950209357825576896132278045112177910266019741013995106579484868768251084453338417115483515132869594712162052362083414163954681306259137057581036657441897428432575924018950961141822554251369262248368899977337886190114104
#c:  3738960639194737957667684143565005503596276451617922474669745529299929395507971435311181578387223323429323286927370576955078618335757508161263585164126047545413028829873269342924092339298957635079736446851837414357757312525158356579607212496060244403765822636515347192211817658170822313646743520831977673861869637519843133863288550058359429455052676323196728280408508614527953057214779165450356577820378810467527006377296194102671360302059901897977339728292345132827184227155061326328585640019916328847372295754472832318258636054663091475801235050657401857262960415898483713074139212596685365780269667500271108538319

分析

gift = lcm(p - 1 , q - 1),lcm为求最小公倍数
因为:$最小公倍数(

标签:gmpy2,gift,Crypto,print,flag,EzRSA,import,NPUCTF2020
From: https://www.cnblogs.com/scarecr0w7/p/17377209.html

相关文章

  • Crypto|[GWCTF 2019]BabyRSA
    encrypt.pyimporthashlibimportsympyfromCrypto.Util.numberimport*flag='GWHT{******}'secret='******'assert(len(flag)==38)half=len(flag)/2flag1=flag[:half]flag2=flag[half:]secret_num=getPrime(1024)*byt......
  • Crypto|[NCTF2019]babyRSA
    task.pyfromCrypto.Util.numberimport*fromflagimportflagdefnextPrime(n):n+=2ifn&1else1whilenotisPrime(n):n+=2returnnp=getPrime(1024)q=nextPrime(p)n=p*qe=0x10001d=inverse(e,(p-1)*(q-1))......
  • Crypto|[AFCTF2018]可怜的RSA
    public.key-----BEGINPUBLICKEY-----MIIBJDANBgkqhkiG9w0BAQEFAAOCAREAMIIBDAKCAQMlsYv184kJfRcjeGa7Uc/43pIkU3SevEA7CZXJfA44bUbBYcrf93xphg2uR5HCFM+Eh6qqnybpIKl3g0kGA4rvtcMIJ9/PP8npdpVE+U4Hzf4IcgOaOmJiEWZ4smH7LWudMlOekqFTs2dWKbqzlC59NeMPfu9avxxQ15fQzIjhvc......
  • Web|Buuctf-[NPUCTF2020]ezinclude
    查看源码提示md5($secret.$name)===$passcookie中存在hash,hash随着name的变化而变化hash填入pass参数请求跳转到404页面使用burpsuite发包,提示存在flflflflag.php页面flag不在此页面,并且页面存在文件包含漏洞读取flflflflag.php页面源码<html><head><scriptlangua......
  • cryptohack wp day(3)
    第二节模运算----第一题(GCD)在做这道题前,了解下欧几里得算法:欧几里得算法,也叫辗转相除法,用于求解两个非负整数a和b的最大公约数(GreatestCommonDivisor,GCD),即能够同时整除它们的最大正整数。算法的基本思想是,通过不断求解a和b的余数的最大公约数,最终可以得到a和b的最大公约......
  • cryptohack wp day (2)
    接着昨天的题目第五题看题目,一道简单的xor题,就是将“label中每个字符与13进行异或处理”,直接上代码:s="label"result=""foriins:result+=chr(ord(i)^13)print(result)或者按照题目所说,用pwntools库中的xor函数来进行异或操作,具体操作如下:frompwnimportxor......
  • cryptohack wp day(1)
    就从头开始吧第一题(ASCII)一道简单的ASCII码转换,直接用题目的提示代码解就行了ascii=[99,114,121,112,116,111,123,65,83,67,73,73,95,112,114,49,110,116,52,98,108,51,125]flag=""foriinascii:flag+=chr(i)print(flag)第二题(Hex)......
  • 安装pycrypto
    下载地址:https://www.dlitz.net/software/pycrypto/在BT5上安装:root@bt:~#easy_installpycrypto-2.6.tar.gzProcessingpycrypto-2.6.tar.gzWriting/tmp/easy_install-bRS9dY/pycrypto-2.6/setup.cfgRunningpycrypto-2.6/setup.py-qbdist_egg--dist-dir/tmp/easy_insta......
  • 前端使用CryptoJS加密解密
    1、安装crypto-js;npminstallcrypto-js--save-devyarnaddcrypto-js--dev2、新建unit.js写成公共方法;constCryptoJS=require('crypto-js');//16位十六进制数作为密钥(秘钥为随机生成,必须与后端保持一致!)constkey=CryptoJS.enc.Utf8.parse("xxxxxxxxxxxxxx");//......
  • DASCTF-Crypto-Sign1n
    sign1n显然能导出下面的式子:\(k\timesphi=e^3\times(WHATF-3)-1\).注意到\(phi=(p-1)\times(q-1)=n-(p+q)+1\),\(n=p\timesq\).考虑构造一元二次方程解出pq.同时考虑到\(k\times(p+q-1)<n\),代入得到:\(k\times(p+q-1)=(1-e^3\times(WHATF-3))\modn\).......