with wave.open("test.wav", "rb") as f: attrib = f.getparams() wav_data = bytearray( f.readframes(-1) )
for index inrange(len(txt_data)): wav_data[index * 4] = txt_data[index] with wave.open("hiden.wav", "wb") as f: f.setparams(attrib) f.writeframes(wav_data)
敲打gpt加手动完善
import wave # 打开包含隐藏数据的WAV文件 with wave.open("hiden.wav", "rb") as f: # 获取音频参数和所有帧 wav_data = bytearray(f.readframes(-1))
from Crypto.Util.number import * import re import math c = 356435791209686635044593929546092486613929446770721636839137 p = 898278915648707936019913202333 q = 814090608763917394723955024893 e = 65537 n = p*q d = pow(e, -1, math.lcm(p-1, q-1)) m = pow(c, d, n) while m % 256 != 125: m += n jump = n * 256 target = b'DASCTF{' + b'0'*math.floor(math.log(m, 256)-7) md = long_to_bytes(m) while re.fullmatch(b'[0-9a-zA-Z_{}]+', md) == None: if md[0:7] == b'DASCTF{': m += jump # print(md) else: m += jump * math.ceil((bytes_to_long(target) - m)//jump) target += b'0' # print(math.log(m,2)) md = long_to_bytes(abs(m)) print(md.decode())
Babycurve
题目
#!/usr/bin/env python # -*- coding: UTF-8 -*- import os import hashlib from sage.allimport * from Crypto.Cipher import AES from Crypto.Util.Padding import pad from secret import c, b, key, FLAG
defadd_curve(P, Q, K): a, d, p = K if P == (0, 0): return Q if Q == (0, 0): return P x1, y1 = P x2, y2 = Q x3 = (x1 * y2 + y1 * x2) * pow(1 - d * x1 ** 2 * x2 ** 2, -1, p) % p y3 = ((y1 * y2 + 2 * a * x1 * x2) * (1 + d * x1 ** 2 * x2 ** 2) + 2 * d * x1 * x2 * (x1 ** 2 + x2 ** 2)) * pow( (1 - d * x1 ** 2 * x2 ** 2) ** 2, -1, p) % p return x3, y3
defmul_curve(n, P, K): R = (0, 0) while n > 0: if n % 2 == 1: R = add_curve(R, P, K) P = add_curve(P, P, K) n = n // 2 return R
defAES_encrypt(k): key = hashlib.sha256(str(k).encode()).digest()[:16] iv = os.urandom(16) cipher = AES.new(key, AES.MODE_CBC, iv) cipher = cipher.encrypt(pad(FLAG, 16)) data = {} data["iv"] = iv.hex() data["cipher"] = cipher.hex() return data
from Crypto.Util.number import * from Crypto.Cipher import AES import hashlib k = '2951856998192356' key = hashlib.sha256(str(k).encode()).digest()[:16] iv = 0xbae1b42f174443d009c8d3a1576f07d6 iv = long_to_bytes(iv) cipher = 0xff34da7a65854ed75342fd4ad178bf577bd622df9850a24fd63e1da557b4b8a4 cipher = long_to_bytes(cipher) aes = AES.new(key, AES.MODE_CBC, iv) print(aes.decrypt(cipher))
TheoremPlus
题目
from Crypto.Util.number import * from gmpy2 import * from secret import flag
defdecode_e(e): if e > 1: mul = 1 for i inrange(1, e): mul *= i if e - mul % e - 1 == 0: mulmod = mul % e - e else: mulmod = mul % e return mulmod + decode_e(e - 1) else: return0
q = getPrime(1024) p = next_prime(q) n = p * q phi = (p - 1) * (q - 1) e = abs(decode_e(703440151)) c = pow(bytes_to_long(flag), e, n) print('n = {}\n' 'c = {}'.format(n, c))
''' n = 18770575776346636857117989716700159556553308603827318013591587255198383129370907809760732011993542700529211200756354110539398800399971400004000898098091275284235225898698802555566416862975758535452624647017057286675078425814784682675012671384340267087604803050995107534481069279281213277371234272710195280647747033302773076094600917583038429969629948198841325080329081838681126456119415461246986745162687569680825296434756908111148165787768172000131704615314046005916223370429567142992192702888820837032850104701948658736010527261246199512595520995042205818856177310544178940343722756848658912946025299687434514029951 c = 2587907790257921446754254335909686808394701314827194535473852919883847207482301560195700622542784316421967768148156146355099210400053281966782598551680260513547233270646414440776109941248869185612357797869860293880114609649325409637239631730174236109860697072051436591823617268725493768867776466173052640366393488873505207198770497373345116165334779381031712832136682178364090547875479645094274237460342318587832274304777193468833278816459344132231018703578274192000016560653148923056635076144189403004763127515475672112627790796376564776321840115465990308933303392198690356639928538984862967102082126458529748355566 '''
n = 18770575776346636857117989716700159556553308603827318013591587255198383129370907809760732011993542700529211200756354110539398800399971400004000898098091275284235225898698802555566416862975758535452624647017057286675078425814784682675012671384340267087604803050995107534481069279281213277371234272710195280647747033302773076094600917583038429969629948198841325080329081838681126456119415461246986745162687569680825296434756908111148165787768172000131704615314046005916223370429567142992192702888820837032850104701948658736010527261246199512595520995042205818856177310544178940343722756848658912946025299687434514029951 c = 2587907790257921446754254335909686808394701314827194535473852919883847207482301560195700622542784316421967768148156146355099210400053281966782598551680260513547233270646414440776109941248869185612357797869860293880114609649325409637239631730174236109860697072051436591823617268725493768867776466173052640366393488873505207198770497373345116165334779381031712832136682178364090547875479645094274237460342318587832274304777193468833278816459344132231018703578274192000016560653148923056635076144189403004763127515475672112627790796376564776321840115465990308933303392198690356639928538984862967102082126458529748355566 a = 703440151
deffactor(n): a, f = gmpy2.iroot(n, 2)
while (True): a += 1 try: b, f = gmpy2.iroot(a*a - n, 2) except: pass
if f: return a-b, a+b
e = 36421873 p = factor(n)[0] q = factor(n)[1] d = inverse(e, (p-1)*(q-1)) print(long_to_bytes(pow(c, d, n)).decode())
TH_curve(未解)
题目
from Crypto.Util.number import * from secret import flag
defmul_THcurve(n, P): R = (0, 0) while n > 0: if n % 2 == 1: R = add_THcurve(R, P) P = add_THcurve(P, P) n = n // 2 return R
p = 10297529403524403127640670200603184608844065065952536889 a = 2 G = (8879931045098533901543131944615620692971716807984752065, 4106024239449946134453673742202491320614591684229547464)
FLAG = flag.lstrip(b'DASCTF{').rstrip(b'}') assertlen(FLAG) == 15 m = bytes_to_long(FLAG) assert m < p Q = mul_THcurve(m, G) print("Q =", Q) # Q = (6784278627340957151283066249316785477882888190582875173, 6078603759966354224428976716568980670702790051879661797)