Site Security 資安掃描
OpenVAS 5:
使用 client 端 Greenbone Security Desktop (gsd),可連至 OpenVAS server 來管理。
至以上網址下載並匯入虛擬機 ova 檔,帳號 yh ,密碼 654321,匯入時勾選重設 mac 位址。
新增帳號 : 按右上角「電源」鈕 > 系統設定值 > 使用者及群組 > 新增 > 設為管理者。
重新以新增的帳號登入。
安裝 openvas :
#sudo su
root@ubuntu:~# service openvas-manager stop
root@ubuntu:~# service openvas-scanner stop
root@ubuntu:~# openvassd
root@ubuntu:~# openvasmd --migrate
root@ubuntu:~# openvasmd --rebuild
root@ubuntu:~# killall openvassd
root@ubuntu:~# service openvas-scanner start (啟動時間會比較久,請耐心等候)
root@ubuntu:~# service openvas-manager start
root@ubuntu:~# service openvas-administrator restart
root@ubuntu:~# service greenbone-security-assistant restart (不要理最後的 ERROR !)
更新 openvas 的檢測庫 root@ubuntu:~#openvas-nvt-sync(請參考上面連結)
建立 admin 帳號: root@ubuntu:~# openvasad -c add_user -n admin -r Admin (註:Enter Password: → 輸入 admin 的密碼,紅色字可自行更改,其他不能改,虛擬機中已有 admin 帳號,密碼為 654321)
修改 vbox 裏的 utuntu 解析度。注意: virtualbox 的 host 鍵就是右邊的 ctrl 鍵。有 host / right ctrl + F (全螢幕), L (無縫), A (調整), G (自動調整) 等搭配方法。打開 ubuntu 按右上角「電源」鈕 > 系統設定值 > 查「解析度」,能有超過 1280 x 768 即可。
有重開機或更新檢測庫 (更新 openvas 的檢測庫 root@ubuntu:~#openvas-nvt-sync ) 要重新執行指令:
#sudo su
root@ubuntu:~# service openvas-scanner start (啟動時間會比較久,請耐心等候)
root@ubuntu:~# service openvas-manager start
root@ubuntu:~# service openvas-administrator restart
root@ubuntu:~# service greenbone-security-assistant restart (不要理最後的 ERROR !)
檢查服務是否已正常啟用
root@ubuntu:~# netstat -nltp(僅列 openvas 相關服務的狀態)
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:9393 0.0.0.0:* LISTEN 28079/openvasad tcp 0 0 127.0.0.1:9390 0.0.0.0:* LISTEN 28066/openvasmd tcp 0 0 127.0.0.1:9391 0.0.0.0:* LISTEN 28054/openvassd: wa tcp 0 0 127.0.0.1:9392 0.0.0.0:* LISTEN 27725/gsad
(掃描程式) 於 user$gsd (user 權限下執行 gsd 指令) > 鍵入 server 值為 localhost,輸入 admin 帳號密碼。被掃描的伺服器不需要開 port (除非要幫忙掃描其他學校)。
(掃描程式) 於 gsd 圖形介面上 > 開新 task,按 task > 右鍵 start (開始掃描)、右鍵 refresh (更新進度)、右鍵 details (看報告),再看右下角有 summary。按 reports tab ,從 summary 框可以看到。
(掃描程式) 在 reports 上的 task 點兩下,可看 report,再來按 all filtered as html 以輸出 html 報告檔。
更新: http://myip.tw/itsmw/index.php?title=OpenVAS6#Lubuntu_.2B_OpenVAS6
還有一套叫 Paros 也可以參考安裝一下,或採紙本申請市級網路資安掃描方式執行。
2013 依建議修改伺服器設定:
(1) linux 伺服器依 OpenVAS 的建議加上以下兩行在 httpd.conf 檔中的 <VirtualHost> </VirtualHost> 段落中。http://www.vmadmin.co.uk/linux/44-redhat/218-linuxhttptracktrace
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
存檔
Check the apache config:
/usr/sbin/apachectl -t
service httpd restart
(2)封掉沒有在用的 443 port
舊版 openvas 無法使用,改用新版 openvas6 :
http://myip.tw/itsmw/index.php?title=OpenVAS6
前置作業
第一步打開終端機,切換成 root 身份
「開始選單」/「附屬應用程式」/「LX終端機」
openvas@lu1204:~& sudo -i
[sudo] Password for openvas:(←輸入 openvas 的密碼 654321)
root@lu1204:~# _
若「第一次」若「很久沒做過」,請先依序執行下面指令:
root@lu1204:~# openvas-nvt-sync ; openvas-nvt-sync
root@lu1204:~# openvas-scapdata-sync
root@lu1204:~# openvas-certdata-sync
root@lu1204:~# openvasmd --rebuild
再繼續執行以下指令
root@lu1204:~# openvassd
root@lu1204:~# openvasmd
root@lu1204:~# openvasad
root@lu1204:~# gsad --http-only
若出現 「Login failed: OMP Service is down.」
對 Lubuntu 重開機
在執行啟動指令前(openvasxx...),先以 root 身份完成以下三個動作。
root@lu1204:~# openvasmd --rebuild
root@lu1204:~# openvasmd --update
root@lu1204:~# openvasmd --migrate
update: 2014-07-31 發現在虛擬機 lubuntu 裏的 openvas6 無法正常掃瞄 server,掃到 1% 即停止。改用下面的 debian7 + openvas 6 虛擬機來運作。
debian7 + openvas 6 虛擬機:
http://myip.tw/itsmw/index.php?title=OpenVAS6
匯入 ova 失敗,後來取出該 ova 包裝裏的 vmdk ,再創一個 vm 即可運作。設定好該 debian 的 ip 及 dns 資料,再進行 openvas 的設定。
該 vm 的帳號為 root,密碼為 d654321
啟動掃描前置作業
同步各種弱點資料庫
root@debvas:~# openvas-nvt-sync
註:系統會問要不要整合資料庫(migration),按「y」。
root@debvas:~# openvasmd --rebuild
root@debvas:~# openvas-scapdata-sync
root@debvas:~# openvas-certdata-sync
啟動 OpenVAS 服務
root@debvas:~# service openvas-scanner start
root@debvas:~# service openvas-manager start start
root@debvas:~# service openvas-administrator start
root@debvas:~# service greenbone-security-assistant start
進入掃描畫面
找一台同網段之 Windows ,啟動瀏覽器(firefox, chrome...etc),輸入網址「https://xxx.xxx.xxx.xxx:9392」
帳號:admin
密碼:d654321
先在右下角輸入 dns 及 www 的 ip 作 immediately scan
修正完 server 的缺陷後,再按畫面上的星星圖示,create 一個針對該兩個 ip 的 full and deep scan。
下載 pdf 檔,進入 firefox 上網路信箱,將 pdf 郵寄給自己。
填報至教育局網站。
UPDATE: 後來這個虛擬機不太穩定,改用 openvas 官網 http://www.openvas.org/vm.html 提供的 ova 檔就解決了。帳號 root 密碼 root 。帳號 openvas ,密碼 openvas 。網頁掃瞄介面帳號: admin 、密碼 admin。在修改 ip 的過程中,因為是該 vm 是用德文鍵盤,所以可以利用數字鍵盤來打- 與 / 符號。y 與z 符號互調, # 符號互調 \。
若要改成英語鍵盤,則鍵入: loadkeys us 即可改為英語鍵盤。若要每次開機自動執行修改為英語鍵盤,則參考:
http://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian
http://forum.directadmin.com/showthread.php?t=42174
http://xmodulo.com/2013/01/how-to-automatically-start-program-on-boot-in-debian.html
新增 /etc/init.d/loadkeys
#!/bin/sh
### BEGIN INIT INFO
# Provides:loadkeys
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop loadkeys
# Description: loadkeys
### END INIT INFO
loadkeys us
以 root 身分鍵入以下指令:
chmod 755 /etc/init.d/loadkeys
update-rc.d loadkeys defaults
shutdown -r now
開機就會進入英語鍵盤模式了。
移除自動執行 SCRIPT 的方式: sudo update-rc.d -f loadkeys remove
官網的說明,它說自己是 7 版,但是進入網頁介面的 about 它卻寫 5 版,update 資料庫的方式可用 5 版方式:
http://www.openvas.org/vm.html
Version: 1.0 (up-to-date regarding base system, OpenVAS-7 and Feed as of 2014-05-12)
Download Sites for the OVA Image (3.5 GByte):
HTTP via binarysignals (Germany):
http://mirrord.binarysignals.net/OpenVAS-7-DEMO-1.0.ova (sha1sum)
RSYNC via OpenVAS (Germany):
rsync://rsync.openvas.org/vm/OpenVAS-7-DEMO-1.0.ova (sha1sum)
MD5SUM: 7d7e4d24229a9a518a356801af1b8845
Compatibility: VirtualBox >=4.3, ESXi >=4
Important Notes:
Security (it is highly recommended that you follow these steps immediately after first start):
You should change the default password for system account "root" (login as root and apply command "passwd").
You should change the default password for system account "openvas" (login as openvas and apply command "passwd").
You should change the default password for web account "admin" (login as admin via web interface and go to "Extras/My Settings". Via the Edit button, change the password - remind the checkbox to confirm password change).
You should upgrade the base system immediately to install all security updates published meanwhile. The base system is Debian Wheezy, so you need to run as "root" the command "apt-get dist-upgrade" (or other management tools you might prefer).
A self-signed SSL certificate is used. You need to allow an exception in your browser at first login.
Exchange it if you don't want to share the same ceritificate with other OpenVAS DEMO installations.
Encryption of passwords: The passwords that you enter for Credentials (ssh/smb) and that are boing used for authenticated scans are stored encrypted. A encryption key is pre-installed because the creation can take considerably long (upto 60 minutes).
If you do not exchange this key, you share the same encryption key with other OpenVAS DEMO installations!
This way you delete the key and create a new one (takes upto 60 minutes):
gpg --homedir=/usr/local/etc/openvas/gnupg --delete-secret-keys 94094F5B
gpg --homedir=/usr/local/etc/openvas/gnupg --delete-keys 94094F5B
openvasmd --create-credentials-encryption-key
/etc/init.d/openvas-manager restart
You will find further details and hints about the key management in the file "/root/build/openvas-manager-5.0.1/INSTALL".
Usage:
If you don't know where to log into the web interface, then log in as system user "openvas" and the URL will be printed.
GNU GPL: In compliance with GNU GPL, any sources are already pre-installed on the VM (under /root/source)
Performance: After import it might make sense to increase resources (CPU, RAM), given your host can provide this
Updating OpenVAS: OpenVAS was built unter /root/build. You need to download newest releases as tar.gz files and follow the usual scheme for building OpenVAS from source. The install prefix is "/usr/local".
Web timeout: If you want to increase the web timeout to for example 1 hour, then you should add "--timeout=60" to DAEMON_ARGS in /etc/default/greenbone-security-assistant and then restart.
同步各種弱點資料庫:
su -
root@debvas:~# openvas-nvt-sync
註:系統會問要不要整合資料庫(migration),按「y」。
root@debvas:~# openvasmd --rebuild
root@debvas:~# openvas-scapdata-sync
root@debvas:~# openvas-certdata-sync
重新開機
root@debvas:~# shutdown -r now
進入網頁 https://ip 然後輸入帳號 admin 及密碼,開始選 job 去掃。下載 report 檔:網頁上的 scan management > reports > 選按 date > 畫面中上有 Report results > PDF 下拉選單選報表格式 > 按綠色「下載」圖示。
註:進入 deep 掃瞄模式掃 freebsd 9 伺服器,出現流量在掃瞄後會仍有每秒十幾 MB 的大流量,將 OPENVAS 虛擬機關掉就沒再出現了。所以在掃瞄過程中可以進入 cacti 看看系統的狀況。建議以 full and fast 設定作掃瞄即可。
2014 年修補缺陷的方法:
freebsd 缺陷1:
將 /etc/sysctl.conf 加入一行:net.ipv4.tcp_timestamps = 0
存檔跳出。
service sysctl restart
/etc/rc.d/init.d/network restart (http://www.dk101.com/Discuz/viewthread.php?tid=193385#.U9tVQICSwvw)
註:以上的處置沒有用,還是出現此缺陷,原因待查。
freebsd 缺陷2 (http://httpd.apache.org/docs/current/en/mod/core.html#traceenable):
nano /usr/local/etc/apache22/httpd.conf
加上最後一行:TraceEnable off
/usr/local/etc/rc.d/apache22 restart
dns 缺陷1:
將 /etc/sysctl.conf 加入一行:net.ipv4.tcp_timestamps = 0
存檔跳出。
sysctl -p
vhd 兩台伺服器的 port 10001 tcp 與 10002 tcp 被認為是木馬:
將此兩個 PORT 限制在虛擬 ip 網段中 192.168.1.0/24 中。
backup、log、中的 nfs 服務:
沒在用,關閉之。