看板 FreeBSD 關於我們 聯絡資訊
※ 引述《lupin513 (螢幕,你不要走~~)》之銘言: : 請教各位大大, : 最近自家的SERVER一直被攻擊, : 想統計一下,並且整理資料, : 在網路上看到這篇文章。 : http://chejen-l.blogspot.com/2011_05_01_archive.html : grep 'login error' /var/log/openwebmail.log > auth_error.log : sed ' s/^.* (\[0-9]*\.[0-9]*.\[0-9]*\.[0-9]*\).*/\1/g 'auth_error.log > ip_list.txt ^^ ^^ 錯誤訊息抱怨括號沒有成對,至少要改成這樣,語法才是對的: s/^.*\(\[0-9]*\.[0-9]*.\[0-9]*\.[0-9]*\).*/\1/g 不過這樣是抓不到 ip 的 (至少我在 FreeBSD 9-current 上測是抓不到) 我建議改成這樣: sed 's/^.*(\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)).*/\1/' auth_error.log ... : sort ip_list.txt > sort_ip_list.txt : uniq -c sort_ip_list.txt : 但是在我的FreeBSD中,第二行指令一直無法成功。 : 顯示的錯誤訊息為:sed: 1: "s/^.* ([0-9]*\.[0-9]*.\ ...": RE error: parentheses not balanced : 不知道是我的系統問題,還是我複製的指令有問題呢? : 我的FreeBSD 是6.1,暫時沒打算升級,請大大指導,謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.30.49 ※ 編輯: HuangTzHuan 來自: 140.112.30.49 (06/02 17:33)