Webhacking.kr 25번 문제풀이
안녕하세요.
웹 해킹 25번 문제풀이 하겠습니다.
문제를 보면 파일 및 디렉토리 항목과 "hello world" 문구가 보입니다. URI 경로가 file=hello인것으로 보아 hello.php가 실행된것을 추측할 수 있습니다.
그렇다면, URI경로를 file=flag로 변경하여 flag.php도 실행해 보겠습니다.
"FLAG is in the code"라는 문구를 보아 FLAG값이 code 안에 있다는 내용인거 같다. 우리는 code를 찾아 내야하는데
이 문제에서는 LFI(Local File Inclusion) 취약점을 생각하여 flag.php 파일에 접근할 수 있을것이다.
LFI(Local File Inclusion): 파일이 공격대상 서버에 위치하여 해당 파일에 접근하는 취약점
우리는 취약점도 알아내었고 접근해야하는 파일도 알아내었는데 그렇다면 어떻게 php 파일에 접근하여야 할까?
정답은 PHP Wrapper에 'php://filter/' 를 사용하여 서버내의 있는 php 파일을 열람할 수 있도록 해준다.
php://filter/convert.base64-encode/resource='파일명' 명령어를 통해 base64로 인코딩된 코드를 볼 수 있다.
www.php.net/manual/en/wrappers.php
PHP: Supported Protocols and Wrappers - Manual
Even though their names will be the same, you can have more than one //memory or //temp stream open concurrently; each time you fopen() such a stream, a NEW stream will be opened independently of the others.This is hinted at by the fact you don't add any u
www.php.net
base64로 인코딩된 코드를 디코딩해보면, FLAG 값을 알아낼 수 있고, 해당 값을 웹해킹 메인페이지에 Auth에 제출하면 문제를 해결할 수 있습니다.
<?php
echo "FLAG is in the code";
$flag = "FLAG{this_is_your_first_flag}";
?>
www.convertstring.com/ko/EncodeDecode/Base64Decode
Base64로 디코딩 - 온라인 Base64로 디코더
당신의 Base64로 여기에 텍스트를 디코딩 복사 파일로 디코딩 Base64로 다운로드 :
www.convertstring.com
감사합니다.