看板 FreeBSD 關於我們 聯絡資訊
已經有人寫好了 官方網站: http://samm.kiev.ua/bruteblock/ 參考: http://skeletor.ho.ua/index.php?name=articles&op=read&art=33&cat=10 以下是安裝方法 OS版本: FreeBSD 7.2 cd /usr/ports/security/bruteblock make install clean /etc/rc.conf firewall_enable="YES" #kernel裡要開firewall syslogd_flags="-c" #怕syslog一直出現 message repeat XXX bruteblockd_enable="YES" bruteblockd_table="1" bruteblockd_flags="-s 5" /etc/syslog.conf auth.info;authpriv.info /var/log/auth.log #加上這行代表把syslog丟給bruteblock auth.info;authpriv.info |exec /usr/local/sbin/bruteblock -f /usr/local/et\ c/bruteblock/ssh.conf #/etc/rc.d/syslogd restart /usr/local/etc/bruteblock/ssh.conf #預設兩個不夠再加上 regexp = sshd.*Illegal user \S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1\ ,3}) regexp1 = sshd.*Failed password for (?:illegal user )?\S+ from (\d{1,3\ }\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp2 = sshd.*error: PAM: authentication error for illegal user \S+ \ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp3 = "sshd.*Failed keyboard-interactive\/pam for \S+ from (\d{1,3\ }\.\d{1,3}\.\d{1,3}\.\d{1,3})" regexp4 = sshd.*Invalid user \S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1\ ,3}) regexp5 = sshd.*error: PAM: authentication error for \S+ from (\d{1,3}\ \.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp6 = sshd.*Did not receive identification string from (\d{1,3}\.\\ d{1,3}\.\d{1,3}\.\d{1,3}) regexp7 = sshd.*User \S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) not\ allowed because not listed in AllowUsers #/usr/local/etc/rc.d/bruteblockd restart /etc/rc.firewall setup_loopback () { ############ # Only in rare cases do you want to change these rules # ${fwcmd} add 100 pass all from any to any via lo0 ${fwcmd} add 200 deny all from any to 127.0.0.0/8 ${fwcmd} add 300 deny ip from 127.0.0.0/8 to any + # BruteBlock + ${fwcmd} add deny ip from me to table\(1\) + ${fwcmd} add deny ip from table\(1\) to me } #/etc/rc.d/ipfw restart ※ 引述《operationcow (香蕉公車)》之銘言: : ※ [本文轉錄自 Linux 看板] : 作者: operationcow (香蕉公車) 看板: Linux : 標題: [問題] 請問 sshd(openssh) 的 log 資訊 : 時間: Sat Nov 28 12:30:25 2009 : ※ [本文轉錄自 LinuxDev 看板] : 作者: operationcow (香蕉公車) 看板: LinuxDev : 標題: [問題] 請問 sshd(openssh) 的 log 資訊 : 時間: Sat Nov 28 12:29:58 2009 : 小弟我最近在研究 log, 希望撰寫一個可以防止 ssh bruteforce : attempt 的 script : 因此我看了 /etc/syslog.conf 後決定從 /var/log/messages 下手 : 我發現每次只要 ssh 失敗, 就會出現 : sshd[816]: error: PAM: authentication error for xxxx : 如果是某一次登入連續三次輸入密碼失敗而被踢出 : 就會出現 : sshd[816]: error: PAM: authentication error for xxxx : last message repeated 2 times : 我有兩個疑問 : (1) error: PAM: authentication error for xxxx 這個 log 可以很容易 : 看出是由 pid 為 816 的 sshd 所 syslog 的, 但 last message : repeated 2 times 卻沒有說是哪一個 process 所 syslog 的. 請問這是 : 哪裡來的呢?? : (2) 上網找了資料, 看到有的資料是藉由分析 error: PAM: authentication : error for xxxx 來獲得該被阻擋的 IP, 但是我有一個問題, 就是怎麼知 : 道 ssh 失敗只會產生這種 log, 有什麼地方可以看到 openssh 所會產生 : 的所有 log 嗎?? 我有嘗試把 openssh 下載下來 trace code, 不過看了 : 一下就眼花了 OTZ... : [其實我主要想問的是, 大家為不同的 application 撰寫 log analysis : script, 都是去哪裡獲得該 application 資料及確保自己撰寫的 script : 是正確的呢??] : 問題有點長, 感謝大家 <(__)> : ----------------------------------------------------------------------- : (1) : 以下是我查到的資料: : http://0rz.tw/mptVm : 因為是 disable 這個功能是在 syslogd 的 option, 所以可以很合理的推斷這是 : 屬於 syslogd 所 log 的資訊, 目的應該是為了避免太多重複的 log message -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.167.45.251