from secret import flag from Crypto.Util.number import *
p = getPrime(1024) q = getPrime(1024)
d = getPrime(32) e = inverse(d, (p-1)*(q-1)) n = p*q m = bytes_to_long(flag)
c = pow(m,e,n)
print(c) print(e) print(n)
# c = 6755916696778185952300108824880341673727005249517850628424982499865744864158808968764135637141068930913626093598728925195859592078242679206690525678584698906782028671968557701271591419982370839581872779561897896707128815668722609285484978303216863236997021197576337940204757331749701872808443246927772977500576853559531421931943600185923610329322219591977644573509755483679059951426686170296018798771243136530651597181988040668586240449099412301454312937065604961224359235038190145852108473520413909014198600434679037524165523422401364208450631557380207996597981309168360160658308982745545442756884931141501387954248 # e = 8614531087131806536072176126608505396485998912193090420094510792595101158240453985055053653848556325011409922394711124558383619830290017950912353027270400567568622816245822324422993074690183971093882640779808546479195604743230137113293752897968332220989640710311998150108315298333817030634179487075421403617790823560886688860928133117536724977888683732478708628314857313700596522339509581915323452695136877802816003353853220986492007970183551041303875958750496892867954477510966708935358534322867404860267180294538231734184176727805289746004999969923736528783436876728104351783351879340959568183101515294393048651825 # n = 19873634983456087520110552277450497529248494581902299327237268030756398057752510103012336452522030173329321726779935832106030157682672262548076895370443461558851584951681093787821035488952691034250115440441807557595256984719995983158595843451037546929918777883675020571945533922321514120075488490479009468943286990002735169371404973284096869826357659027627815888558391520276866122370551115223282637855894202170474955274129276356625364663165723431215981184996513023372433862053624792195361271141451880123090158644095287045862204954829998614717677163841391272754122687961264723993880239407106030370047794145123292991433
from Crypto.Util.number import * from flag import flag
defgen_prime(n): res = 1
for i inrange(15): res *= getPrime(n)
return res
if __name__ == '__main__': n = gen_prime(32) #32位n e = 65537 m = bytes_to_long(flag) c = pow(m,e,n) print(n) print(c) # 17290066070594979571009663381214201320459569851358502368651245514213538229969915658064992558167323586895088933922835353804055772638980251328261 # 14322038433761655404678393568158537849783589481463521075694802654611048898878605144663750410655734675423328256213114422929994037240752995363595
# from flag import flag, key # modulus = 256 # ciphertext = []
# for f in flag: # ciphertext.append((key[0]*f + key[1]) % modulus)
# print(bytes(ciphertext).hex())
import binascii
modulus = 256
s = "dd4388ee428bdddd5865cc66aa5887ffcca966109c66edcca920667a88312064"
s = binascii.unhexlify(s)
for i inrange(256):
for j inrange(256):
if (i*ord('f') + j) % modulus ==s[0] and (i*ord('l') + j) % modulus ==s[1] and (i*ord('a') + j) % modulus == s[2] :
print(i,j)
a,b = 17,23
flag = ''
for i inrange(len(s)):
for k inrange(255):
if (a*k + b)%256 == s[i]:
flag += chr(k)
break
print(flag)
#flag{4ff1ne_c1pher_i5_very_3azy}
根据源码知道,a*flag+b =c字符,那么,设个方程即可,解出来后,再带回去,即可。
WEEK1|PWN ret2text
/pwn/xinshengsai ❯ checksec ret2text ✘ INT 1m 16s root@Bohemian 11:08:48 [] Checking for new versions of pwntools To disable this functionality, set the contents of /root/.cache/.pwntools-cache-3.8/update to ‘ever’ (old way). Or add the following lines to ~/.pwn.conf or ~/.config/pwn.conf (or /etc/pwn.conf system-wide): [update] interval=never [] A newer version of pwntools is available on pypi (4.8.0 –> 4.11.0). Update with: $ pip install -U pwntools [*] ‘/pwn/xinshengsai/ret2text’ Arch: amd64-64-little RELRO: Full RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) 没有开保护