file down load
파일 다운로드 기능을 가진 웹 어플리케이션에서 파일명이 제대로 검사되지 않는 경우
Directory Traversal 등에 의해 다른 위치에 있는 파일도 다운로드 가능
부적절한 환경설정에 의해 Source code 파일이나, backup 파일등이 다운로드 가능
ex) 개발자의 편의상 사용하는, .inc .txt .bak 등의 확장자를 제어하지 않는 경우 다운로드 가능
파일 다운로드 로직
1. 절대 경로 -> 개발자의 부주의
2. 상대 경로 -> 어플리케이선의 취약점
윈도우의 경우 : ../../../../../boot.ini
..%2F..%2F..
..%5C..%5C
------------
방문자에게 허용된 파일외의 다운로드
웹서버의 소스 및 기밀문서 다운로드
FileDownload 기능의 웹 어플리케이션에서 파일명 필터링 못할 경우
우회 URL 요청
.../filedownload.php?path=../../../../../../../../../etc/passwd
------------
1.jpg 를 다운 받을때 확장자를 넣을때 소문자만 인식하면 리눅스 계열이다 라는 팁
http://192.168.0.75/board/pds/예제.jpg
http://192.168.0.75/../../../../../../board/dbconn.inc
dbconn.inc : 시스템 부팅정보 파일
<%
Set objconn = Server.CreateObject("ADODB.Connection") objConn.Open "PROVIDER=SQLOLEDB; DATA SOURCE=(local); INITIAL CATALOG=board; USER ID=sa; PASSWORD=111111" %>
-> 소스 유출
-------------------
방어 소스
<?
ob_start();
$filename = $_GET['path'];
$filename = trim($filename);
$dir = "c:\apm_setup\htdocs\data";
if(strstr($filename,"../")||strstr($filename,"..%2f")) //문자 존재 여부
{
echo "<script>alert("잘못된 경로입니다.")</script>";
echo "<script>location.href('/index.html')</script>";
exit();
}
//추가된 부분 (방어 소스) -> 다운로드 경로 입력받을 시에 서버에서 문자열 필터링을 함
if(file_exists($dir.$filename))
{
Header("Content-Type: application/octet-stream");
Header("Content-Disposition: attachment;; filename=$filename");
Header("Content-Transfer-Encoding: binary");
Header("Content-Length: ".(string)(filesize($dir.$filename)));
Header("Cache-Control: cache, must-revalidate");
Header("Pragma: no-cache");
Header("Expires: 0");
$fp = fopen($dir.$filename, "rb");
while(!feof($fp)) {
echo fread($fp, 100*1024);
}
fclose ($fp);
flush();
}
else{
echo "<script>alert(\"File not found.\");</script>";
echo "<script>location.href('/index.html')</script>";
}
?>
-----------
쿠키 변조
정보수정을 통한 서비스 접근
본인의 쿠키값을 가지고 변조
방어 : 중요한 정보값은 세션으로 검증해야함
쿠키값을 가지고 검증하지 않도록 함
http://61.76.181.76/cookie/index.php
rot-13 암호화 방식
---------
sql injection
'Web' 카테고리의 다른 글
sql injection (0) | 2014.11.12 |
---|---|
SQL Injection (0) | 2014.11.11 |
webshell and defense of it (0) | 2014.11.06 |
CSRF (0) | 2014.11.05 |
CSRF (0) | 2014.11.04 |