웹마스터 팁
htaccess 보안 팁
2015.02.24 16:20
#1 기초적인 프록시 차단
프록시 서버를 100% 막아낼 수 있는 방법은 없다. 프록시 서버를 구현하는 방법이 너무 많고, 새로운 기법이 하루가 다르게 생겨나고 있기 때문이다. 예를 일본 츠쿠바 대학 모 연구팀에서는 "프록시가 아니면서 프록시 기능을 하는 새로운 개념"을 얼마전에 만들어서 테스트하고 있다. 나도 이 프록시에 대해 테스트를 해보았지만 이를 프록시로 탐지하는 것은 아직 불가능한 것 같다. 이 정도로 프록시 기술을 빠르게 변화하고 있는데 htaccess로 프록시를 완전 차단한다는 것은 말이 되지 않는다. 하지만, 아주 전형적이고 좀 철지난 프록시 방식을 통해 들어오는 접근이라도 htaccess를 통해 차단해 줄 필요는 있다. 다음의 코드가 프록시를 통한 접근을 막는데 약간의 도움은 줄 것이다.
RewriteEngine on RewriteCond %{HTTP:VIA} !^$ [OR]
RewriteCond %{HTTP:FORWARDED} !^$ [OR]
RewriteCond %{HTTP:USERAGENT_VIA} !^$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} !^$ [OR]
RewriteCond %{HTTP:PROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
RewriteCond %{HTTP:HTTP_CLIENT_IP} !^$ RewriteRule ^(.*)$ - [F]
#2 접속하는 브라우저 정보에 따른 차단
사이트의 로그파일을 분석해보고, 특정 user-agent(브라우저 정보)에서 의심스러운 정황이 보인다면 아예 그 브라우저 정보를 가진 접근을 막아야 할 필요가 있다. 아래코드는 그 샘플이다. user-agent에 특정 스트링이 포함되면 차단하고 싶을 경우에는 RewriteCond %{HTTP_USER_AGENT} ^.*특정스트링.* [NC,OR] 을 사용하면 된다.
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^.*Transmission.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Ezooms.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^ HuaweiSymantecSpider [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Localbot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*MJ12bot.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Sosospider [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Talk Talk.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Trend Micro [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Vagabondo.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*YandexBot.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*YandexMedia.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*torrent.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*uTorrent.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*iLOVECZ.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*BTwebclient.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Bittorrent.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*BitComet.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} ^HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule .* - [F,L]
일부 간악한 자들이, 보안에 취약한 사이트를 찾아서 토렌트 트래커 서버로 악용하려는 피도 눈물도 없는 공격이 있을 수 있다. 집에서 토렌트로 뭐 하나 받아도 컴퓨터가 엄청 느려지는데 내 사이트가 들어있는 서버를 트래커서버로 돌려버린다면... 상상만 해도 아찔하다. 그래서 토렌트 프로그램의 user-agent 스트링을 포함하면 차단하게 하였다. 위의 코드 윗쪽에 torrent, utorrent, bitcomet 등이 들어있는 줄을 참고.
RewriteEngine on 이것은 계속 중복할 필요가 없다. 그리고 조건문의 마지막줄에는 [OR]을 빼야하는 것이 중요. 위의 코드예의 경우 마지막 조건문을 RewriteCond %{HTTP_USER_AGENT} ^Zeus [OR]로 해버린다면, 모든 접근이 다 차단되어버리니 조심해야 한다.
사이트 수정하다 생기는 00000.php.bak
액세스를 차단
<FilesMatch "\.bak">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
<FilesMatch "\.config">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
<FilesMatch "\.sql">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
댓글 0
제목 | 글쓴이 | 날짜 |
---|---|---|
검색엔진 네이버 사이트 순위 SEO 검색엔진 최적화 작업해도 안 올라간다면..
[1]
![]() | CJM | 2022.05.16 |
여러가지 프로토타이핑 툴 [1] | 드래그홈 | 2014.03.26 |
불법광고 댓글 | greentown | 2021.05.18 |
RSS를 활용한 HelloMaster 홈페이지 새글 알리미 설정하기
[3]
![]() | 퍼니온 | 2009.08.16 |
content 위젯에서 태그로 글 뽑기 | 날아올라 | 2021.02.07 |
[PHP] 이름 및 연락처 마스킹 처리 [1] | ppumweb | 2018.05.21 |
Windows10 에서 IIS + mysql + PHP 설치
[10]
![]() | HSJI | 2014.07.21 |
코드 이미지 생성해주는 사이트
[2]
![]() | reactux | 2019.10.06 |
XE를 다른디렉토리에 설치후 리다이렉트하기 | 디자인플렉스 | 2020.04.24 |
게시판 글 엑셀로 출력하기(확장변수 포함) [15] | 한이73 | 2014.07.17 |
관리자 아이디/비번을 잃어버렸을때, 관리자페이지 접속을 못할 때 TIP
[1]
![]() | 플레이웹 | 2019.08.13 |
커뮤니션 쪽지 보내기 기능을 모바일 에서 실행시 로그인 풀림 현상 | 인천한량 | 2020.04.14 |
nginx 에서 서브도메인 사용시 로그인유지방법 [3] | garnecia | 2014.02.26 |
IIS에서 HTTPS를 사용하기 위한 SSL설정 (letsencrypt 인증서 설치, 갱신)
![]() | ehii | 2016.04.13 |
AI 개발에 적합한 5가지 프로그래밍 언어 | ppumweb | 2020.01.06 |
날씨배너 600종류 입니다.(지역별75종X색상별8종)
![]() | 푸른커튼 | 2008.01.30 |
대부분 쉬운설치로 인해 홈페이지 빈 페이지가 뜨는 에러는.. | CJM | 2019.10.24 |
xe 기본회원가입품 연락처항목 공백&숫자 유효성검사 질문입니다. | 해운거사2 | 2019.08.25 |
[주옥시리즈] 내글 모니터링, 작성글 앞으로 뺴기 [6] | socialskyo | 2013.10.18 |
회원가입품 연락처항목 공백잇을시 질문입니다. | 해운거사2 | 2019.08.16 |