網絡攻擊測試方法和工具簡介
目錄
網絡攻擊測試方法和工具簡介 1
說明 1
漏洞檢測 1
掃描系統漏洞 2
網絡攻擊檢測和防護 3
攻擊模擬 3
攻擊防護 5
說明
本文檔內容根據網絡上關於網絡攻擊測試方法和工具進行了分類整理,歸納出最適用於漏洞檢測和 DDOS 攻防測試工具。本文中出現的工具大部分屬於開源和可以免費獲取到的網絡工具。
漏洞檢測
目前針對漏洞檢測的工具分為兩大類:
- 網絡安全公司開發的收費軟件
- 開源愛好者和組織開發的免費軟件
一般收費軟件更新速度快,能夠根據漏洞數據庫掃描出最新的漏洞;而免費工具基本很少更新,基本上只能掃描到一些基本的漏洞。
著名收費漏洞掃描軟件,國內有:綠盟,知道創宇,360,軟件均無法免費獲得,需購買。
著名收費漏洞掃描軟件,國外:Nessus,OpenVAS, Core Impact。
免費漏洞掃描軟件:國內無,國外有 nmap, Retina, Nipper。
經測試使用,nmap 數據庫比較新,能夠實用。
掃描系統漏洞
以普通 Linux 系統為例:
-
從官網下載最新 nmap 7 源代碼,https://nmap.org/download.html.
-
解壓源代碼到本機
bzip2 -cd nmap-.tar.bz2 | tar xvf – -
進入源碼目錄
cd nmap- -
配置源碼
./configure
配置完成成功后,會有 ASCII 界面 -
編譯並安裝
make
su root
make install -
下載漏洞掃描腳本
git clone https://github.com/scipag/vulscan.git -
將腳本拷貝到 nmap script 目錄
cp vulscan /usr/share/nmap/scripts/ -r -
執行目標機掃描
本例,以局域網內 Linux 機器掃描:
nmap --script vulscan --script-args vulscandb=cve.csv -sV 10.56.56.236
掃描到的結果和 CVE 漏洞編號將打印在終端:
網絡攻擊檢測和防護
目前針對網絡設備的攻擊主要是拒絕服務攻擊(DoS)。針對 DoS 的工具測試工具主要有:
- 網絡測試儀
- 網絡愛好者開發的免費工具
- 專業網絡安全工作人員的專用工具
其中 網絡測試儀是一種能夠產生任何需要的測試數據包的網絡硬件,能夠根據需要定制測試項目,但是價格昂貴。
專業工具一般都是收費軟件,網絡上較難獲取到。
攻擊模擬
本文使用免費的工具 HYENAE,該工具最后更新時間是 2010-12-04
該工具可以自定義模擬執行所有的 DoS 攻擊:
Features
• ARP-Request flooding
• ARP-Cache poisoning
• PPPoE session initiation flooding
• Blind PPPoE session termination
• ICMP-Echo flooding
• ICMP-Smurf attack
• ICMP based TCP-Connection reset
• TCP-SYN flooding
• TCP-Land attack
• Blind TCP-Connection reset
• UDP flooding
• DNS-Query flooding
• DHCP-Discover flooding
• DHCP starvation attack
• DHCP-Release forcing
• Cisco HSRP active router hijacking
• Pattern based packet address configuration
• Intelligent address and address protocol detection
• Smart wildcard-based randomization
• Daemon for setting up remote attack networks
• HyenaeFE QT-Frontend support
經測試,在 Windows 10 系統正常運行,並成功發出自定義攻擊數據包。
以 ARP 請求風暴為例:
WireShark 顯示系統發出大量 ARP 請求數據包請求地址 10.56.56.236:
攻擊防護
Dos 攻擊主要靠流量取勝,流量決定攻擊和防護的輸贏。所以為了保證正常業務的運行,保證正常通信流量是唯一途徑。針對攻擊的類型,可以采用一些基本的防護措施:
- 針對 TCP SYNC 攻擊
優化sysctl內核 tcp 參數,並提高 tcp 連接能力 - 主動丟棄異常數據包
- 使用腳本和專用 DoS 防火牆阻擊工具數據包
其中針對 CentOS 的防火牆配置防 DoS 功能:
CentOS7 默認是用 Firewall 配置防火牆,但是 Firewall 功能有限,建議使用 DoS Deflate 防御 DoS 攻擊:
停用 Firewall:
systemctl stop firewalld
安裝命令:
wget http://www.inetbase.com/scripts/ddos/install.sh
chmod 700 install.sh
./install.sh
卸載命令:
wget http://www.inetbase.com/scripts/ddos/uninstall.ddos
chmod 700 uninstall.ddos
./uninstall.ddos
2、配置DDoS deflate
下面是DDoS deflate的默認配置位於/usr/local/ddos/ddos.conf ,內容如下:
Paths of the script and other files
PROGDIR="/usr/local/ddos"
PROG="/usr/local/ddos/ddos.sh"
IGNORE_IP_LIST="/usr/local/ddos/ignore.ip.list" //IP地址白名單
CRON="/etc/cron.d/ddos.cron" //定時執行程序
APF="/etc/apf/apf"
IPT="/sbin/iptables"
frequency in minutes for running the script
Caution: Every time this setting is changed, run the script with --cron
option so that the new frequency takes effect
FREQ=1 //檢查時間間隔,默認1分鍾
How many connections define a bad IP? Indicate that below.
NO_OF_CONNECTIONS=150 //最大連接數,超過這個數IP就會被屏蔽,一般默認即可
APF_BAN=1 (Make sure your APF version is atleast 0.96)
APF_BAN=0 (Uses iptables for banning ips instead of APF)
APF_BAN=1 //使用APF還是iptables。推薦使用iptables,將APF_BAN的值改為0即可。
KILL=0 (Bad IPs are'nt banned, good for interactive execution of script)
KILL=1 (Recommended setting)
KILL=1 //是否屏蔽IP,默認即可
An email is sent to the following address when an IP is banned.
Blank would suppress sending of mails
EMAIL_TO="root" //當IP被屏蔽時給指定郵箱發送郵件,推薦使用,換成自己的郵箱即可
Number of seconds the banned ip should remain in blacklist.
BAN_PERIOD=600 //禁用IP時間,默認600秒,可根據情況調整
用戶可根據給默認配置文件加上的注釋提示內容,修改配置文件。
查看/usr/local/ddos/ddos.sh文件的第117行
netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr > $BAD_IP_LIST
修改為以下代碼即可!
netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sed -n ‘/[0-9]/p’ | sort | uniq -c | sort -nr > $BAD_IP_LIST