IThome 2024 鐵人賽 一直刷 CTF - Day28
前言
本日進度:
上課紀錄
XOR

MOD

Lab - XOR wormup
改一下他的程式碼就可以得到 Flag 了1
2
3
4
5
6
7
8
9
10
11from Crypto.Random import get_random_bytes
# from flag import FLAG
FLAG = bytes.fromhex("603ad76575ed41dd3fd38be80d6edfdc569e2a324c928741129e210e2c934aa3770ff8d4f0c5340e82d9c0eea5")
def xor_bytes(a, b):
return bytes(x ^ y for x, y in zip(a, b))
random_data = bytes.fromhex("0209e4030e9929b44c8ce29b5216b0ae09ed456d29f3f4386be7585114f22ec2436ecdb795f2506db0bff5dcd8")
result = xor_bytes(FLAG, random_data)
print({result.decode()})
流密碼

隨機數

偽隨機數


線性同餘生成器 (Linear Congruential Generator)




其他常見方法

反饋位移生成器 (Feedback Shift Register)


lab - eof-almost baby prng
lab - easy lcg
lab - eof lf3r
對稱式加密

重點是 使用同一把鑰匙
基本策略
- Confusion
- 混淆密文和密鑰的關係,使難以從密文推斷出密鑰
- Defusion
- 改變一點點明文,就能改變很多密文
Feistel Network

DES (Data Encryption Standard)




Substitution-Permutation Network

AES (Advanced Encryption Standard)




TODO
之後好好研究一下原理還有把上面三題 lab 做完