table = 'abcdefghijklmnopqrstuvwxyz{}' c = '{mvjk}gbxyiutfchpm}ylm}a}amuxlmg'
for k in itertools.product(table, repeat=4): key = ''.join(k)*8 print(key, end=': ') m = '' for i inrange(32): j = (table.index(key[i]) + table.index(c[i])) % len(table) m += table[j] print(m) if'hsnctf{'in m: print(m) break# jguv
stk32 = bytes(b for a, b inzip('0'*32, chacha_stream(key))) print(stk32) r = bytes([a ^ b ^ c ^ d for a, b, c, d inzip(stk32[:2], b'hs', enc[:2], key[:2])]) rand = r*16 print(rand) pas = bytes(a ^ b ^ d for a, b, d inzip(enc, stk32, rand)) flag = bytes(a ^ b for a, b inzip(pas, key)) print(flag)
#a = '[\x19\x11\x14\x10\x14A\x12\x10\x19E\x10F\x19AB\x17D\x12\x14\x15D\x15EE]' #real_flag = ''.join([chr(ord(x)+32) for x in a]) # wtm real_flag = ''.join([chr(x^32) for x in flag]) print(real_flag)
# Sage n = 18063067344610339216153985692612281572817741664675607678652303435614007498381778351769875436146202656046376229230301546036936157387112023740191321525053376287669082764405582433625684806876916446972913665369214463085013163680561680547504669535234097704543181896102678806687855186991260097818170404933906747197883469031713141650074132393349905331106066834535590661982175788821272806789997889177223174440597557123215327802956604540266427629432102831417141857529533126730032545280982187575314304833926895362131842373431496451307025688884322822389454974409791286467835534879165048438720535286815275424674266921135402897929
# from PollarRsaCracker(https://github.com/ZeroBone/PollardRsaCracker) q = 117486439452151013756875087780890246814564400691388361051671017362980892839542853238429910539305056241983874345637539194223655284177104469678700212956147349645867093623855297098201296729367179715901763674630438303543911790021803446119555075061116934105943593758927093241215951931328064556145541149845397321183 p = n // q assert p*q == n m1 = 412905115020036859448242054750143050792413836344
c2 = 889007651662506403203783493267282257215988729179620082971032093479384814992266823808192587257794931781622242482548202684315610166947125782056641835890542545830029903217817561269310184963519900268026434414254409767043528083064767018130469968738966212268513325090645430187706207887862845389628550171196492124556219364186293306935140349363837175430616647997752033400818089096772569695030947505437436792691260570218211502426593061096955991144063055944016658538765609416477033433728682889456364449301289731877176395077152830024245111711011732884071448942050549470148093802410710200714874231484059368826458031775976862475 e = 65537
G = Zmod(p) m2 = discrete_log(G(c2), G(e)) print(m2) # 567361900135895770360389450735093365969913930365
import libnum flag = libnum.n2s(int(m1)) + libnum.n2s(int(m2)) print(flag)
Reference:[HPS14] Hoffstein, Jeffrey, et al. An introduction to mathematical cryptography. Vol. 1. New York: springer, 2008.
whileTrue: g = os.walk('./out/') for path,dir_list,file_list in g: for file_name in file_list: zfn = os.path.join(path, file_name) print(zfn) if'zip'notin zfn: break zf = zipfile.ZipFile(zfn) for zfin in zf.namelist(): zf.extract(zfin, './out/') zf.close() os.remove(zfn)