请问,我想修改dropbear添加一个
功能。我已经下载了 dropbear-0.52 的源代码并且我已经
读了很长时间但我不知道我应该修改哪个c.file..
我想添加这样的功能,如果用户登录被拒绝3次,
禁止其IP 30分钟
我尝试修改cli.auth,但不起作用
/*
if(ses.authstate.failcount >= 3){
if (cli_ses.auth_interact_failed) {
finished = 0;
} else {
cli_auth_interactive();
cli_ses.lastauthtype = AUTH_TYPE_INTERACT;
finished = 1;
}
*/
希望有人能帮我解决这个问题,非常感谢
最佳答案
dropbear 中的
svr-auth.c 文件检查密码并重试查看 send_msg_userauth_failure() 函数,因为您有 ses.authstate.failcount 跟踪连续登录失败的变量,如果达到 3,您可以在 svr-main.c 文件中阻止来自该 ip 的连接 30 分钟
svr-auth.c
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);
}
关于linux - dropbear如何禁止登录三次被拒绝的用户IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28341083/