Archive for the ‘資安’ Category

E-Mail Icon Generator

星期三, 六月 9th, 2010

常在網誌上看到漂亮的 E-Mail 圖示(像是 Demo Email),一直找不到出處,今天終於在無意間發現了,運氣不錯呵 ^_^

E-Mail Icon Generator: http://services.nexodyne.com/email/
只要在畫面中輸入 E-mail,然後按下 Generate 按鈕就會產生該 E-mail 的圖示。可以直接下載,或是用 link 的方式使用。

如果要在網頁上使用這個網站產生的 E-Mail 圖示,該網站只有一項要求:
「請在使用到這個網站產生的 E-Mail 圖示的網頁中的任何一個地方,放一個連到這個網站的連結,好讓其他網友也可以產生他們自己的 E-Mail 圖示。」
繼續閱讀 »

sshguard – 封鎖可疑攻擊 IP

星期六, 十一月 28th, 2009

sshguard 透過監控系統記錄檔,封鎖可疑的 IP 連線。與 SSHBlock 不同之處在於,監控的系統記錄檔不僅限於 ssh,因此雖然名為 sshguard,但實際上也可監控 dovecot, proftpd, ftpd 等服務。此外,sshguard 除了支援 TCP Wrappers 封鎖之外,還支援 unix-like system 常見的防火牆,例如 pf, netfilter/iptables, IPFIREWALL/ipfw, IPFILTER 等等。

sshguard 的 ports 路徑為 security/sshgurad/,若要搭配 pf 使用,則可直接到 security/sshguard-pf/ 目錄下安裝。其他還有 security/sshguard-ipfilter/, security/sshguard-ipfw/,端視欲搭配的防火牆而定。以下以搭配 pf 為例:

在 security/sshguard-pf/ 目錄下執行 make install clean 之後,最後顯示的操作提示:

Sshguard installed successfully.

To activate or configure PF see http://sshguard.sf.net/doc/setup/blockingpf.html

Your /etc/syslog.conf has been added a line for sshguard; uncomment it
and use "/etc/rc.d/syslogd reload" for activating it.

See sshguard(8) and http://sshguard.sourceforge.net for additional info.

因為是使用 pf 進行封鎖,因此需要先建立 sshguard 使用的 table,以便 sshguard 將可疑 IP 加入。pf 的設定方式可參考 sshguard 官方網站中的 Set up PF firewall
繼續閱讀 »

SSHBlock – 阻擋 ssh 暴力攻擊

星期六, 十一月 28th, 2009

就像有手機就會接到詐騙電話一樣,只要 server 連上網路,就會有人想 try 密碼。
SSHBlock 是藉由監控 ssh 記錄檔,將惡意的來源 IP 加到 TCP Wrappers 設定檔中以進行封鎖。

SSHBlock 的 ports 路徑為 security/sshblock/ ,其中的套件說明如下:

SSHBlock is a daemon to monitor a syslog log for break-in attempts using
SSH, and to automatically block bad hosts by adding lines to /etc/hosts.allow
(TCP Wrappers). Several thresholds are pre-defined, to be able to block those
trying many attempts within a longer or shorter period.

WWW: http://www.bsdconsulting.no/tools/

下指令 make install clean 安裝之後,出現後續的操作說明:

To enable and use the sshblock daemon, use the following in /etc/rc.conf or
/etc/rc.conf.local:

sshblock_enable="YES"

To set flags/options (optional), add:

sshblock_flags=""

See /usr/local/sbin/sshblock -h for possible command line options.

Use /usr/local/etc/rc.d/sshblock to stop and start it.

sshblock 語法說明如下:

Usage: sshblock [ -b <blockfile> ] [ -l <logfile> ] [ -t <trigger list> ]

Trigger list is a list of seconds:attempts threshold pairs for determining
whether a host should be blocked

Default blockfile: /etc/hosts.allow
Default logfile: /var/log/auth.log

因此利用 ports 安裝完成之後,可以執行以下指令啟動 sshblock

/usr/local/etc/rc.d/sshblock start

若要系統開機時自動啟動 sshblcok,則在 /etc/rc.conf 加入

sshblock_enable="YES"

繼續閱讀 »

用 portaudit 檢查套件的安全性

星期一, 七月 20th, 2009

安裝路徑: /usr/ports/security/portaudit
使用方式:

portaudit -Fda

這指令會自動抓取最新的弱點資料庫,並比對所有已安裝的套件,並產生需要修補的套件報表。

該死的 sosospider

星期一, 六月 23rd, 2008

正在做例行的伺服器維護時,突然系統變得超慢,用 vmstat 一看

 procs      memory      page                   disk   faults      cpu
 r b w     avm    fre  flt  re  pi  po  fr  sr ad0   in   sy  cs us sy id
136 29 0 1767964  30084 75528 6449 344 1952 19101 3716299  54 83147    0 120759 53 47  0
132 16 0 1690556  30944 39779 3063 309 224 9382 932991  30 71882    0 112895 53 47  0
153 20 0 1716916  41504 70373 6371 313 2848 20009 3229680  51 157679    0 277140 41 59  0

哇!正在跑的 process 竟然飆到 130 以上,難怪系統超慢。追查之後發現是從 124.115.0.xxx 與 124.115.4.xxx 來的 http request 把伺服器搞掛。Google 一下這幾個 IP,原來正是惡名昭彰的騰訊 sosospider。因此二話不說,直接把這兩個網段 ban 掉

ipfw add 100 deny tcp from 124.115.0.1/24 to any
ipfw add 100 deny tcp from 124.115.4.1/24 to any

再用 vmstat 觀察一下,馬上就恢復正常了

 procs      memory      page                   disk   faults      cpu
 r b w     avm    fre  flt  re  pi  po  fr  sr ad0   in   sy  cs us sy id
156 18 0 1721036  31456 44789 4409 340 736 6014 1109953  36 90724    0 157802 43 57  0
144 22 0 1738760  29972 50467 4974 437 1600 10285 1768221  57 81266    0 136508 46 54  0
39 34 0 1762924  33188 54962 2551 958 704 19168 971608  62 58070    0 92074 52 48  0
 4 7 0 1650664  59108 23262 481 285   0 18632   0  50 17862    0 33268 39 61  0
 0 1 0 1628484  65848 3535  10  98   0 4956   0  75  781    0 1926 27 58 15
 0 1 0 1619168  69368 1420  18   0   0 1384   0   2  614    0 694 11 30 59

之後看一下封鎖的狀況: ipfw show

00100     165903       9944820 deny tcp from 124.115.0.0/24 to any
00100      59700       3579864 deny tcp from 124.115.4.0/24 to any

總共 try 了二十幾萬次,真是惡質…

用 host -al 或 dig axfr 檢查 DNS 設定

星期三, 十月 10th, 2007

基於安全考量, DNS server 不應該讓一般人取得網域的完整設定,也就是不能讓人隨隨便便就能看到整份 zone file。
而取得整份 zone file 的指令,可以用

host -al domain [server]

dig @server domain axfr

其中 domain 是網域名稱,server 是 DNS server。

當 DNS 設定完成後,最好利用上述指令測試一下,看其他未經授權的伺服器能否取得整份 zone 檔,
如果能夠任意取得,就要再進一步檢查 DNS server 的設定是否有誤。

WordPress 的 themes 有 Path Disclosure 漏洞

星期六, 六月 23rd, 2007

在查 Path Disclosure 相關資料時,無意間發現有網友指出 WordPress 的 themes 存在著 Path Disclosure 的漏洞,原文請見:
http://cnc.sablog.net/blog/show-243-1.html

該文是 2007.03.25. 發佈的,當時 WordPress 的版本是 2.1.2,
而今我以 2.2 版測試,還是存在同樣的問題,因此先以原文提出的方式修正。
但是將所有 wp-content/themes/default/ 目錄下的所有 php 檔,
都加上原文提供的修正碼之後,編輯文章按下儲存之後,
畫面卻出現 Access Denied 的錯誤訊息!

明顯是剛剛修改的某個檔案有問題,仔細一個一個查,
發現問題是出在 functions.php 這個程式。
因此對於functions.php,在檔案最上方加上以下程式碼修正之:

<?php error_reporting(0);?>

由於 error_reporting(0) 會抑制錯誤訊息的輸出,
而我又不確定將 error_reporting 關掉是否會對後面的程式造成影響,
因此其餘檔案就照原文提供的方式修正。