我谈网络扫描 -- 之三
生活随笔
收集整理的這篇文章主要介紹了
我谈网络扫描 -- 之三
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
在本系列文章的第一,二部分(我談網(wǎng)絡(luò)掃描 -- 之一,之二),我們站在安全從業(yè)者的角度,討論了網(wǎng)絡(luò)掃描基礎(chǔ),各種端口和漏洞掃描技術(shù)及使用經(jīng)驗(yàn)。接下來,我們討論如何應(yīng)對惡意網(wǎng)絡(luò)掃描。 五. 如何應(yīng)對網(wǎng)絡(luò)掃描
??????現(xiàn)在,互聯(lián)網(wǎng)上免費(fèi)的掃描軟件,太多了,隨便 google 一下,就可以找到一大推;而且,現(xiàn)在的掃描軟件,越來越簡單易用,從而使得一些沒有什么網(wǎng)絡(luò)和系統(tǒng)技術(shù)的 badegg 們(傳說中的“腳本小子”),也可以用得得心應(yīng)手;另外,現(xiàn)在的掃描軟件,越來越智能,越來越會逃避 IDS/IPS 的檢測和防護(hù)。這一方面方便了安全從業(yè)者的工作,提高了我們的工作效率,另一方面也給那些專門想搞破壞的 badegg 們大開了方便之門,增加了安全從業(yè)者的負(fù)擔(dān)。我們不得不承認(rèn),網(wǎng)絡(luò)掃描工具的這些特點(diǎn),確實(shí)增加了我們工作的難度,但是,那并不意味著我們在面對網(wǎng)絡(luò)掃描的時候,就應(yīng)該束手無策,不知所措,坐以待斃了。相反,我們應(yīng)該使用各種針對端口和漏洞掃描的檢測和防護(hù)措施,來積極地跟惡意的網(wǎng)絡(luò)掃描做斗爭,限制他們的掃描范圍,減少他們通過掃描能獲得的信息,從而更好地保護(hù)我們的網(wǎng)絡(luò)安全。 1. 檢測網(wǎng)絡(luò)掃描
??? 要有效地檢測網(wǎng)絡(luò)掃描,需要先弄清楚幾個問題:
?????? × 希望檢測外網(wǎng)掃描還是內(nèi)網(wǎng)掃描?
??????????? 檢測的目的決定了我們到底該進(jìn)行哪種檢測。如果我們想檢測來自公網(wǎng)的惡意掃描,并進(jìn)行及時封堵,或者檢查我們的網(wǎng)絡(luò)防火墻配置是否正確,? 那么應(yīng)該選擇檢測外網(wǎng)掃描;如果我們對自己內(nèi)網(wǎng)的安全不太確信,比如曾經(jīng)被侵入過,想檢測出是否有惡意程序存在,那么可以選擇檢測內(nèi)網(wǎng)掃描。
?????? × 掃描檢測系統(tǒng)應(yīng)該部署在哪個位置?
??????????? 如果想檢測外網(wǎng)掃描,那么建議將掃描檢測軟件(一般就是入侵檢測/防護(hù)系統(tǒng))部署在公網(wǎng)防火墻后面,因?yàn)楣W(wǎng)上未經(jīng)防火墻過濾的惡意掃描實(shí)在太多,各種告警信息會把我們弄崩潰,一旦經(jīng)過防火墻過濾了,能夠到達(dá)掃描檢測軟件的惡意掃描就會明顯少很多,這樣方便我們的工作,而且,也只有經(jīng)過防火墻過濾后的惡意掃描,才是我們所關(guān)心的;如果想檢測內(nèi)網(wǎng)掃描,那么把掃描檢測軟件部署到內(nèi)網(wǎng)的任何位置都可以,只要能夠接收到內(nèi)網(wǎng)的所有網(wǎng)絡(luò)數(shù)據(jù)包就可以了(當(dāng)然需要我們的精心配制)。
?????? × 怎樣讓網(wǎng)絡(luò)數(shù)據(jù)包發(fā)送到掃描檢測系統(tǒng)?
??????????? 通常情況下,不管是檢測外網(wǎng)掃描還是內(nèi)網(wǎng)掃描,都極有可能涉及到端口數(shù)據(jù)流鏡像/復(fù)制技術(shù),就是把從同一個交換機(jī)的其他某些端口進(jìn)出的數(shù)據(jù)包,復(fù)制到掃描檢測系統(tǒng)所連接的交換機(jī)端口上來(這種同一個交換機(jī)上的端口數(shù)據(jù)流鏡像/復(fù)制,就 cisco 交換機(jī)來說,被稱之為 SPAN);或者是把進(jìn)出其它交換機(jī)的某些端口的數(shù)據(jù)包,復(fù)制到掃描檢測系統(tǒng)所連接的交換機(jī)端口上來(這種不同交換機(jī)上的端口數(shù)據(jù)流鏡像/復(fù)制,就 cisco 交換機(jī)來說,被稱之為 RSPAN)。
??我在這里不詳述 SPAN 和 RSPAN 了,只各舉一個例子:
????????? SPAN 例子: !指定復(fù)制哪些端口的流量
???????????????SwitchA(config)# monitor session 1 source int g0/10 rx???
???????????????!指定把流量復(fù)制到哪個端口??
???????????????SwitchA(config)# monitor session 1 dest?? int g0/24??????? RSPAN 例子: ! 定義 RPSN VLAN,必須保證該 VLAN 定義能夠 ! 被傳輸?shù)浇粨Q機(jī) SwitchB 上去
???????????????SwitchA(config)# vlan 1000
???????????????SwitchA(config-vlan)# remote vlan
???????????????SwitchA(config-vlan)# end
???????????????!指定復(fù)制交換機(jī) SwitchA 上的哪些端口的流量?
???????????????SwitchA(config)# monitor session 1 source int g0/2 rx
???????????????SwitchA(config)# monitor session 1 dest remote vlan 1000
???????????????!指定復(fù)制到交換機(jī) SwitchB 上的哪個端口
???????????????SwitchB(config)# monitor session 1 source remote vlan 1000
???????????????SwitchB(config)# monitor session 1 dest int g0/1 提示:如果需要檢測的流量比較大,建議只分析一個方向的數(shù)據(jù)包。 接下來,我們看看開源 IDS/IPS snort 對網(wǎng)絡(luò)掃描的檢測:
??????? a. 當(dāng)我們用 nmap 來進(jìn)行掃描的時候,snort 能檢測到,并生成 nmap 掃描警告,生成的警告消息如下:
??????
??????? b. 當(dāng)我們用 nessus 來進(jìn)行掃描的時候,snort 能檢測到,并生成 nmap,nessus 及跟目標(biāo)運(yùn)行的服務(wù)相關(guān)的掃描警告,生成的警告消息如下(為了簡潔,我刪了一些警告信息): c. 當(dāng)我們用 nikto 來進(jìn)行掃描的時候,snort 能檢測到,并生成許多的信息收集和 WEB 應(yīng)用攻擊掃描警告,下面是幾條有代表性的掃描警告:
??????????
????? 再次,我們看看商業(yè) IDS/IPS 對網(wǎng)絡(luò)掃描的檢測:就筆者所知,Juniper NetScreen-IDP 可以準(zhǔn)確檢測出網(wǎng)絡(luò)掃描,其它 IDS/IPS 筆者不熟悉,不敢亂說了。 2. 防護(hù)網(wǎng)絡(luò)掃描
????首先,我們看看防火墻在防護(hù)網(wǎng)絡(luò)掃描方面的作用:作為一種靜態(tài)的網(wǎng)絡(luò)安全防護(hù)工具,防火墻在防護(hù)網(wǎng)絡(luò)掃描方面的作用比較小,它能作的事情就是保護(hù)我們網(wǎng)絡(luò)上監(jiān)聽著的但未開放給公網(wǎng)的端口(比如只開放給特定IP地址的端口),避免這些端口被黑客掃描到,僅此而已。其它諸如實(shí)時告警和防護(hù),就指望不上了。
?????當(dāng)然,這也意味著我們必須好好利用防火墻這個工具,保護(hù)好每一個我們不希望公網(wǎng)訪問的端口,避免它們被惡意掃描到。
???? 其次,我們看看主機(jī)入侵檢測系統(tǒng) OSSEC 在防護(hù)網(wǎng)絡(luò)掃描方面的表現(xiàn):OSSEC 是一款優(yōu)秀的主機(jī)入侵檢測軟件,其默認(rèn)配置就能夠檢測和防護(hù)網(wǎng)絡(luò)掃描。下面是筆者做的測試,該測試很好地體現(xiàn)了 OSSEC 的自動防護(hù)網(wǎng)絡(luò)掃描功能。
在 rac1 掃描 rac2 之前,rac2 的 iptables 規(guī)則:
?????????????? ??[root@rac2 ossec]# iptables -L -n
?????????????? ??Chain INPUT (policy ACCEPT)
?????????????? ??target???? prot opt source?????????????? destination???????? Chain FORWARD (policy ACCEPT)
?????????????????target???? prot opt source?????????????? destination???????? Chain OUTPUT (policy ACCEPT)
?????????????? ??target???? prot opt source?????????????? destination?? 從 rac2 掃描 rac1:??????
?????????????? ??[root@rac1 ~]# nmap -sS -v 192.168.2.222
?????????????? ??Starting nmap 3.70 (?[url]http://www.insecure.org/nmap/[/url]) at??? 2008-02-?????????????????Initiating SYN Stealth Scan against 192.168.2.222 [1660 ports] at 21:36 rac1 掃描了 rac2 之后,rac2 的 iptables 規(guī)則:
?????????????? ??[root@rac2 ossec]# iptables -L -n
?????????????? ??Chain INPUT (policy ACCEPT)
?????????????? ??target???? prot opt source?????????????? destination?????????
?????????????? ??DROP?????? all? --? 192.168.2.111??????? 0.0.0.0/0???????????
??
???????????????? hain FORWARD (policy ACCEPT)
???????????????? target???? prot opt source?????????????? destination?????????
???????????????? DROP?????? all? --? 192.168.2.111??????? 0.0.0.0/0?????????? Chain OUTPUT (policy ACCEPT)
?????????????? ??target???? prot opt source?????????????? destination? 可以看出,rac2 已經(jīng)自動添加防火墻規(guī)則,丟棄來自 rac1(192.168.2.111)的任何數(shù)據(jù)包,自動防護(hù)網(wǎng)絡(luò)掃描功能,體現(xiàn)出來了,呵呵。 再次,我們看看端口掃描檢測工具 PortSentry 在防護(hù)網(wǎng)絡(luò)掃描方面的表現(xiàn):PortSentry 是一款檢測各種類型端口掃描,實(shí)時響應(yīng)的工具。由于筆者先前沒有寫過關(guān)于 PortSentry 的文章,故在此簡單描述一下其安裝和使用:
第一步:修改 Makefile 文件
??????????? # vi Makefile?
?????????? ??? # 注釋掉下面一行
?????????????? # CC = cc
?
?????????? ??? # 取消對下面一行的注釋
?????????? ??? CC = gcc 第二步:修改 portsentry.c 文件中的一個小 bug
??????????? # vi portsentry.c
???????????? ??將 1584 行 和 1585 行
?????????? ???? printf ("Copyright 1997-2003 Craig H. Rowland <craigrowland at users dot
???????????? sourceforget dot net>\n");
??????????? 修改為下面這一行:
???????????? printf ("Copyright 1997-2003 Craig H. Rowland <craigrowland at users dot sourceforget dot net>\n"); 第三步:安裝
???????????? # make linux && make install 第四步:配置
????????????? a. 啟用 iptables 防護(hù):修改 /usr/local/psionic/portsentry/portsentry.conf 文件下面兩行??????????????? # iptables support for Linux
???????????????? #KILL_ROUTE="/usr/local/bin/iptables -I INPUT -s $TARGET$ -j DROP"??
???????????????? 為
???????????????? # iptables support for Linux
???????????????? KILL_ROUTE="/sbin/iptables -I INPUT -s $TARGET$ -j DROP"???????????????????
??????????? ?? b. 把我們信任的網(wǎng)絡(luò)或主機(jī)的IP地址寫入 /usr/local/psionic/portsentry/portsentry.ignore 文件,PortSentry 不會?理會來自這些地址的網(wǎng)絡(luò)掃描。 第五步:運(yùn)行
????????????? # /usr/local/psionic/portsentry/portsentry -tcp?????????????????????????????
????????? ??? # /usr/local/psionic/portsentry/portsentry -stcp 或者??? # /usr/local/psionic/portsentry/portsentry -atcp?
????????????? # /usr/local/psionic/portsentry/portsentry -udp 下面是筆者的測試,該測試很好地體現(xiàn)了 PortSentry 在自動防護(hù)網(wǎng)絡(luò)掃描時的優(yōu)秀表現(xiàn): 掃描前 rac2 的防火墻規(guī)則:
???????????????? ??[root@rac2 portsentry]# iptables -L -n
???????????????????Chain INPUT (policy ACCEPT)
???????????????? ??target???? prot opt source?????????????? destination???????? Chain FORWARD (policy ACCEPT)
???????????????? ??target???? prot opt source?????????????? destination???????? Chain OUTPUT (policy ACCEPT)
???????????????? ??target???? prot opt source?????????????? destination?? 從 rac1 掃描 rac2:
??????????????? ??[root@rac1 ~]# nmap -sS -O -v 192.168.2.222 當(dāng) rac1 開始掃描 rac2 后,rac2 的 iptables 規(guī)則:
??????????????? ??[root@rac2 portsentry]# iptables -L -n
??????????????? ??Chain INPUT (policy ACCEPT)
??????????????? ??target???? prot opt source?????????????? destination?????????
??????????????????DROP?????? all? --? 192.168.2.111??????? 0.0.0.0/0?????????? Chain FORWARD (policy ACCEPT)
??????????????? ??target???? prot opt source?????????????? destination???????? Chain OUTPUT (policy ACCEPT)
??????????????? ??target???? prot opt source?????????????? destination????
??
???????????????? ?當(dāng) rac1 開始掃描 rac2 后,rac2 的 portsentry.history 文件的內(nèi)容:
???????????????? ??[root@rac2 portsentry]# cat portsentry.history?
???????????????? ??1202224522 - 02/05/2008 23:15:22 Host: 192.168.2.111/192.168.2.111 Port: 23 TCP Blocked 當(dāng)掃描結(jié)束后,獲得的信息:
?????????????????? [root@rac1 ~]# nmap -sS -O -v 192.168.2.222
?????????????????? Starting nmap 3.70 (?[url]http://www.insecure.org/nmap/[/url]) at 2008-02-05 23:26 CST
???????????????????Initiating SYN Stealth Scan against 192.168.2.222 [1660 ports] at 23:26
?????????????????? SYN Stealth Scan Timing: About 32.20% done; ETC: 23:27 (0:01:03 remaining)
?????????????????? Increasing send delay for 192.168.2.222 from 0 to 5 due to 11 out of 21 dropped probes since last increase.
????????????????? SYN Stealth Scan Timing: About 50.66% done; ETC: 23:29 (0:01:31 remaining)
????????????????? Increasing send delay for 192.168.2.222 from 5 to 10 due to 11 out of 11 dropped probes since last increase.
????????????????? Increasing send delay for 192.168.2.222 from 10 to 20 due to 11 out of 11 dropped probes since last increase.
???????????????? SYN Stealth Scan Timing: About 78.01% done; ETC: 23:30 (0:00:52 remaining)
???????????????? Increasing send delay for 192.168.2.222 from 20 to 40 due to 11 out of 11 dropped probes since last increase.
??????????????? The SYN Stealth Scan took 263.62s to scan 1660 total ports.
??????????????? Warning:? OS detection will be MUCH less reliable because we did not find at least 1 open and 1 closed TCP port
??????????????? Host 192.168.2.222 appears to be up ... good.
??????????????? Interesting ports on 192.168.2.222:
??????????????? (The 1650 ports scanned but not shown below are in state: filtered)
?????????????? PORT???? STATE? SERVICE
?????????????? 21/tcp?? closed ftp
?????????????? 23/tcp?? closed telnet
???????????????53/tcp?? closed domain
?????????????? 113/tcp? closed auth
?????????????? 256/tcp? closed FW1-secureremote
???????????????443/tcp? closed https
?????????????? 554/tcp? closed rtsp
?????????????? 636/tcp? closed ldapssl
?????????????? 1723/tcp closed pptp
?????????????? 3389/tcp closed ms-term-serv
?????????????? Too many fingerprints match this host to give specific OS details Nmap run completed -- 1 IP address (1 host up) scanned in 271.799 seconds ? 可以看出,PortSentry 及時添加了 iptables 規(guī)則,阻擋了 rac1 的掃描,使得 rac1 的掃描根本就沒能發(fā)現(xiàn)什么有價值的信息,great!
?????????
??????? OSSEC 和 PortSentry 在檢測和防護(hù) nmap 掃描時確實(shí)表現(xiàn)不凡。但是,我們也不得不承認(rèn),他們在應(yīng)對 nessus 和 nikto 掃描時,幾乎無能為力。防護(hù) nessus 和 nikto 掃描的重任,就只有交給網(wǎng)絡(luò) IDS/IPS 了。 最后,我們看看網(wǎng)絡(luò)入侵檢測系統(tǒng)在防護(hù)網(wǎng)絡(luò)掃描方面的表現(xiàn):就筆者所知,工作于 Inline 模式的 Snort 和 Juniper NetScreen-IDP 可以防護(hù)各種網(wǎng)絡(luò)掃描,諸如 nmap, nessus, nikto 等等,其它 IDS/IPS 筆者不熟悉,不敢亂說了。 提示:如果我們正確配置了防火墻,那么惡意端口掃描并不是嚴(yán)重的事情,不會對我們的網(wǎng)絡(luò)安全構(gòu)成嚴(yán)重威脅。 六. 結(jié)語
???? 在本系列文章的三個部分,我們分別探討了網(wǎng)絡(luò)掃描基礎(chǔ)和端口掃描,漏洞掃描,如何應(yīng)對網(wǎng)絡(luò)掃描。可以看出,網(wǎng)絡(luò)掃描并沒有我們想象的那么簡單,需要注意很多地方和細(xì)節(jié),才能夠獲得我們需要的信息,才能夠避免給生產(chǎn)網(wǎng)絡(luò)造成負(fù)面影響,才能夠避免給自己帶來麻煩。為了更好地保護(hù)自己的網(wǎng)絡(luò),我們需要積極使用多種軟件和技術(shù)來檢測和防護(hù)惡意的網(wǎng)絡(luò)掃描,限制惡意掃描能抵達(dá)的范圍,減少惡意掃描所能獲得的信息,從而蒙上黑客的“眼睛”。 更多信息,請參考筆者的其它幾篇文章:
《snort 安裝指南》
《主機(jī)入侵檢測系統(tǒng) OSSEC 安裝指南》
《某大型網(wǎng)站在某機(jī)房網(wǎng)絡(luò)核心交換機(jī)配置》 RSPAN 配置部分;
《linux 系統(tǒng)安全規(guī)范》???????
本文轉(zhuǎn)自zkjian517 51CTO博客,原文鏈接:http://blog.51cto.com/zoukejian/61737
??????現(xiàn)在,互聯(lián)網(wǎng)上免費(fèi)的掃描軟件,太多了,隨便 google 一下,就可以找到一大推;而且,現(xiàn)在的掃描軟件,越來越簡單易用,從而使得一些沒有什么網(wǎng)絡(luò)和系統(tǒng)技術(shù)的 badegg 們(傳說中的“腳本小子”),也可以用得得心應(yīng)手;另外,現(xiàn)在的掃描軟件,越來越智能,越來越會逃避 IDS/IPS 的檢測和防護(hù)。這一方面方便了安全從業(yè)者的工作,提高了我們的工作效率,另一方面也給那些專門想搞破壞的 badegg 們大開了方便之門,增加了安全從業(yè)者的負(fù)擔(dān)。我們不得不承認(rèn),網(wǎng)絡(luò)掃描工具的這些特點(diǎn),確實(shí)增加了我們工作的難度,但是,那并不意味著我們在面對網(wǎng)絡(luò)掃描的時候,就應(yīng)該束手無策,不知所措,坐以待斃了。相反,我們應(yīng)該使用各種針對端口和漏洞掃描的檢測和防護(hù)措施,來積極地跟惡意的網(wǎng)絡(luò)掃描做斗爭,限制他們的掃描范圍,減少他們通過掃描能獲得的信息,從而更好地保護(hù)我們的網(wǎng)絡(luò)安全。 1. 檢測網(wǎng)絡(luò)掃描
??? 要有效地檢測網(wǎng)絡(luò)掃描,需要先弄清楚幾個問題:
?????? × 希望檢測外網(wǎng)掃描還是內(nèi)網(wǎng)掃描?
??????????? 檢測的目的決定了我們到底該進(jìn)行哪種檢測。如果我們想檢測來自公網(wǎng)的惡意掃描,并進(jìn)行及時封堵,或者檢查我們的網(wǎng)絡(luò)防火墻配置是否正確,? 那么應(yīng)該選擇檢測外網(wǎng)掃描;如果我們對自己內(nèi)網(wǎng)的安全不太確信,比如曾經(jīng)被侵入過,想檢測出是否有惡意程序存在,那么可以選擇檢測內(nèi)網(wǎng)掃描。
?????? × 掃描檢測系統(tǒng)應(yīng)該部署在哪個位置?
??????????? 如果想檢測外網(wǎng)掃描,那么建議將掃描檢測軟件(一般就是入侵檢測/防護(hù)系統(tǒng))部署在公網(wǎng)防火墻后面,因?yàn)楣W(wǎng)上未經(jīng)防火墻過濾的惡意掃描實(shí)在太多,各種告警信息會把我們弄崩潰,一旦經(jīng)過防火墻過濾了,能夠到達(dá)掃描檢測軟件的惡意掃描就會明顯少很多,這樣方便我們的工作,而且,也只有經(jīng)過防火墻過濾后的惡意掃描,才是我們所關(guān)心的;如果想檢測內(nèi)網(wǎng)掃描,那么把掃描檢測軟件部署到內(nèi)網(wǎng)的任何位置都可以,只要能夠接收到內(nèi)網(wǎng)的所有網(wǎng)絡(luò)數(shù)據(jù)包就可以了(當(dāng)然需要我們的精心配制)。
?????? × 怎樣讓網(wǎng)絡(luò)數(shù)據(jù)包發(fā)送到掃描檢測系統(tǒng)?
??????????? 通常情況下,不管是檢測外網(wǎng)掃描還是內(nèi)網(wǎng)掃描,都極有可能涉及到端口數(shù)據(jù)流鏡像/復(fù)制技術(shù),就是把從同一個交換機(jī)的其他某些端口進(jìn)出的數(shù)據(jù)包,復(fù)制到掃描檢測系統(tǒng)所連接的交換機(jī)端口上來(這種同一個交換機(jī)上的端口數(shù)據(jù)流鏡像/復(fù)制,就 cisco 交換機(jī)來說,被稱之為 SPAN);或者是把進(jìn)出其它交換機(jī)的某些端口的數(shù)據(jù)包,復(fù)制到掃描檢測系統(tǒng)所連接的交換機(jī)端口上來(這種不同交換機(jī)上的端口數(shù)據(jù)流鏡像/復(fù)制,就 cisco 交換機(jī)來說,被稱之為 RSPAN)。
??我在這里不詳述 SPAN 和 RSPAN 了,只各舉一個例子:
????????? SPAN 例子: !指定復(fù)制哪些端口的流量
???????????????SwitchA(config)# monitor session 1 source int g0/10 rx???
???????????????!指定把流量復(fù)制到哪個端口??
???????????????SwitchA(config)# monitor session 1 dest?? int g0/24??????? RSPAN 例子: ! 定義 RPSN VLAN,必須保證該 VLAN 定義能夠 ! 被傳輸?shù)浇粨Q機(jī) SwitchB 上去
???????????????SwitchA(config)# vlan 1000
???????????????SwitchA(config-vlan)# remote vlan
???????????????SwitchA(config-vlan)# end
???????????????!指定復(fù)制交換機(jī) SwitchA 上的哪些端口的流量?
???????????????SwitchA(config)# monitor session 1 source int g0/2 rx
???????????????SwitchA(config)# monitor session 1 dest remote vlan 1000
???????????????!指定復(fù)制到交換機(jī) SwitchB 上的哪個端口
???????????????SwitchB(config)# monitor session 1 source remote vlan 1000
???????????????SwitchB(config)# monitor session 1 dest int g0/1 提示:如果需要檢測的流量比較大,建議只分析一個方向的數(shù)據(jù)包。 接下來,我們看看開源 IDS/IPS snort 對網(wǎng)絡(luò)掃描的檢測:
??????? a. 當(dāng)我們用 nmap 來進(jìn)行掃描的時候,snort 能檢測到,并生成 nmap 掃描警告,生成的警告消息如下:
??????
??????? b. 當(dāng)我們用 nessus 來進(jìn)行掃描的時候,snort 能檢測到,并生成 nmap,nessus 及跟目標(biāo)運(yùn)行的服務(wù)相關(guān)的掃描警告,生成的警告消息如下(為了簡潔,我刪了一些警告信息): c. 當(dāng)我們用 nikto 來進(jìn)行掃描的時候,snort 能檢測到,并生成許多的信息收集和 WEB 應(yīng)用攻擊掃描警告,下面是幾條有代表性的掃描警告:
??????????
????? 再次,我們看看商業(yè) IDS/IPS 對網(wǎng)絡(luò)掃描的檢測:就筆者所知,Juniper NetScreen-IDP 可以準(zhǔn)確檢測出網(wǎng)絡(luò)掃描,其它 IDS/IPS 筆者不熟悉,不敢亂說了。 2. 防護(hù)網(wǎng)絡(luò)掃描
????首先,我們看看防火墻在防護(hù)網(wǎng)絡(luò)掃描方面的作用:作為一種靜態(tài)的網(wǎng)絡(luò)安全防護(hù)工具,防火墻在防護(hù)網(wǎng)絡(luò)掃描方面的作用比較小,它能作的事情就是保護(hù)我們網(wǎng)絡(luò)上監(jiān)聽著的但未開放給公網(wǎng)的端口(比如只開放給特定IP地址的端口),避免這些端口被黑客掃描到,僅此而已。其它諸如實(shí)時告警和防護(hù),就指望不上了。
?????當(dāng)然,這也意味著我們必須好好利用防火墻這個工具,保護(hù)好每一個我們不希望公網(wǎng)訪問的端口,避免它們被惡意掃描到。
???? 其次,我們看看主機(jī)入侵檢測系統(tǒng) OSSEC 在防護(hù)網(wǎng)絡(luò)掃描方面的表現(xiàn):OSSEC 是一款優(yōu)秀的主機(jī)入侵檢測軟件,其默認(rèn)配置就能夠檢測和防護(hù)網(wǎng)絡(luò)掃描。下面是筆者做的測試,該測試很好地體現(xiàn)了 OSSEC 的自動防護(hù)網(wǎng)絡(luò)掃描功能。
在 rac1 掃描 rac2 之前,rac2 的 iptables 規(guī)則:
?????????????? ??[root@rac2 ossec]# iptables -L -n
?????????????? ??Chain INPUT (policy ACCEPT)
?????????????? ??target???? prot opt source?????????????? destination???????? Chain FORWARD (policy ACCEPT)
?????????????????target???? prot opt source?????????????? destination???????? Chain OUTPUT (policy ACCEPT)
?????????????? ??target???? prot opt source?????????????? destination?? 從 rac2 掃描 rac1:??????
?????????????? ??[root@rac1 ~]# nmap -sS -v 192.168.2.222
?????????????? ??Starting nmap 3.70 (?[url]http://www.insecure.org/nmap/[/url]) at??? 2008-02-?????????????????Initiating SYN Stealth Scan against 192.168.2.222 [1660 ports] at 21:36 rac1 掃描了 rac2 之后,rac2 的 iptables 規(guī)則:
?????????????? ??[root@rac2 ossec]# iptables -L -n
?????????????? ??Chain INPUT (policy ACCEPT)
?????????????? ??target???? prot opt source?????????????? destination?????????
?????????????? ??DROP?????? all? --? 192.168.2.111??????? 0.0.0.0/0???????????
??
???????????????? hain FORWARD (policy ACCEPT)
???????????????? target???? prot opt source?????????????? destination?????????
???????????????? DROP?????? all? --? 192.168.2.111??????? 0.0.0.0/0?????????? Chain OUTPUT (policy ACCEPT)
?????????????? ??target???? prot opt source?????????????? destination? 可以看出,rac2 已經(jīng)自動添加防火墻規(guī)則,丟棄來自 rac1(192.168.2.111)的任何數(shù)據(jù)包,自動防護(hù)網(wǎng)絡(luò)掃描功能,體現(xiàn)出來了,呵呵。 再次,我們看看端口掃描檢測工具 PortSentry 在防護(hù)網(wǎng)絡(luò)掃描方面的表現(xiàn):PortSentry 是一款檢測各種類型端口掃描,實(shí)時響應(yīng)的工具。由于筆者先前沒有寫過關(guān)于 PortSentry 的文章,故在此簡單描述一下其安裝和使用:
第一步:修改 Makefile 文件
??????????? # vi Makefile?
?????????? ??? # 注釋掉下面一行
?????????????? # CC = cc
?
?????????? ??? # 取消對下面一行的注釋
?????????? ??? CC = gcc 第二步:修改 portsentry.c 文件中的一個小 bug
??????????? # vi portsentry.c
???????????? ??將 1584 行 和 1585 行
?????????? ???? printf ("Copyright 1997-2003 Craig H. Rowland <craigrowland at users dot
???????????? sourceforget dot net>\n");
??????????? 修改為下面這一行:
???????????? printf ("Copyright 1997-2003 Craig H. Rowland <craigrowland at users dot sourceforget dot net>\n"); 第三步:安裝
???????????? # make linux && make install 第四步:配置
????????????? a. 啟用 iptables 防護(hù):修改 /usr/local/psionic/portsentry/portsentry.conf 文件下面兩行??????????????? # iptables support for Linux
???????????????? #KILL_ROUTE="/usr/local/bin/iptables -I INPUT -s $TARGET$ -j DROP"??
???????????????? 為
???????????????? # iptables support for Linux
???????????????? KILL_ROUTE="/sbin/iptables -I INPUT -s $TARGET$ -j DROP"???????????????????
??????????? ?? b. 把我們信任的網(wǎng)絡(luò)或主機(jī)的IP地址寫入 /usr/local/psionic/portsentry/portsentry.ignore 文件,PortSentry 不會?理會來自這些地址的網(wǎng)絡(luò)掃描。 第五步:運(yùn)行
????????????? # /usr/local/psionic/portsentry/portsentry -tcp?????????????????????????????
????????? ??? # /usr/local/psionic/portsentry/portsentry -stcp 或者??? # /usr/local/psionic/portsentry/portsentry -atcp?
????????????? # /usr/local/psionic/portsentry/portsentry -udp 下面是筆者的測試,該測試很好地體現(xiàn)了 PortSentry 在自動防護(hù)網(wǎng)絡(luò)掃描時的優(yōu)秀表現(xiàn): 掃描前 rac2 的防火墻規(guī)則:
???????????????? ??[root@rac2 portsentry]# iptables -L -n
???????????????????Chain INPUT (policy ACCEPT)
???????????????? ??target???? prot opt source?????????????? destination???????? Chain FORWARD (policy ACCEPT)
???????????????? ??target???? prot opt source?????????????? destination???????? Chain OUTPUT (policy ACCEPT)
???????????????? ??target???? prot opt source?????????????? destination?? 從 rac1 掃描 rac2:
??????????????? ??[root@rac1 ~]# nmap -sS -O -v 192.168.2.222 當(dāng) rac1 開始掃描 rac2 后,rac2 的 iptables 規(guī)則:
??????????????? ??[root@rac2 portsentry]# iptables -L -n
??????????????? ??Chain INPUT (policy ACCEPT)
??????????????? ??target???? prot opt source?????????????? destination?????????
??????????????????DROP?????? all? --? 192.168.2.111??????? 0.0.0.0/0?????????? Chain FORWARD (policy ACCEPT)
??????????????? ??target???? prot opt source?????????????? destination???????? Chain OUTPUT (policy ACCEPT)
??????????????? ??target???? prot opt source?????????????? destination????
??
???????????????? ?當(dāng) rac1 開始掃描 rac2 后,rac2 的 portsentry.history 文件的內(nèi)容:
???????????????? ??[root@rac2 portsentry]# cat portsentry.history?
???????????????? ??1202224522 - 02/05/2008 23:15:22 Host: 192.168.2.111/192.168.2.111 Port: 23 TCP Blocked 當(dāng)掃描結(jié)束后,獲得的信息:
?????????????????? [root@rac1 ~]# nmap -sS -O -v 192.168.2.222
?????????????????? Starting nmap 3.70 (?[url]http://www.insecure.org/nmap/[/url]) at 2008-02-05 23:26 CST
???????????????????Initiating SYN Stealth Scan against 192.168.2.222 [1660 ports] at 23:26
?????????????????? SYN Stealth Scan Timing: About 32.20% done; ETC: 23:27 (0:01:03 remaining)
?????????????????? Increasing send delay for 192.168.2.222 from 0 to 5 due to 11 out of 21 dropped probes since last increase.
????????????????? SYN Stealth Scan Timing: About 50.66% done; ETC: 23:29 (0:01:31 remaining)
????????????????? Increasing send delay for 192.168.2.222 from 5 to 10 due to 11 out of 11 dropped probes since last increase.
????????????????? Increasing send delay for 192.168.2.222 from 10 to 20 due to 11 out of 11 dropped probes since last increase.
???????????????? SYN Stealth Scan Timing: About 78.01% done; ETC: 23:30 (0:00:52 remaining)
???????????????? Increasing send delay for 192.168.2.222 from 20 to 40 due to 11 out of 11 dropped probes since last increase.
??????????????? The SYN Stealth Scan took 263.62s to scan 1660 total ports.
??????????????? Warning:? OS detection will be MUCH less reliable because we did not find at least 1 open and 1 closed TCP port
??????????????? Host 192.168.2.222 appears to be up ... good.
??????????????? Interesting ports on 192.168.2.222:
??????????????? (The 1650 ports scanned but not shown below are in state: filtered)
?????????????? PORT???? STATE? SERVICE
?????????????? 21/tcp?? closed ftp
?????????????? 23/tcp?? closed telnet
???????????????53/tcp?? closed domain
?????????????? 113/tcp? closed auth
?????????????? 256/tcp? closed FW1-secureremote
???????????????443/tcp? closed https
?????????????? 554/tcp? closed rtsp
?????????????? 636/tcp? closed ldapssl
?????????????? 1723/tcp closed pptp
?????????????? 3389/tcp closed ms-term-serv
?????????????? Too many fingerprints match this host to give specific OS details Nmap run completed -- 1 IP address (1 host up) scanned in 271.799 seconds ? 可以看出,PortSentry 及時添加了 iptables 規(guī)則,阻擋了 rac1 的掃描,使得 rac1 的掃描根本就沒能發(fā)現(xiàn)什么有價值的信息,great!
?????????
??????? OSSEC 和 PortSentry 在檢測和防護(hù) nmap 掃描時確實(shí)表現(xiàn)不凡。但是,我們也不得不承認(rèn),他們在應(yīng)對 nessus 和 nikto 掃描時,幾乎無能為力。防護(hù) nessus 和 nikto 掃描的重任,就只有交給網(wǎng)絡(luò) IDS/IPS 了。 最后,我們看看網(wǎng)絡(luò)入侵檢測系統(tǒng)在防護(hù)網(wǎng)絡(luò)掃描方面的表現(xiàn):就筆者所知,工作于 Inline 模式的 Snort 和 Juniper NetScreen-IDP 可以防護(hù)各種網(wǎng)絡(luò)掃描,諸如 nmap, nessus, nikto 等等,其它 IDS/IPS 筆者不熟悉,不敢亂說了。 提示:如果我們正確配置了防火墻,那么惡意端口掃描并不是嚴(yán)重的事情,不會對我們的網(wǎng)絡(luò)安全構(gòu)成嚴(yán)重威脅。 六. 結(jié)語
???? 在本系列文章的三個部分,我們分別探討了網(wǎng)絡(luò)掃描基礎(chǔ)和端口掃描,漏洞掃描,如何應(yīng)對網(wǎng)絡(luò)掃描。可以看出,網(wǎng)絡(luò)掃描并沒有我們想象的那么簡單,需要注意很多地方和細(xì)節(jié),才能夠獲得我們需要的信息,才能夠避免給生產(chǎn)網(wǎng)絡(luò)造成負(fù)面影響,才能夠避免給自己帶來麻煩。為了更好地保護(hù)自己的網(wǎng)絡(luò),我們需要積極使用多種軟件和技術(shù)來檢測和防護(hù)惡意的網(wǎng)絡(luò)掃描,限制惡意掃描能抵達(dá)的范圍,減少惡意掃描所能獲得的信息,從而蒙上黑客的“眼睛”。 更多信息,請參考筆者的其它幾篇文章:
《snort 安裝指南》
《主機(jī)入侵檢測系統(tǒng) OSSEC 安裝指南》
《某大型網(wǎng)站在某機(jī)房網(wǎng)絡(luò)核心交換機(jī)配置》 RSPAN 配置部分;
《linux 系統(tǒng)安全規(guī)范》???????
本文轉(zhuǎn)自zkjian517 51CTO博客,原文鏈接:http://blog.51cto.com/zoukejian/61737
總結(jié)
以上是生活随笔為你收集整理的我谈网络扫描 -- 之三的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OSRAM欧司朗3030灯珠,看完就明白
- 下一篇: 猜数字小游戏(JAVA)