[md5_compare]

md5_compare라는 이름에서 md5암호화를 통해 무언가를 비교하는 문제인 것 같다.

[md5_compare start]

value1과 value2 값을 입력 받는 것을 확인한 후 소스를 확인해 보았다.

[md5_compare view source]

php로 작성되어 졌으며 Get방식으로 value1, 2를 받는 것을 알 수 있다.

ctype_alpha는 인자값이 알파벳인지 확인하는 php 함수이다. v1이 문자인지 확인한다.

is_numeric은 인자값이 숫자인지 확인하는 php 함수이다. v2가 숫자인지 확인한다.

 

value1 -> v1

value2 -> v2

 

최종적으로 v1과 v2를 md5로 암호화한 값을 비교해서 같을 경우 flag를 알려주는 문제이다.

 

어느 부분에서 문제가 발생할지 고민 끝에 php함수 자체 취약점이라고 결론을 내리고 어떤 함수가 문제인지 찾아보았지만 눈에 뛰는 내용은 없었다.

 

그러던중 php는 == 연산자 뿐만 아니라 =, === 연산자를 이용한 정밀 검사가 있다는 것을 알게 되어 == 연산자에 취약점이 있는지 찾아보게 되었다.

 

아래 링크를 통해 php compare 연산자의 문제점을 알게 되었다.

www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison

 

PHP: Comparison Operators - Manual

When you want to know if two arrays contain the same values, regardless of the values' order, you cannot use "==" or "===".  In other words: To answer that question, use: A related, but more strict problem, is if you need to ensure that two arrays contain

www.php.net

'='은 값을 지정해줄때 사용한다.

'=='은 값이 같은지 비교해줄 때 사용한다.

'==='은 값과 데이터 형식이 같은지 비교할 때 사용한다.

 

www.php.net/manual/en/function.md5.php

 

PHP: md5 - Manual

I've found multiple sites suggesting the code:md5(file_get_contents($filename));Until recently, I hadn't noticed any issues with this locally... but then I tried to hash a 700MB file, with a 2048MB memory limit and kept getting out of memory errors...There

www.php.net

[md5_compare vulnerability]

php는 두 md5의 해시 값이 '0e'로 시작하기 때문에 참으로 판단한다고 한다. 참 어이가 없다.

 

[md5_compare flag]

'Challenge > Dreamhack' 카테고리의 다른 글

[Dreamhack] blind-command  (0) 2022.01.04
[wargame.kr] type confusion  (0) 2021.01.04
[wargame.kr] pyc decompile  (0) 2020.12.29
[wargame.kr] tmitter  (0) 2020.10.13
[wargame.kr] DB is really GOOD  (0) 2020.10.06

+ Recent posts