[webhacking.kr] old-25 문제

2026. 1. 26. 16:22·워게임/webhacking.kr

1. 문제 정보

  • 문제 번호 : old -25
  • 문제 점수 : 15점
  • 문제 유형 : PHP wrapper

 


2. 문제 분석

25번 문제에 들어오면 아래 사진 처럼 나온다.  url을 보니 http://webhacking.kr:10001/?file=hello 이다.

아래 hello word는 입력하면 아무것도 안나온다.

 

 

 

페이지 소스 보기를 해보자 뭐 아무것도 없다.

<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=euc-kr">
<title>Challenge 25</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
textarea { background:silver; color:black; fnot-size:9pt; }
</style>
</head>
<body>
<pre>total 20
drwxr-xr-x 2 root root 4096 Dec 28 01:09 .
drwxr-xr-x 1 root root 4096 Dec 28 00:50 ..
-rw-r--r-- 1 root root   82 Aug 24  2019 flag.php
-rw-r--r-- 1 root root   31 Aug 24  2019 hello.php
-rw-r--r-- 1 root root  605 Aug 24  2019 index.php
</pre><hr><textarea rows=10 cols=100>hello world</textarea></body>
</html>

 


 

3. 풀이

 

url로 flag.php를 요청하려면 그냥 ?file=flag형식으로 요청하면 된다.

 

 

url에서 hello를 입력 받아서 hello.php를 요청하는 것 같다. 그러면 Flag is in the code가 나오는데 이건 Flag.php를 그대로가 아닌 실행해서 보여주기 때문이다.

 

php://를 wrapper라고 하는데 이걸 사용하면 내용을 인코딩 할 수 있다. 

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

 

이걸 그대로 요청하면 base64로 인코딩된 파일이 나타난다.

 

이 값을 base64 디코더를 사용해서 디코딩하면 아래 값이 나온다.

 

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

 

일반적인 include 함수는 파일을 가져와서 PHP 코드로 해석하여 실행한다. 서버 코드에는 iclude(file.php)이런 식으로 되어 있어

?file=flag를 했을 때 플래그가 보이지 않는다. 그냥 변수로 들어가 있기 때문이다. 

 

 

php://filter 스트림은 데이터가 include 함수로 넘겨지기 전에 데이터를 가공합니다. 여기서 Base64 인코딩을 거치면, PHP 태그(<?php ... ?>)가 깨져서 문자로 인식되므로 서버는 이를 실행하지 않고 단순 문자열로 출력하게 된다


4. 요약

  • file 파라미터가 사용자 입력을 받아 파일을 호출할 때, flag를 입력하면 flag.php가 서버 측에서 실행되어 소스 코드를 볼 수 없는 문제이다.
  • 이를 우회하기 위해 PHP Wrapper인 php://filter/convert.base64-encode/resource=flag를 사용하여 소스 코드를 실행하지 않고 Base64로 인코딩하여 출력했다.
  • 출력된 Base64 문자열을 디코딩하여 flag.php의 원본 소스 코드를 확인하고 그 안에 숨겨진 플래그를 획득했다.

 

'워게임 > webhacking.kr' 카테고리의 다른 글

[webhacking.kr] old-58 문제  (0) 2026.01.26
[webhacking.kr] old- 19문제  (0) 2026.01.26
[webhacking.kr] old-27 문제  (0) 2026.01.26
[webhacking.kr] old-31 문제  (0) 2026.01.23
[webhacking.kr] old-39 문제  (0) 2026.01.23
'워게임/webhacking.kr' 카테고리의 다른 글
  • [webhacking.kr] old-58 문제
  • [webhacking.kr] old- 19문제
  • [webhacking.kr] old-27 문제
  • [webhacking.kr] old-31 문제
yt_5246
yt_5246
yt5246 님의 블로그 입니다.
  • yt_5246
    yt의 공부 블로그
    yt_5246
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
    • 분류 전체보기 (61)
      • IT (1)
      • Security (11)
        • 시스템해킹 (3)
        • 리버싱 (6)
        • 암호학 (0)
        • tools (2)
      • Book (0)
      • 자격증 (3)
      • 워게임 (46)
        • DVWA (7)
        • WebGoat (4)
        • webhacking.kr (35)
      • 버그바운티 (0)
  • 인기 글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
yt_5246
[webhacking.kr] old-25 문제
상단으로

티스토리툴바