inflearn logo
강의

講義

知識共有

模擬ハッキングの実務者が知らせる、ファイルアップロードの脆弱性攻撃のテクニックと実務事例の分析:パート1

%00 사용하면 오류 발생

555

작성자 없음

投稿した質問数 0

1

<?
header("Content-Type: text/html; charset=UTF-8");

$gubun = $_GET["gubun"];
if(empty($_FILES["userfile"]["name"])){#클라이언트에 존재하는 파일의 원래 이름
    echo "<script>alert('파일을 업로드 하세요!');history.back(-1);</script>";
    exit();
}

$path = "./upload/";
$filename = $gubun."_".$_FILES["userfile"]["name"];#서버에 저장된 업로드된 파일의 임시 파일 이름



$file_info = pathinfo($path.$filename);
$ext = strtolower($file_info["extension"]);

$ext_arr = array("php""html""");

if(in_array($ext$ext_arr)){#파일 이름에 "php", "php3", "php5", "html", "htm" 확장자가 포함되어 있으면 예외처리(블랙리스트) 
    echo "<script>alert('허용되지 않은 확장자 입니다1.');history.back(-1);</script>";
    exit();
}

if(!move_uploaded_file($_FILES["userfile"]["tmp_name"], $path.$filename)){#$_FILES["userfile"]["tmp_name"](서버에 저장된 임시 파일)을 $path.$filename(업로드될 경로:upload/$filename)에 저장
    echo "<script>alert('파일 업로드에 실패하였습니다.');history.back(-1);</script>";
    exit();
}
?>

<li>업로드 성공 : <?=$path.$filename?></li>

------------------------------------------------------------------------------------------------------------

POST /null_ex1/upload.php?gubun=aa.php%00 HTTP/1.1

Host: 127.0.0.1:81

Content-Length: 1588436

Cache-Control: max-age=0

sec-ch-ua: "Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"

sec-ch-ua-mobile: ?0

Upgrade-Insecure-Requests: 1

Origin: http://127.0.0.1:81

Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryFJAvtYdjVBOAe0Td

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

Sec-Fetch-Site: same-origin

Sec-Fetch-Mode: navigate

Sec-Fetch-User: ?1

Sec-Fetch-Dest: document

Referer: http://127.0.0.1:81/null_ex1/index.php

Accept-Encoding: gzip, deflate

Accept-Language: ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7

Connection: close

------WebKitFormBoundaryFJAvtYdjVBOAe0Td

Content-Disposition: form-data; name="userfile"; filename="test.jpg"

Content-Type: image/jpeg

---------------------------------------------------------------------------------------------------------------

HTTP/1.1 200 OK

Date: Fri, 27 Aug 2021 15:23:45 GMT

Server: Apache

X-Frame-Options: SAMEORIGIN

X-Powered-By: PHP/7.4.7

Vary: Accept-Encoding

Content-Length: 282

Connection: close

Content-Type: text/html; charset=UTF-8

<br />

<b>Warning</b>:  move_uploaded_file() expects parameter 2 to be a valid path, string given in <b>C:\Bitnami\wampstack-7.4.7-0\apache2\htdocs\null_ex1\upload.php</b> on line <b>25</b><br />

<script>alert('파일 업로드에 실패하였습니다.');history.back(-1);</script>

모의해킹

回答 1

0

crehacktive

혹시 업로드 기능은 정상적으로 잘되나요? %00 없이 그냥 업로드 할 경우 파일 업로드는 잘 되나요?

톰캣 매니저를 통한 WAR 디플로이 실습에서 궁금한 점이 있습니다

1

424

1

APM 설치 환경 질문드립니다.

1

387

1

안녕하세요 포트관련 질문 드립니다!

1

281

1

안녕하세요 질문이 있습니다!

1

298

1

안녕하세요 질문이 있습니다

1

237

1

img_upload1 이미지 파일 업로드 오류(해결O)

1

632

1

bitnami 사용중인데 널바이트 입력 시 fatal error가 발생합니다

1

386

1

인코딩, cmd 파라미터 오류

2

346

1

jsp 업로드 기능 실행 시 오류가 발생합니다

1

781

1

upload_prob10 에러 문제

0

253

0

톰캣 매니저

1

400

1

업로드 경로가 이미지 or 파일서버일 경우 문의드립니다!

1

307

1

system.getProperty("os.name").toLowerCase() 실행이 안됨

1

369

1

IIS 세미콜론 취약점 대응방안

1

253

1

jsp 환경에서도 널바이트 공격이 가능한가요?

2

342

1

수업내용대로 진행했는데 적용이 안됩니다.

1

244

1

강의 내용 질문드립니다. (파일업로드 공격대상 탐색CASE(2)강의)

1

220

1

[실습4-14] 이미지 검증 우회 실습(2)

1

453

1

JSP 한글 깨짐

1

652

1

upload_prob10 설정 문제

1

865

1

system() 함수 결과값 한글 깨짐 현상

1

359

1

JSP 오류 뜹니다.

2

5147

2

선생님 ㅠㅠ 안됩니다.

1

3083

1

안녕하세요

2

197

1