티스토리 뷰

웹 해킹/취약점

php include, wrapper 취약점

삼전동해커 2020. 9. 14. 19:21

출처 : https://dreamhack.io/learn/15#39

https://blackperl-security.gitlab.io/blog/2018/08/10/2018-08-10-aswj-03/


php include 취약점


php의 Include 함수는 인자로 전달된 파일을 읽은 후 해당 파일의 내용을 출력한다. 파일의 내용 중 php 코드 구문이 존재하면 해당 코드를 실행 한다.


include함수는 동적으로 다른 php 페이지를 로드해야할 때 사용한다.


include 함수는 파일의 확장자 또는 파일의 타입과는 상관없이 파일의 내용의 php 코드를 실행시킨다.


<예제>


php wrapper

wrapper란 감싸다 라는 의미인데, 코드나 데이터를 둘러싸다. 정도의 의미를 갖겠다.


파일 시스템 관련 함수(ex:include(),fopen())로 filename이 사용자의 입력이 될 경우 php에 존재하는 wrapper를 사용해 개발자의 의도와 다른 행위를 발생시킬 수 있다.


http:// 도 사실 url 형식의 wrapper이다.


wrapper의 종류

1.expect://


system command를 실행해 준다.


ex) http://www.test.com/?page=expect://ls


2.php://filter


다양한  In/Out stream을 다룬다.


ex) http://www.test.com/?page=php://filter/convert.base64-encode/resource=/etc/passwd


convert.base64-encode : 데이터를 base64로 인코딩

resource : 필터링할 stream을 명시한다.



3.zip://


zip 파일의 압축을 풀고, zip 파일 안에 들어있는 특정 파일을 실행한다.


ex) http://www.test.com/?page=zip://file.zip#shell.php



4.php://stdin, php://stdout and php://stderr


stdin, stdout, stderr로 연결.



5.php://fd/<fd number>


파일 디스크립터에 연결한다.



6.php://input


http의 body,즉 post 데이터를 입력받는다.



file_get_contents를 이용해 웹 상의 파일을 읽을 수 있다.






'웹 해킹 > 취약점' 카테고리의 다른 글

type juggling  (0) 2020.09.18
eval 함수  (0) 2020.09.15
serialize()함수 취약점(2) python  (0) 2020.09.14
serialize()함수 취약점(1) php  (0) 2020.09.14
strcmp 취약점  (0) 2020.09.09
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함