NSSCTF Round#17 Basic-WP——Crypto

文章讲述了在密码学挑战中,使用共模攻击技术解决RSA问题的过程,通过自动化脚本快速处理多个加密实例,最终成功获取flag。作者提到轩禹利用特定工具和技巧快速解决了题目中的加密谜题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

Level_1

Level_2

Level_3


Level_1

info:

#真签到题
from Crypto.Util.number import bytes_to_long, getPrime
from secret import getflag

e1 = getPrime(1024)
e2 = getPrime(1024)
n = e1 * e2
m = bytes_to_long(getflag().encode())
c1 = pow(m, e1, n)
c2 = pow(m, e2, n)
print(n)
print(c1)
print(c2)
print(e1)
print(e2)

# n = 22517647586235353449147432825948355885962082318127038138351524894369583539246623545565501496312996556897362735789505076324197072008392656511657262430676945685471397862981216472634785622155317188784494912316440866051402627470561626691472280850273482836308002341429493460677206562201947000047718275995355772707947408688836667011206588727438261189233517003341094758634490421007907582147392858070623641389171229435187248184443645883661560636995548332475573072064240073037558031928639832259001407585962782698021735648128101459118863015844905452823095147248865104102562991382119836061161756978764495337874807458182581421229
# c1 = 1432393096266401187029059077791766305797845826173887492889260179348416733820890797101745501984437201566364579129066414005659742104885321270122634155922766503333859812540068278962999824043206496595825886026095484801291802992082454776271149083516187121160475839108002133113254134626407840182541809478892306748590016896975053434021666376203540725254480252049443975835307793528287818262102688334515632062552114342619781840154202525919769192765621085008206581226486157149883898548933475155236509073675387541466324512294079413938239828341890576923100769181401944289365386552139418728492565319685207500539721582552448971814
# c2 = 13299679392897297864252207869444022461237574801991239380909482153705185317634241850084078027230394830079554676426505967970943836811048777462696506309466535820372917756458083553031417406403895116557560548183674144457502601887632495739472178857537011190162283185735114683172731936834993707871636782206418680404006299140864001776588991141011500807549645227520128216130966268810165946959810884593793452437010902774726405217517557763322690215690606067996057037379898630878638483268362526985225092000670251641184960698506349245915816808028210142606700394584541282682338561482561343076218115042099753144875658666459825545602
# e1 = 155861690390761931560700906834977917646203451142415617638229284868013723431003139974975998354830978765979365632120896717380895021936387027045347260400512396388028781862427862974453223157509702913026222541667006325100878113871620322023188372501930117363623076837619478555007555970810681502521309925774889678793
# e2 = 144471983652821947847253052623701746810204736865723159569786739658583884214397562204788127484897909964898113250509653721265240138487697822089282456150238116811225975640330930854549232972314642221382625614304415750165289831040623741828600283778523993251940904896081111235859249916040849697146542311990869696453

 exp:共模变形攻击,上工具,轩禹秒了

Level_2

题目描述

hint:e is a common e

info:

# 猜猜我是谁 猜对了直接秒出flag喔
from Crypto.Util.number import bytes_to_long, getPrime
from secret import getflag

p = ***
q = getPrime(1024)
e = you guess!
n = p * q
m = bytes_to_long(getflag().encode())
c=pow(m, e, n)
print(q)
print(c)
#p=one of ps
#q=145721736470529261146573065574028992352505611489859183763269215489708531333597694809923949026781460438320576519639268582565188719134157402292313959218961804213310847081787824780075530751842057663327444602428455144829447776271394663729996984613471623158126083062443634493708467568220146024273763894704649472957
#c=17441814714407189483380175736850663249578989775568187792928771544069162420510939242665830363276698262009780462912108642025299275146709817979705069095332726251759039923303627023610865046363171692163473939115438686877494878334016463787558794121885354719336139401336137097548305393030069499625065664884238710759260231321106291200849044147840392021931720902340003746946851806025722944795391356835342258387797980787437188976704677008092850181043891802072500430200735973581081228711070923822341261809453662427341958883142789220800541626034573952425948295446202775198692920613709157662831071515700549093766182579873408465779
#flag=NSSCTF{*}

exp:猜测e=65537,感觉非预期了,本来是要读取文件ps.txt得到P,我用轩禹秒了

Level_3

题目描述

自动化RSA?

info:

 exp:题目给出关键函数并描述自动化RSA,这里就明白我们要解好多次了(665),所以直接上脚本

from pwn import *
import re
import gmpy2
import binascii

host = 'node1.anna.nssctf.cn'
port = 28406
f = remote(host, port)

for i in range(1,667):
	if i>2:
		count = 13
	else:
		count = 12
	w = f.recvlines(count)
	r = f.recvline()
	s = f.recvline()
	t = f.recvline()
	u = f.recvline()
	v = f.recvline()
	n = int(r[2:])
	e1 = int(s[3:])
	e2 = int(t[3:])
	c1 = int(u[3:])
	c2 = int(v[3:])
	s = gmpy2.gcdext(e1,e2)
	a = s[1]
	b = s[2]
	if a<0:
    		a = -a
    		c1 = gmpy2.invert(c1,n)
	else:
    		b = -b
    		c2 = gmpy2.invert(c2,n)
	m = (gmpy2.powmod(c1,a,n)*gmpy2.powmod(c2,b,n))%n
	m = binascii.unhexlify(hex(m)[2:])
	f.sendline(m)
	print(i)
	print(m)
print(1)
f.interactive()

 跑一会就能拿到flag

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值