본문 바로가기

Server

Upload Directory Exec Control

일반 파일이 업로드 되는 업로드 디렉터리에는 Server-Side-Script가 실행될 이유가 없다. 

실행권한이 있을 경우 공격자는 웹쉘 업로드를 통해 공격이 가능하게 된다. 

실행권한을 제거하거나, PHP로 Parsing되지 않게 처리하는 법 등 다양하나, 아래 몇가지만 소개한다. 

※ apache FileInfo 인자를 이용한 방법
[root@ns1 /home/test]# cat > .htaccess << EOF
> php_value engine off
EOF
[root@ns1 /home/test]# chmod 644 .htaccess



 apache RemoveType 인자를 이용한 방법
<Directory "/home/test/">
        RemoveType .html .html .php .php3
</Directory> 


※ Files 지시자를 이용한 방법
<Directory "/home/test/">
   <Files ~ “[.]([Pp][Hh][Pp]|[Pp][Hh][Pp]3|[Hh][Tt][Mm][Ll]?|[Cc][Gg][Ii])[.]*$”>
      Forcetype text/html
   </Files>
</Directory> 


※ DirectoryMatch 지시자를 이용한 방법
   <DirectoryMatch "^/.*/testid/bbs/(data|tmp|icon)">
      AddType application/x-httpd-php3-source .phps .php .ph .php3 .cgi .sh .pl .html .htm .shtml .vbs .ins 
      AddType application/x-httpd-php-source .phps .php .ph .php3 .cgi .sh .pl .html .htm .shtml .vbs .ins 
  </DirectoryMatch>


※ php_admin_flag 지시자를 이용한 방법
   <Directory ~ "/home/testid/htdocs/bbs/(data|tmp|icon)">
       php_admin_flag engine off 
   </Directory>


'Server' 카테고리의 다른 글

Reverse RDP  (0) 2015.09.24
Intel S3420GP Datasheet  (0) 2015.08.16
Set Throttling Mode(CLTT,OLTT)?  (0) 2015.08.01
리눅스/유닉스/OSX 파일 확장자 변경  (0) 2015.02.18
문자열 인코딩 명령어 'iconv'  (0) 2014.08.31