io.sendlineafter(":", "2") flag = [eval(_) for _ in io.recvline().strip().decode()[:-1].split(",")]
defremove_noise(flag, i): flag_with_noise = [0] * len(flag) for j in range(2**i): io.sendlineafter(":", "2") new_flag_with_noise = [eval(_) for _ in io.recvline().strip().decode()[:-1].split(",")] flag_with_noise = [flag_with_noise[i] + new_flag_with_noise[i] for i in range(len(flag))] flag_with_noise = [_ / (2**i) for _ in flag_with_noise] flag = [(flag[i] + flag_with_noise[i]) / 2for i in range(len(flag))] return flag
for i in tqdm(range(10)): flag = remove_noise(flag, i) print(bytes([round(_) for _ in flag])) ''' [+] Opening connection to 124.71.145.165 on port 9999: Done 0%| | 0/10 [00:00<?, ?it/s]b'k^gufxyrt\\gnlvfrwcf_]anvo_ejodftensicq^ptjvfcy\x80' 10%|████████████████▊ | 1/10 [00:00<00:01, 7.45it/s]b'j_euf{ypx_hnmvanvch__`n}pabliffqfnshao_orjueaz~' 20%|█████████████████████████████████▌ | 2/10 [00:00<00:01, 5.56it/s]b'hbdug|xpv`jnnwanvcf`banyr`dkgfdqfoshan`qqjvb`{|' 30%|██████████████████████████████████████████████████▍ | 3/10 [00:00<00:02, 3.47it/s]b'hacug|xou`kmow_lubh`bbows`dkegdrfntian_qqivabx}' 40%|███████████████████████████████████████████████████████████████████▏ | 4/10 [00:02<00:03, 1.84it/s]b'g`cuf{xot`kmow_mvcg`aaovt_dkfffrentiam_privaby}' 50%|████████████████████████████████████████████████████████████████████████████████████ | 5/10 [00:04<00:05, 1.02s/it]b'g`ctf{xou_jnow_mvcg_about_djfffrentiam_priv`cy}' 60%|████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 6/10 [00:08<00:08, 2.04s/it]b'gactf{you_jnow_much_abous_difffrential_privacy}' 70%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 7/10 [00:17<00:12, 4.13s/it]b'gactf{you_jnow_much_about_differential_privacy}' 80%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 8/10 [00:35<00:16, 8.27s/it]b'gactf{you_know_much_about_differential_privacy}' '''
h = hashlib.md5(key).hexdigest() SECRET = binascii.unhexlify(h)[:10] with open('flag','rb') as f: IV = f.read().strip(b'gactf{').strip(b'}') message = b'AES CBC Mode is commonly used in data encryption. What do you know about it?'+SECRET print("Encrypted data: ", binascii.hexlify(encrypt(pad(message),key,IV))) ''' Encrypted data: b'a8**************************b1a923**************************011147**************************6e094e**************************cdb1c7**********a32c412a3e7474e584cd72481dab9dd83141706925d92bdd39e4' '''
defxor(a, b): return bytes(x ^ y for x, y in zip(a, b))
for i in range(0x100): for j in range(0x100): k = bytes(key[:-2] + [i, j]) h = hashlib.md5(k).hexdigest() SECRET = binascii.unhexlify(h)[:10] aes = AES.new(k, AES.MODE_ECB) if xor(aes.decrypt(binascii.unhexlify(cipher[-32:]))[-10:], binascii.unhexlify(cipher[-52:-32])) == bytes([10] * 10): print(k) print(SECRET) ''' b'T0EyZaLRzQmNe2pd' b'\xfc\x89\xb4\xd5\xe2\x0b\xd2\xc6U\xae' '''
key = b'T0EyZaLRzQmNe2pd' SECRET = b'\xfc\x89\xb4\xd5\xe2\x0b\xd2\xc6U\xae' message = pad(b'AES CBC Mode is commonly used in data encryption. What do you know about it?'+SECRET) ct = binascii.unhexlify(cipher[-32:]) aes = AES.new(key, AES.MODE_ECB) for i in range(5): ct = xor(aes.decrypt(ct), message[-16:]) message = message[:-16] iv = xor(aes.decrypt(ct), message[-16:]) iv # b'9j_for_aes_cbc!!'
square
[题解分析]
1
'Please give me 100 (x,y) which satisfies x**2 = ( 1**2 + 2**2 + ... + y**2) / y\n'
A = (68279847973010227567437241690876400434176575735647388141445319082120661, 36521392659318312718307506287199839545959127964141955928297920414981390) B = (84698630137710906531637499064120297563999383201108850561060383338482806, 10975400339031190591877824767290004140780471215800442883565278903964109)
from Crypto.Util.number import *
p = GCD(A[0]^2+A[1]^2-1, B[0]^2+B[1]^2-1) factor(p) # 2^2 * 108848362000185157098908557633810357240367513945191048364780883709439999
p = 108848362000185157098908557633810357240367513945191048364780883709439999 g = (29223879291878505213325643878338189297997503744039619988987863719655098, 32188620669315455017576071518169599806490004123869726364682284676721556)