# easy_real

import random
import hashlib
flag = 'xxxxxxxxxxxxxxxxxxxx'
key = random.randint(1,10)
for i in range(len(flag)):
	crypto += chr(ord(flag[i])^key)
m = crypto的ascii十六进制
e = random.randint(1,100)
print(hashlib.md5(e))
p = 64310413306776406422334034047152581900365687374336418863191177338901198608319
q = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
n = p*q
c = pow(m,e,n)
print(n)
print(c)
#37693cfc748049e45d87b8c7d8b9aacd
#4197356622576696564490569060686240088884187113566430134461945130770906825187894394672841467350797015940721560434743086405821584185286177962353341322088523
#3298176862697175389935722420143867000970906723110625484802850810634814647827572034913391972640399446415991848730984820839735665233943600223288991148186397

n c e p 已知

简单的 rsa

求出的 m 是与随机数 k 异或

from Crypto.Util.number import *
e=23
n=4197356622576696564490569060686240088884187113566430134461945130770906825187894394672841467350797015940721560434743086405821584185286177962353341322088523
c=3298176862697175389935722420143867000970906723110625484802850810634814647827572034913391972640399446415991848730984820839735665233943600223288991148186397
p=64310413306776406422334034047152581900365687374336418863191177338901198608319
q=n//p
phi=(p-1)*(q-1)
d=inverse(e,phi)
m=long_to_bytes(pow(c,d,n))
print(m)
for key in range(1,10):
    crypto = ''
    for i in m:
	    crypto += chr(i^key)
    print(crypto)

# special_rsa

from Crypto.Util.number import *
def getPrime1(bitLength, e):
    while True:
        i = getPrime(bitLength)
        if (i - 1) % e ** 2 == 0:
            return i
flag=b'DASCTF{????????????????????}'
m = bytes_to_long(flag)
lenth = ((len(bin(m)) - 2) // 2) + 9
e=113
p = getPrime1(lenth, e)
q = getPrime1(lenth, e)
n=p*q
print(f"n = {n}")
c1 = pow(m, e, n)
for i in range(26):
    lenth = ((len(bin(c)) - 2) // 2) + 9
    p = getPrime1(lenth, e)
    q = getPrime1(lenth, e)
    n=p*q
    print(f"n = {n}")
    c=pow(c,e,n)
print(f"e = {e}")
print(f"c = {c}")

n 可以分解,gcd (e,phi)=e

特殊情况 ep1e|p-1

参考 La 佬

但是这里循环了 26 次,根据尚师傅提醒每一次求出来的 m 都小于后一次的 n get 了

exp

e = 113
c = 1028324919038104683475485759234995158466543298184637219012354053883391759172761125802189697762778242175407876548832454351014064525118465877297277847501477586955680645311999174005606833294172830817159
n = [1134876149917575363176366704410565158549594427794901202977560677131703617,
     68506321231437453734007374706367120760326482177047006099953454136095248103663,
     7783503593765446343363083302704731608384677185199537317445372251030064778965500447,
     1070135687488356161164202697449500843725645617129661751744246979913699130211505096520493,
     84012402115704505952834528733063574032699054524475028392540927197962976150657887637275643641,
     4497278582433699034700211877087309784829036823057043402314297478185216205338241432310114079123771,
     222438508972972285373674471797570608108219830357859030918870564627162064662598790037437036093579139489,
     19116847751264029874551971240684579996570601026679560309305369168779130317938356692609176166515369250878437,
     1549903986709797721131070830901667744892392382636347158789834851868638863292232718716074359148785900673192362699,
     62387766690725996279968636478698222263235233511074646032501495855928095611796694112573478405813305623307157261619643,
     1496134688150941811618178638810353297864345150241986530472328508974364124440160181353848429438725939837967063441528305921,
     128744123633657656499069966444992201456797762973822340505291131642660343436783413140023509983315177426811890315424928661125061,
     6917342652058596217869122177298094984415751234677039849514181349685079073411591975537016273056773954075238307918266361998553646469,
     1999306851167477770905800721615579416365273707414308684419794311809177595829473632853128686208533753019224536487399393397120864878000113,
     138594056023048386926766329537127538558164718841925506735112367176642328352257472034381662493666299220910783237918231719166519833124529218331,
     8397272388904583425531462714999219642572091279898695377838194583995214737828538895164195817973441184775814069396690436662985593377966417476040659,
     83372889332166088651413254885376085265561130214754686361784964744744711092668473281132249352040520639092871294276293287744276919265091479681667169671,
     10684953914628370830889219903654707140968094024767031366624595731918523435466123514094659595357231410471738736952266383928737163485550013190959149252435167,
     428359134899960532964729749713513106760306719712194950954567619156985067322564731294653991204666853689688900339268764469280769569535109069729404621290809120793,
     24491413133428851306933688733518898516890217803647806829002775935975741568422047344206442746983871735723486865901743352102305801200224958166496937663406627341150101,
     2247517335600310176909964109060502815240207684510918447209767597511414934626668616704865548059751008841620288545344598917362752622130186820039265603312354963258673860579,
     157978379942536176944325875241196121764116712487226808271002140500926678942090491383544034591205964958130852055691446362753906164711087278555153881606839791499207025307202087,
     43938571869497484913682975192955012614794498816057204091016374302341854100775132924321569876797699342959191646206571444845883942305710956894334106963321644724361549027630634869933,
     2609065298534470914730686454716224905333131812890643378630636043224255484662185236061585264231004975072801053316107165770342161619265243081616632312934742288262985830181883449780965531,
     222235907202454132555071455958700740228567465616560859711214102245461514428187391909176054661864893645713338391509536653547350134615807194339839952004333949540567943568810413945779642106201,
     44890472824427626252451120059527486677662371033945481542195354255473403815853320591468917295474578271680865394304946847791535710766947049195816261224382109115684638995528332538466194474846836399,
     1062789633774349417938788353001516763303743389381120380522262327123099728631034935663418832664265833959487018276693680850987382421521055508477988016246558095545925414048663082368488342633334571240563]
p = []
p.append(953730950786751671162019537171974567)
p.append(232079231415308325450092906880606082069)
p.append(88067722275537586769787599991567203589751)
p.append(24335212484189159197840692460327461505035059)
p.append(7832299017937880395583715032476962329929226581)
p.append(1656848589754467667368312855929759764100120657831)
p.append(385788223643735590500185001710758495904528462058461)
p.append(135813272566456906193934636644217527100917542578856697)
p.append(37185691759470013533730603170661686570987787098353146897)
p.append(6623023178993627032758350846838617937710601663528839184727)
p.append(954412804126450754097808991490470782833291028309980575506163)
p.append(350121371461894793578110243222665782247737840410076591434903787)
p.append(66882708962198932251728043152245270662769508317424500666902658099)
p.append(43449898447639409732732812916430042263570178747794530133229640125923)
p.append(11136261905010083405430254612464029672882837025885682392810368001188527)
p.append(2623629589005115152329094552749299711026240699896424120660145647226563547)
p.append(262775599542220820608778738911414710660835549772895468394761119434220071003)
p.append(102366458668689911004027849640392002821642295855327735994412634235696717329671)
p.append(15874438801602936764330936047390981280096007684699625987478211613419079727910193)
p.append(4479430800690915874719403516331677127806963529247809966024777708496270901092401687)
p.append(1328165608715012145707239303399129070657427496129541416861187541092152796676371237057)
p.append(368461902207817023013078031477042541053987571003677386333567043030477451518424731838173)
p.append(206721456778089912780641186795393376537372828449722520397829606593267585681448641482345737)
p.append(43870497594014737833600078975099212558645315030912084285417550950854483979406797450479252891)
p.append(14702310219802004876082313481498680940324963613770096574742182597840558294030859405666549879531)
p.append(5952590790902091635268726673538951527433355660839816621733964706901441977862333411532558667717227)
p.append(978009050697262759337388871320370165458800566798280419667959552859180906066907114053826258140106617)
q = []
for i in range(27):
     q.append(n[i]//p[i])
for k in range(26, 0, -1):
     if k == 26:
          C ,C0 = [c],[c]
     else:
          C ,C0 = C0, []
     for c in C:
          R.< x > = Zmod(p[k])[]
          f = x ^ e - c
          f = f.monic()
          res1 = f.roots()
          R.< x > = Zmod(q[k])[]
          f = x ^ e - c
          f = f.monic()
          res2 = f.roots()
          for i in res1:
               for j in res2:
                    m = (CRT(int(i[0]), int(j[0]), p[k], q[k]))
                    if m < n[k - 1]:
                         C0.append(m)
                         print(C0)
p=953730950786751671162019537171974567
q=1134876149917575363176366704410565158549594427794901202977560677131703617//p
c=53296318153341311013989348488093143123693921875654781175946491674187297
k = 0
R.<x> = Zmod(p)[]
f = x ^ e - c
f = f.monic()
res1 = f.roots()
R.<x> = Zmod(q)[]
f = x ^ e - c
f = f.monic()
res2 = f.roots()
for i in res1:
     for j in res2:
          m = (CRT(int(i[0]), int(j[0]), p[k], q[k]))
          if b'DAS' in long_to_bytes(m):
               print(long_to_bytes(m))

# CVE OF RSA

通过链接

在 roca.py 下加上

# Some logging so we can see what's happening.
logging.basicConfig(level=logging.DEBUG)
M = 962947420735983927056946215901134429196419130606213075415963491270
N = 14481363580917358871472996410471767154481047067466167591298208947805462002275531552979475988627964256677709787930755013972295770123571982960720640872341517
p_, q_ = factorize(N, M, 5, 6)
print(f"Found p = {p_} and q = {q_}")

但是没跑出来

问题不大

0BE7DC13