# 遍历每个像素 for y in range(height): for x in range(width): # 获取像素的RGB值 r, g, b = image.getpixel((x, y))
# 判断RGB值并输出相应字符 if r == 46: print('.',end="") elif r == 33: print('!',end="") elif r == 63: print('?',end="") if g == 46: print('.',end="") elif g == 33: print('!',end="") elif g == 63: print('?',end="") if b == 46: print('.',end="") elif b == 33: print('!',end="") elif b == 63: print('?',end="")
publicfunction__toString() { echo"I also want to fall in love"; if($this->girl != $this->boy && md5($this->girl) == md5($this->boy)){ $this->Aec->game(); } }
from sage.all import * import binascii from Crypto.Util.number import *
n =114007680041157617250208809154392208683967639953423906669116998085115503737001019559692895227927818755160444076128820965038044269092587109196557720941716578025622244634385547194563001079609897387390680250570961313174656874665690193604984942452581886657386063927035039087208310041149977622001887997061312418381 cipher =87627846271126693177889082381507430884663777705438987267317070845965070209704910716182088690758208915234427170455157948022843849997441546596567189456637997191173043345521331111329110083529853409188141263211030032553825858341099759209550785745319223409181813931086979471131074015406202979668575990074985441810
e2 = 0x10001 pbits = 512 for i in range(0,2**4): p4=0x38481379948fa6f1dcedd12e2fb045f096e9978eccc3be2984a9ede4e6ebe1958606c590 p4=p4+int(hex(i),16) print(hex(p4)) kbits = pbits - p4.nbits() #未知需要爆破的比特位数 print(p4.nbits()) p4 = p4 << kbits PR.<x> = PolynomialRing(Zmod(n)) f = x + p4 roots= f.small_roots(X=2^kbits, beta=0.4) #进行爆破 #print roots if roots: #爆破成功,求根 p = p4+int(roots[0]) print("p: ", hex(int(p))) assert n % p == 0 q = n/int(p) print("q: ", hex(int(q))) print(gcd(p,q)) phin = (p-1)*(q-1) print(gcd(e2,phin)) d = inverse_mod(e2,phin) print("d:",d) flag = pow(cipher,d,n) flag = hex(int(flag))[2:] result = "" for i in range(0, len(flag), 2): hex_int = int(flag[i:i+2], 16) # 转换为整数 result += chr(hex_int) # 转换为字符并拼接到结果字符串 print('result :',result) # SICTF{3f9366ed-b8e4-412f-bbd0-62616a24115c}
defis_character(x): returnord('a') <= x <= ord('z') orord('A') <= x <= ord('Z')
defxor_strings(s1, s2): returnbytes([b1 ^ b2 for b1, b2 inzip(s1, s2)])
definfer_space(index, pos): if message[index, pos] != 0: return message[index, pos] = ord(' ') for x inrange(len(ciphertexts)): if x != index: message[x][pos] = xor_strings(ciphertexts[x], ciphertexts[index])[pos] ^ ord(' ')
deffind_spaces(): for index, x inenumerate(ciphertexts): res = [xor_strings(x, y) for y in ciphertexts if x != y] f = lambda position: len(list(filter(is_character, [s[position] for s in res]))) cnt = [f(pos) for pos inrange(len(x))] for pos inrange(len(x)): space_data.append((f(pos), index, pos))
withopen('222.txt', 'r') as file: ciphertexts = [codecs.decode(x.strip().encode(), 'hex') for x in file.readlines()]
space_data = sorted(space_data, reverse=True) for weight, index, pos in space_data: infer_space(index, pos)
print('\n'.join([''.join([chr(c) for c in x]) for x in message])) hex_str1 = "1f2037202a1e6d06353b61263d050a0538493b3018544e14171d2b1c4218" hex_str2 = "Little Red Riding Hood promised"
import libnum import binascii from Crypto.Util.number import * n = 18993579800590288733556762316465854395650778003397512624355925069287661487515652428099677335464809283955351330659278915073219733930542167360381688856732762552737791137784222098296804826261681852699742456526979985201331982720936091963830799430264680941164508709453794113576607749669278887105809727027129736803614327631979056934906547015919204770702496676692691248702461766117271815398943842909579917102217310779431999448597899109808086655029624478062317317442297276087073653945439820988375066353157221370129064423613949039895822016206336117081475698987326594199181180346821431242733826487765566154350269651592993856883 c1 = 3089900890429368903963127778258893993015616003863275300568951378177309984878857933740319974151823410060583527905656182419531008417050246901514691111335764182779077027419410717272164998075313101695833565450587029584857433998627248705518025411896438130004108810308599666206694770859843696952378804678690327442746359836105117371144846629293505396610982407985241783168161504309420302314102538231774470927864959064261347913286659384383565379900391857812482728653358741387072374314243068833590379370244368317200796927931678203916569721211768082289529948017340699194622234734381555103898784827642197721866114583358940604520 c2 = 6062491672599671503583327431533992487890060173533816222838721749216161789662841049274959778509684968479022417053571624473283543736981267659104310293237792925201009775193492423025040929132360886500863823523629213703533794348606076463773478200331006341206053010168741302440409050344170767489936681627020501853981450212305108039373119567034948781143698613084550376070802084805644270376620484786155554275798939105737707005991882264123315436368611647275530607811665999620394422672764116158492214128572456571553281799359243174598812137554860109807481900330449364878168308833006964726761878461761560543284533578701661413931 defis_prime(n): if n <= 1: returnFalse if n <= 3: returnTrue if n % 2 == 0or n % 3 == 0: returnFalse i = 5 while i * i <= n: if n % i == 0or n % (i + 2) == 0: returnFalse i += 6 returnTrue deffranklinReiter(n,e,c1,c2): PR.<x> = PolynomialRing(Zmod(n)) g1 = (114*x+2333)^int(e) - c1 g2 = (514*x+4555)^int(e) - c2 defgcd(g1, g2): while g2: g1, g2 = g2, g1 % g2 return g1.monic() return -gcd(g1, g2)[0]
for i inrange(1024): if is_prime(i): e = i m=franklinReiter(n,e,c1,c2) print(long_to_bytes((int(m))))