作者dingyuchi (fish)
看板FreeBSD
标题Re: [问题] 请问 sshd(openssh) 的 log 资讯
时间Sat Nov 28 22:43:47 2009
已经有人写好了
官方网站:
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