보통 md5('value')로 hash값을 만들면 32자리 hex값으로 나오게 됩니다.

하지만 md5('value', true)로 hash값을 만들면 16자리 바이너리 형태로 나오게 됩니다.

바이너리 형태로 나오게 되면서 취약점이 발생합니다.


password='aaa'='bbb' 라는 식은 password='aaa' 부분이 false, bool 연산의 문자열은 false이기에 'bbb'도 false가 나와

true로 query가 작동하게 됩니다.


그렇다면 md5를 한 바이너리 값 중에서 '=' 라는 문자열이 나오게 되면 false + false = true 로 된다는 것입니다.



python으로 간단하게 hash를 생성하는 코드를 만들고 '=' 를 찾으면 띄워 주도록 만들었습니다.

(ascii code로 27은 싱글쿼터, 3d는 =입니다)

1
2
3
4
5
6
import hashlib
 
for password in range(1,99999999):
     md5_hash = hashlib.md5(str(password)).hexdigest()
     if '273d27' in md5_hash:
         print(password)
cs


여러 값들이 나오게 되는데 모든 값이 false/false가 되지 않는지 전부 되지는 않고, 몇몇 값들만 됩니다.


'WarGame > wargame.kr' 카테고리의 다른 글

[WarGame] md5_compare  (0) 2018.10.30
[WarGame] strcmp  (0) 2018.10.30
[WarGame] login filtering  (0) 2018.10.29
[WarGame] fly me to the moon  (0) 2018.10.28
[WarGame] QR CODE PUZZLE  (0) 2018.10.28

+ Recent posts