[问题] dropbear加入安全机制

楼主: hungwei0331 (Game)   2015-02-06 16:56:13
各位版上前辈好,
我想用dropbear加入以下功能,
连续三次登入未能成功则阻挡该IP 30分钟,
目前已下载dropbear souce code更改,
更改svr-auth.c与svr-main.c
svr-auth更改如下
if (ses.authstate.failcount >= MAX_AUTH_TRIES) {
char * userstr;
/* XXX - send disconnect ? */
TRACE(("Max auth tries reached, exiting"))
if (ses.authstate.pw_name == NULL) {
userstr = "is invalid";
} else {
userstr = ses.authstate.pw_name;
}
dropbear_exit("Max auth tries reached - user '%s' from %s",
userstr, svr_ses.addrstring);
}
svr-main.c更改如下
/* child */
#ifdef DEBUG_FORKGPROF
extern void _start(void), etext(void);
monstartup((u_long)&_start, (u_long)&etext);
#endif /* DEBUG_FORKGPROF */
getaddrstring(&remoteaddr, NULL, &remote_port, 0);
dropbear_log(LOG_INFO, "Child connection from %s:%s",
remote_host, remote_port);
///Ignore connection here for 30 mins if you found 3 times login failure
m_free(remote_host);
m_free(remote_port);
#ifndef DEBUG_NOFORK
if (setsid() < 0) {
dropbear_exit("setsid: %s", strerror(errno));
}
#endif
/* make sure we close sockets */
for (i = 0; i < listensockcount; i++) {
m_close(listensocks[i]);
}
m_close(childpipe[0]);
/* start the session */
svr_session(childsock, childpipe[1]);
/* don't return */
dropbear_assert(0);
}
以上compile过后都未能新增这功能,
stack overflow则是有建议安装fail2ban,
但我在openwrt底下这套软件太过肥大暂不考虑
想请教版上前辈是否能指点我哪里更改错误呢? 请多多指教 谢谢
作者: hizuki (ayaka)   2015-02-06 19:46:00
你没把ip存起来当然不行建list存ip和时间,每次检查才行,很麻烦
作者: jokester (蛮王科科)   2015-02-11 15:05:00
dropbear可以连结fail2ban眼残抱歉..

Links booklink

Contact Us: admin [ a t ] ucptt.com