Scanning heartbleed bug with the nmap NSE script
สืบเนื่องจาก Heartbleed Bug: OpenSSL Security Flaw ซึ่งทำให้บริการที่ใช้ secure protocol ที่ใช้งาน OpenSSL 1.0.1 เกิดความไม่ปลอดภัยอีกต่อไป
จากเหตุการณ์เช่นนี้ทำให้ผู้ดูแลระบบที่มีการใช้ OpenSSL ต้องทำการตรวจสอบระบบของตนเองว่ามีช่องโหว่ตรงส่วนนี้หรือไม่ ซึ่งถ้าหากมีอยู่จำนวน server อยู่ไม่มากก็สามารถตรวจสอบและแก้ไขได้ง่าย แต่สำหรับผู้ดูแลระบบที่ต้องดูแล server จำนวนมากก็จะต้องใช้เวลาในการตรวจสอบค่อนข้างนาน
ในบทความนี้ผมนำเสนอวิธีที่จะทุ่นเวลาให้กับผู้ดูแลระบบที่ต้องการตรวจสอบ server ของตนเองแบบคร่าวๆ ว่าได้รับผลกระทบจาก Heartbleed Bug หรือไม่ ซึ่ง script จะทำงานโดยเข้าไปเชคว่ามี Heartbeat ใช้งานหรือไม่
วิธีการติดตั้งและใช้งานจะใช้ nmap จะพูดถึงแค่ CentOS 6 นะครับ
Install ssl-heartbleed และ update nmap server
ให้ทำการ copy script ด้านล่างนี้ และรัน เพื่อติดตั้ง ssl-heartbleed script และ update nmap server
#!/bin/bash
red='\e[0;31m'
NC='\e[0m' # No Color
echo -e "${red}Install Atomic repo${NC}"
rpm -ivh http://updates.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/atomic-release-1.0-18.el6.art.noarch.rpm
echo -e "\n${red}Update NMAP to version 6.40${NC}"
yum install nmap --enablerepo=atomic -y
if [ ! -e ~/ssl-heartbleed.nse ]; then
echo -e "\n${red}Get ssl-heartbleed.nse ${NC}"
cd ~ && wget https://svn.nmap.org/nmap/scripts/ssl-heartbleed.nse
fi
if [ ! -e /usr/share/nmap/nselib/tls.lua ]; then
echo -e "\n${red}Get TLS NSELib ${NC}"
wget https://svn.nmap.org/nmap/nselib/tls.lua -O /usr/share/nmap/nselib/tls.lua
fi
Run nmap with ssl-heartbleed script for scan your network
หลังจากรัน script ด้านบนเรียบร้อยแล้วให้รันคำสั่งด้านล่าง เพื่อทำการ scan https
nmap -p 443 --script ~/ssl-heartbleed.nse 192.168.0.100
Note:
1. ถ้าหากต้องการ scan port อื่นด้วยก็สามารถกำหนดได้ หรือลบ -p 443 ออกเพื่อ scan port อื่นๆ
2. สามารถกำหนด IP เป็น class ได้ เช่น 192.168.1.0/24
Result
ผลลัพธ์การ scan บน server ที่มีความเสี่ยงจาก Heartbleed Bug
Nmap scan report for 192.168.0.100
Host is up (0.00035s 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:
| https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160
| http://cvedetails.com/cve/2014-0160/
|_ http://www.openssl.org/news/secadv_20140407.txt
MAC Address: 00:55:55:95:1B:50 (VMware)