2024-04-16 18:05 (화)
nmap으로 heartbleed취약성 여부 대량으로 빠르게 스캔하는 방법
상태바
nmap으로 heartbleed취약성 여부 대량으로 빠르게 스캔하는 방법
  • 홍석범
  • 승인 2014.04.11 16:26
이 기사를 공유합니다

무료 스캔 프로그램 nmap Scripting Engine 활용...빠르게 취약성 여부 확인 가능

최근 공개된 OpenSSL의 heartbleed 취약성과 관련해 웹사이트나 script 등 취약성 여부를 확인할 수 있는 툴들이 공개되었는데, 만약 관리하는 시스템의 규모가 커서 일괄적으로 취약성 여부에 대한 스캔을 해야 할 경우 많은 시간이 소요되는 등 어려움이 있을 수 있다. 이때 대표적인 무료 스캔 프로그램인 nmap의 Scripting Engine(NSE)기능을 활용하면 빠르고 간단히 취약성 여부를 확인할 수 있다. 이에 구체적인 활용 방법에 대해 설명하고자 한다.
 

먼저 nmap 프로그램은 http://nmap.org/download.html 에서 Windows, Linux 등 여러가지 OS환경에서 다운로드하여 설치가 가능하다. 만약 Linux 환경이라면, rpm등 패키지로 설치하거나 root 권한으로 아래와 같이 실행하면 간단히 설치할 수 있다.

$ wget http://nmap.org/dist/nmap-6.40.tar.bz2
$ bzip2 -cd nmap-6.40.tar.bz2 | tar xvf -
$ cd nmap-6.40
$ ./configure
$ make;  make install
 

이후, 아래와 같이 관련 파일을 다운로드한 후 db 를 업데이트해 준다. (시스템에 따라 경로는 /usr/share/nmap/ 일 수 있다.
 

$ cd /usr/local/share/nmap/nselib/
$ wget https://svn.nmap.org/nmap/nselib/tls.lua
$ cd /usr/local/share/nmap/scripts/
$ wget https://svn.nmap.org/nmap/scripts/ssl-heartbleed.nse
$ nmap --script-updatedb
 

모든 준비가 완료되었다. 이제 아래와 같이 실행하면 해당 서버의 heartbleed 취약성 여부를 간단히 확인할 수 있다.
 

$ nmap --script ssl-heartbleed  www.example.com
 

위의 경우 여러 well known 포트를 스캔하는데, 만약 https(443/tcp)와 같이 특정 port만 체크하고자 한다면 아래와 같이 -p 옵션을 주면 좀 더 빠르게 결과를 알 수 있다.
 

#   nmap --script ssl-heartbleed  www.example.com -p 443
 

이때, 아래와 같이 단순히 포트오픈에 대한 정보만 나오면 heartbleed 취약성이 없는 것을 의미한다.
 

PORT    STATE SERVICE
443/tcp open  https
 

하지만 취약할 경우 아래와 같이 오픈된 포트외 ssl-heartbleed: VULNERABLE: 이라는 메시지가 출력된다.
 

Nmap scan report for www.example.com
Host is up (0.26s latency).
PORT    STATE SERVICE
443/tcp open  https
| ssl-heartbleed:
|   VULNERABLE:
|   The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library. It allows for stealing information intended to be protected by SSL/TLS encryption.
|     State: VULNERABLE
|     Risk factor: High
|     Description:
|       OpenSSL versions 1.0.1 and 1.0.2-beta releases (including 1.0.1f and 1.0.2-beta1) of OpenSSL are affected by the Heartbleed bug. The bug allows for reading memory of systems protected by the vulnerable OpenSSL versions and could allow for disclosure of otherwise encrypted confidential information as well as the encryption keys themselves.
|
|     References:
|       http://www.openssl.org/news/secadv_20140407.txt
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160
|_      http://cvedetails.com/cve/2014-0160/
 

아울러, C Class(/24) 대역내에 heartbleed에 취약한 서버가 있는지에 대한 스캔을 하고자 한다면 아래와 같이 IP 대역으로 스캔을 하면 된다. 


$ nmap --script ssl-heartbleed 192.168.1.0/24
 

nmap이외 취약성스캐너인 nessus에서도 heartbleed 취약성 스캔기능을 제공하고 있는데, 이에 대해서는 아래 URL을 참고하면 된다.
https://discussions.nessus.org/thread/7274

[글. 홍석범 씨디네트웍스 시스템 UNIT 부장 / antihong@gmail.com]