首页 > 其他分享 >[LitCTF 2023]factordb (中级)

[LitCTF 2023]factordb (中级)

时间:2024-12-25 10:00:49浏览次数:6  
标签:phi gmpy2 gp LitCTF factordb 2023 print import dp

[LitCTF 2023]factordb (中级)

攻击代码:

import gmpy2
from Crypto.Util.number import long_to_bytes

e=65537
p=275127860351348928173285174381581152299
q=319576316814478949870590164193048041239
n = 87924348264132406875276140514499937145050893665602592992418171647042491658461
c = 87677652386897749300638591365341016390128692783949277305987828177045932576708
phi=(p-1)*(q-1)
d=gmpy2.invert(e,phi)
m = pow(c,d,n)
print(long_to_bytes(m))

flag为:

NSSCTF{factordb!!!}

[LitCTF 2023]P_Leak

源代码:

from Crypto.Util.number import *
e=65537
m=bytes_to_long(b'xxxx')
p=getPrime(512)
q=getPrime(512)
n=p*q
phi=(p-1)*(q-1)
d=inverse(e,phi)
dp=d%(p-1)
c=pow(m,e,n)
print("dp=",dp)
print("n=",n)
print("c=",c)
#dp= 5892502924236878675675338970704766304539618343869489297045857272605067962848952532606770917225218534430490745895652561015493032055636004130931491316020329
#n= 50612159190225619689404794427464916374543237300894011803225784470008992781409447214236779975896311093686413491163221778479739252804271270231391599602217675895446538524670610623369953168412236472302812808639218392319634397138871387898452935081756580084070333246950840091192420542761507705395568904875746222477
#c= 39257649468514605476432946851710016346016992413796229928386230062780829495844059368939749930876895443279723032641876662714088329296631207594999580050131450251288839714711436117326769029649419789323982613380617840218087161435260837263996287628129307328857086987521821533565738409794866606381789730458247531619

攻击代码:

import gmpy2 as gp
e = 65537
n = gp.mpz(50612159190225619689404794427464916374543237300894011803225784470008992781409447214236779975896311093686413491163221778479739252804271270231391599602217675895446538524670610623369953168412236472302812808639218392319634397138871387898452935081756580084070333246950840091192420542761507705395568904875746222477)
dp = gp.mpz(5892502924236878675675338970704766304539618343869489297045857272605067962848952532606770917225218534430490745895652561015493032055636004130931491316020329)
c = gp.mpz(39257649468514605476432946851710016346016992413796229928386230062780829495844059368939749930876895443279723032641876662714088329296631207594999580050131450251288839714711436117326769029649419789323982613380617840218087161435260837263996287628129307328857086987521821533565738409794866606381789730458247531619)
for x in range(1, e):
    if(e*dp%x==1):
        p=(e*dp-1)//x+1
        if(n%p!=0):
            continue
        q=n//p
        phin=(p-1)*(q-1)
        d=gp.invert(e, phin)
        m=gp.powmod(c, d, n)
        if(len(hex(m)[2:])%2==1):
            continue
        print('--------------')
        print(m)
        print(hex(m)[2:])
        print(bytes.fromhex(hex(m)[2:]))

flag为:

NSSCTF{Prim3_1s_Le@k!!!!!}

[HUBUCTF 2022 新生赛]RSAaaa

攻击代码:

#coding:utf-8
from Crypto.Util.number import *
import gmpy2
n = 536970330703
p = 540961
q = 992623
e = 65537
message = "473878130775 40132555282 40132555282 94619939727 72818765591 208015808884 42561234694 159353248388 27748063975 159353248388 159353248388 278953790403 410746718603 496849210942 27748063975 142521857906 103632267191 17774494147 328684046745 278953790403 129956887006 129956887006 366275425558 328684046745 142521857906 410746718603 142521857906 129956887006 379067009467 328684046745 159353248388 366275425558 129956887006 103632267191 27748063975 27748063975 17774494147 160623996897 278953790403 182341799525"
phi = (p - 1) * (q - 1)
d = gmpy2.invert(e, phi)
flag = ''
for i in message.split(" "):
    m = gmpy2.powmod(int(i), d, n)
    flag += str(long_to_bytes(m))[2:3]
print(flag)

得到falg为:

NSSCTF{08004fa8571d4669d5f56ed096788134}

标签:phi,gmpy2,gp,LitCTF,factordb,2023,print,import,dp
From: https://blog.csdn.net/ming20211016/article/details/144419897

相关文章

  • 阅读报告 Phys. Rev. Lett. 130, 177001 (2023).
    摘要:本文为CollectiveTransportforNonlinearCurrent-VoltageCharacteristicsofDopedConductingPolymers,Phys.Rev.Lett.130,177001(2023)的阅读报告.文章中的参考文献均来自于文章Phys.Rev.Lett.130,177001(2023)底下的参考文献.报告正文:1.实验观测到......
  • NSSCTF--Crypto--[CISCN 2023 初赛]badkey
    [CISCN2023初赛]badkeytask:fromCrypto.Util.numberimport*fromCrypto.PublicKeyimportRSAfromhashlibimportsha256importrandom,os,signal,stringdefproof_of_work():random.seed(os.urandom(8))proof=''.join([random.choice(st......
  • NSSCTF--Crypto--[FSCTF 2023]ezmath
    [FSCTF2023]ezmathtask:importlibnumfromCrypto.Util.numberimport*fromsecretimportflagm=libnum.s2n(flag)e=65537p=getPrime(1024)q=getPrime(1024)n=p*qc=pow(m,e,n)hint=pow(2022*p+2023,q,n)print(f'n={n}')pri......
  • 2023腾讯游戏安全mobile端初赛wp
    绕过一些简单的检测绕过端口检测。app对27042与23946端口有检测。frida换个启动端口即可。./frida-server-16.1.10-android-arm64-l0.0.0.0:1234adbforwardtcp:1234tcp:1234IDA也换个调试端口./android_server64-p23947adbforwardtcp:23947tcp:23947......
  • 上市公司-企业税费统计、税收优惠、税费返还数据(2008-2023年)原始数据、计算代码、参考
    上市公司-企业税费统计、税收优惠、税费返还数据(2008-2023年)原始数据、计算代码、参考文献、最终结果 https://download.csdn.net/download/2401_84585615/90025511           https://download.csdn.net/download/2401_84585615/90025511    ......
  • (即插即用模块-特征处理部分) 十二、(2023) SDM 语义差异引导模块
    文章目录1、SemanticDifferenceGuidanceModule2、代码实现paper:PnPNet:Pull-and-PushNetworksforVolumetricSegmentationwithBoundaryConfusionCode:https://github.com/AlexYouXin/PnPNet1、SemanticDifferenceGuidanceModule为了解决以下几个问......
  • 2000-2023年 上市公司-企业数字化转型(报告词频、文本统计)原始数据、参考文献、代码、
    一、数据介绍数据名称:企业数字化转型-年度报告词频、文本统计数据范围:1999-2023年5630家上市公司样本数量:63051条,345个变量数据来源:上市公司年度报告数据说明:内含数字化转型314个词频、各维度水平、文本统计面板二、整理说明爬取1999-2023年上市公司年报将原始报告文本......
  • 【工具变量】上市公司企业供应链成本分担数据(2010-2023年)
    一、测算方式:参考C刊《经济管理》刘红霞老师(2024)的做法,从绿色投资企业与供应链其他成员企业关系层面出发,使用两个指标测度供应链成本分担:一是单向供应链成本分担总额(CS_get),是绿色投资企业从供应链其他成员企业获取的成本分担,强调了链上企业对绿色投资企业单向的成本分担水平,使......
  • 2024-2025-1 20231420《计算机基础与程序设计》第十二周助教总结
    课程答疑C语言:指针、结构体、文件C语言中,指针、结构体十分重要,也较为困难;大家刚接触文件的操作,可能比较陌生,未能掌握文件的相关操作。大家要深入学习指针、结构体、文件的相关语法,这对之后的课程也很有帮助,可以借助网络资源学习,也要多敲代码,多多练习。课程作业中出现的问题格......
  • 【漏洞复现】CVE-2022-45206 & CVE-2023-38905 SQL Injection
    漏洞信息NVD-CVE-2022-45206Jeecg-bootv3.4.3wasdiscoveredtocontainaSQLinjectionvulnerabilityviathecomponent/sys/duplicate/check.NVD-CVE-2023-38905SQLinjectionvulnerabilityinJeecg-bootv.3.5.0andbeforeallowsalocalattackerto......