타이거팀 (번역 아티클)

NMAP & WAFW00F 웹방화벽 특정하기 본문

테크아티클번역

NMAP & WAFW00F 웹방화벽 특정하기

타이거팀 2017. 11. 19. 13:54

NMAP & WAFW00F – Identifying a web application firewall

Web App Penetration Testing – Identifying a web application firewall

원문주소: https://goo.gl/DYKrpE

 

nmap과 wafw00f로  웹방화벽 특정화하기

 

A web application firewall (WAF) is a device or a piece of software that checks packages sent to a web server in order to identify and block those that might be malicious, usually based on signatures or regular expressions.

 

웹방화벽은 (WAF)는 웹서버 팜의 상단에 위치하면서 웹서버로 보내는 접속을 감시하고, 보통 미리 잘짜여진 시그니처 패턴을 기반으로 통신 접속중 악성코드를 특정화하고 차단하기위한 솔루션 장비나 소프트웨어를 말합니다.  


We can end up dealing with a lot of problems in our penetration test if an undetected WAF blocks our requests or bans our IP address. When performing a penetration test, the reconnaissance phase must include the detection and identification of a WAF, intrusion detection system (IDS), or intrusion prevention system (IPS). This is required in order to take the necessary measures to prevent being blocked or banned.

만약 모의침투를 수행하는 도중에 전혀 감지 불가능한 웹방화벽 장비(WAF)가 우리의 요청을 차단하거나, IP주소를 더이상 접근하지못하게 금지시킨다면 모의침투 테스트는 이것저것 시도도 못해보고 바로 종료될 수 있겠죠. 

모의 침투 테스트를 수행할 때, 장비에 의해서 블럭당하거나 금지당하는 조치를 당하기 전, 정찰 단계 (reconnaissance phase)에서 타겟의 방어수단인 웹방화벽(WAF), 침입 방지 시스템(IPS) 또는 침입 탐지 시스템(IDS)의 존재까지 탐지하고 특정화시키는걸 염두에 두어야 합니다.

 

In this recipe, we will use different methods, along with the tools included in Kali Linux, to detect and identify the presence of a web application firewall between our target and us.

이 튜토리얼에서는 칼리리눅스에 들어있는 툴과 제공되는 다른 방법들을 사용해 타겟의 웹 방화벽 장비나 웹방화벽 소프트웨어의 존재를 특정화하고 탐지할 것입니다.

 

How to do it…

Nmap includes a couple of scripts to test for the presence of a WAF. Let’s try some on our vulnerable-vm:

nmap은 웹방화벽 존재를 알아내는데 다음과 같은 스크립트를 사용합니다. 

메타스플로잇2 같은 취약한 가상머신이 있다면 한번 테스트해보세요

 

root@debian9: /home/tiger # nmap -p 80,443 --script=http-waf-detect 192.168.56.102

 

 

 

 

이건 ../../../../../../../../../etc/passwd 란  페이로드를 보내서 해당사이트가 IDS/IPS/WAF를 사용하고 있음을 특정했죠?

 

보통 no WAF is detected 

라고 나오면 다면 해당사이트는 웹방화벽이 검출되지 않는다는 뜻인데, 웹방화벽 탐지가 안되서 나타나지않는 경우가 더 많습니다. 오탐도 있고, 액면 그대로 믿으면안됩니다.

 

 

2. Now, let’s try the same command on a server that actually has a firewall protecting it.

Here, we will use example.com; however, you may try it over any protected server.

 

실제로 방화벽으로 보호되는 서버에서 동일한 명령을 실행해 봅시다.

먼저 imperva.com 을 사용할건데 다른 보호되는 서버를 사용해봐도 되겠죠?

 

root@debian9 : /home/tiger# nmap -p 80,443 --script=http-waf-detect www.imperva.com

 

아래 그림의 중간에 보시면 script alert (document. cookie) /script 라는 페이로드를 보내서 해당사이트가 IDS/IPS/WAF를 사용하고 있음을 특정했죠?

 

 


 

Imperva is one of the leading brands in the market of web application firewalls; as we can see here, there is a device protecting this site.

임퍼바(Imperva)는 웹 방화벽 시장에서 선두 브랜드 중 하나라고 하는데, 이 회사 웹사이트엔 당연히 자사의 사이트를 보호하는 웹방화벽 장치가 있겠죠? 사실 한국에선 이 브랜드는 잘 볼 수는 없습니다. 한국에는 파이오링크나 와플, 모니터랩쪽이 시장을 장악하고있어서 저는 사실 본적이 없습니다.  안랩에만 해도 DDOS나 IPS는 있지만, 웹방화벽 제품은 따로 없어요

 

3. There is another script in Nmap that can help us to identify the device being used, more precisely. The script is as follows:

nmap에는 웹방화벽장비를 보다 더 정확하게 특정화시켜주는 또 다른 스크립트가 또 있습니다.

 

root@debian9: /home/tiger # nmap -p 80,443 --script=http-waf-fingerprint www.imperva.com

 

 

 

 

* TIPS 한가지 더

초보자용 입문서인 문성호씨의 <어서와 해킹은 처음이지?> 책에서도 Wafw00f를 잠깐 소개하고있습니다. 

굳이 책을 살 필요까진 없고, 맛보기 형태로 휴티블로그에 4장까진 미리 공개되어있으니 그냥 보시면 됩니다.

 

* 휴티 블로그중 wafw00f 소개부문  

http://blog.naver.com/agboy/220888698893

 

아파치 프로젝트중 MODSecurity 를 이용하는 사이트를 탐지한 모습입니다.

 

 

WAFW00F – Kali Linux

칼리의 WafW00f

 

WAF detection works by sending specific requests to servers and then analyzing the response;  for example, in the case of http-waf-detect, it sends some basic malicious packets and compares the responses while looking for an indicator that a packet was blocked, refused, or detected.

The same occurs with http-waf-fingerprint, but this script also tries to interpret that response and classify it according to known patterns of various IDSs and WAFs. The same applies to wafw00f.

웹방화벽의 탐지 기능은 특수한 요청을 웹서버에 전송한 후 응답을 분석하여 작동합니다.

예를 들어, http-waf-detect의 경우 기본적으로 기본적인 몇개의 악성 패킷을 보내고, 응답을 차단하거나, 패킷이 차단되거나, 거부되었거나 탐지되는 지표를 찾습니다. 동일한 방법으로 http-waf-fingerprint은 탐지 방식은 같겠지만, 응답을 해석하면서 다양한 IDS및 웹방화벽의 알려진 패턴들에 따라 분류합니다.

wafw00f에서도 똑같이 적용됩니다.

 

데비안리눅스 9에서 직접 wafw00f 패키지를 더 설치해서 테스트했습니다.

wafw00f를 넣어보고, 설치가 안되어있어서 apt-get install 명령으로 인스톨합니다.

root@debian9 :/home/tiger#  apt-get install wafw00f  

 

 

 

 

데비안리눅스 9 에서 Wafwoof를 테스트합니다  

root@debian9 :/home/tiger#  wafw00f  www.imperva.com

 

 

 

 

 The site http://imperva.com is behind Incapsula WAF 라고 결과물이 보입니다.

아까 nmap에서 http-waf-fingerprint 옵션을 준 결과랑 비교해보세요