# Crypto ## 一些py函式 - chr() - ex: 99 -> 'c' - bytes.fromhex('str') - ex: bytes().fromhex('617765736f6d65') -> b'awesome' - 不要留0x 不然python3識別不出來 - bytes().decode('ascii') - b'awesome' -> 'awesome' - base64函式庫裡的b64encode('bytes_string') - 轉換base64編碼 - Crypto.Util.number(install : pip install pycrypto) - long_to_bytes - bytes_to_long ## pwntools - py module - install : pip install pwntools - convenience to write exploit - 常用function - process() - remote() - send(),sendline() - sendafter(),sendlineafter() - recv(),recvline() - recvuntil() ### cryptohack/general/encoding challenge ## AES(Advanced Encryption Standard) - 對稱式加密 - block length : 128bit - key length : 128, 192 , 256bit - 4*4bytes matrix(state) - cryptohack/block cipher/Structure of AES - 4 step - AddRoundKey - subBytes - shiftRows - Mixcolumns - AddRoundKey - 對應該次的key進行xor - cryptohack/block cipher/Round key - ![](https://i.imgur.com/gQWsRW6.png) - subBytes - state 透過 sbox inverse 出來的表去做線性轉換 - 混淆用的步驟 避免簡單的代數攻擊 - cryptohack/block cipher/Confusion through Substitution - ![](https://i.imgur.com/WW1Qevz.png) - shiftrows - 將每個列向左位移一個數值 - 數值是該列的row值(第一列移0,第二列移1......) - ![](https://i.imgur.com/rK8KR3J.png) - Mixcolumns - cryptohack/block cipher/Diffusion through Permutation - ![](https://i.imgur.com/VrGo4M1.png) - Bringing It All Together ## RSA - fermat - nextPrime() - e太小 C直接取e root就是m - 練習好站 - [cryptoHack](https://cryptohack.org/) {%hackmd iaeIZ7VVT223x4UqDsJevQ %}
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up