Glowman554/mirai

Telnet connection

Slotharmy opened this issue · 0 comments

Hi there,
i am setting up a lab for Mirai.
Thanks for the published repo and scripts.

I got an issue, when running the mirai.dbg.
It seems like nothing, or the wrong things are written into the rdbuf. Therefor in Consume_user_prompt, when the code checks for ':' and 'ogin', these strings can't be found.
To debug the code, I changed Consume_user_prompt() the following:


static int consume_user_prompt(struct scanner_connection *conn)
{
    #ifdef DEBUG
        printf("[scanner] start consume_user_prompt\n");
#endif
    char *pch;
    int i, prompt_ending = -1;

    for (i = conn->rdbuf_pos - 1; i > 0; i--)
    {
    #ifdef DEBUG
        printf("[scanner] FD%d  check if : is in buffer\n", conn->fd);
        if (conn->rdbuf_pos > 0){
            printf("Inhalt von conn->rdbuf vor ':'(Länge %d): \n", conn->rdbuf_pos);
            for (int i = 0; i < conn->rdbuf_pos; i++) {
                
                //if (isprint(conn->rdbuf[i]))
                    printf("%c", conn->rdbuf[i]);
                //else
                //    printf(".");
            }
            printf("\n");
        }
    #endif


        if (conn->rdbuf[i] == ':' || conn->rdbuf[i] == '>' || conn->rdbuf[i] == '$' || conn->rdbuf[i] == '#' || conn->rdbuf[i] == '%')
        {
        #ifdef DEBUG
            printf("[scanner] FD%d  : is in buffer\n", conn->fd);
        #endif
            prompt_ending = i + 1;
            break;
        }
    }
#ifdef DEBUG
            printf("[scanner] prompt_ending = %d SHOULD BE -1\n", prompt_ending);
#endif
    if (prompt_ending == -1)
    {
        int tmp;

        //check what is in rdbuf

        if (conn->rdbuf_pos > 0){
            printf("Inhalt von conn->rdbuf (Länge %d): \n", conn->rdbuf_pos);
            for (int i = 0; i < conn->rdbuf_pos; i++) {
                
                //if (isprint(conn->rdbuf[i]))
                    printf("%c", conn->rdbuf[i]);
                //else
                //    printf(".");
            }
            printf("\n");
        }



        if ((tmp = util_memsearch(conn->rdbuf, conn->rdbuf_pos, "ogin", 4)) != -1)
        {
#ifdef DEBUG
            printf("[scanner] tmp for ogin = %d\n", tmp);
#endif
            prompt_ending = tmp;
        }
        else if ((tmp = util_memsearch(conn->rdbuf, conn->rdbuf_pos, "enter", 5)) != -1)
        {

#ifdef DEBUG
            printf("[scanner] tmp for enter = %d\n", tmp);
#endif
            prompt_ending = tmp;
        }

            
    }

    if (prompt_ending == -1)
        return 0;
    else
        return prompt_ending;
}

Every help would be appreciated, Thx!