Web Hacking/Webhacking.kr

Webhacking.kr old-25 풀이 (php wrapper)

프레딕 2023. 11. 21. 23:45
728x90

처음 접속하면 hello.php로 접속되는 것을 볼 수 있다. 

일단 flag를 찾아야 하니 flag.php로 접속해보면 

별반 중요한 내용이 들어있지는 않다.

유추해 볼 수 있는점은 .php가 자동으로 붙는다는 점이고 flag.php의 내용을 파악해야 한다는 점이다.

버프스위트도 돌려보고 혼자 해보다 안돼서 찾아보니 php wrapper를 사용해야 한다고 한다.

https://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

php wrapper는 lfi(Local File Inclusion) 취약점 중 하나로 파일이 공격대상의 서버에 위치할 때 사용할 수 있다.

대표적으론 세가지 종류가 있다.

1. expect://

expect는 system command 를 실행시켜 준다.

expet://[command] 와 같이 사용한다.

 

2. php://filter

io stream을 다루는 사용하는 wrapper로 

php://filter/convert.base64-encode.resource=[file] 와 같이 사용한다.

 

3. zip://

zip파일의 압축을 풀고 압축을 푼 파일의 코드를 실행시켜준다.

zip://file.zip#[file] 와 같이 사용한다.

 

이 중 우리가 사용해야 할 것은 flag.php의 내용을 알아야 하기 때문에 2번을 사용하면 될것 같다.

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

 

Challenge 25

 

webhacking.kr:10001

다음과 같은 주소를 입력하면 base64로 인코딩 된 문자를 얻을 수 있다. 

디코딩 해보면 flag를 얻을 수 있다.

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

728x90
반응형