打扰一下,我想问一下我要修改防坠落以添加一个

功能。我已经下载了dropbear-0.52的源代码,而我已经

为他们阅读了很长时间,但我不知道我应该修改哪个c.file。

我想添加这样的功能,如果用户登录被拒绝了三次,

禁止其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/

10-13 06:39