pwnable.kr(2) - collision
Problem
Points: 3 pt
1 | Daddy told me about cool MD5 hash collision today. |
Code
1 |
|
Prepare
little-endian
Thinking
L16 需求一個參數作為passcode,L19 passcode必須長20Byte。
L4 check_password
方法,將輸入p強制以int方式處理。
對應20Byte輸入passcode將轉為5個int處理,呼應L8 for迴圈上限5。
回傳值為5個int總和。
L24 若check_password
回傳值等於 L3 0x21DD09EC則獲得flag。
Solution
一個字元是由1個Byte所組成,而一個int是由4個Byte所組成。
所以輸入的字元每4個一組,轉換為整數後相加必須為0x21DD09EC。
由於輸入必須可以分為5組int,轉為20Byte,20字元。
直接以0x21DD09EC除以5可得113626824(0x6C5CEC8)餘4。
則可以確定總和為 0x06C5CEC8 * 4 + 0x06C5CECC。
因C語言處理字元有順序問題(小序),反轉後轉為字元即為:
\xC8\xCE\xC5\x06 * 4 + \xCC\xCE\xC5\x06
輸出使用Python組合:
1 | $ ./col `python -c "print '\xC8\xCE\xC5\x06' * 4 + '\xCC\xCE\xC5\x06'"` |