~cpp 규 . 2000~3000 . // C++ C 기 3 . // 6000~9000 ... // 그 C++ C 0.8 간 . // 기 고 . : IRC bot : irc 공격 그. & AI( AI ) bot OS : Linux Language : C & Linux System Function : 개 교 그 게 . : Zombie Process System Call . 1. Client Console IRC Server . -> Main Process 2. PING -> 1 Child Process 3. -> 2 Chile Process (3 Master 군 게 -> Private 겨 IP .) main.c -> IRC Server 고 . parse.c -> IRC Server . file.c -> Log . 그 고 구. request.c -> IRC Server PING PONG . bot.c -> . attack_#.c(# == ) -> 공격 . 공격 . // 그 . connect.c -> . // . (2 ...) 구 : main , parse PING , request . ! . // signal . // fork 구.
~cpp // 구 . 각 . // 걸 기 . // #linux 까 . // 각 privmsg process call mirc . #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/wait.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <unistd.h> #include <arpa/inet.h> #define MSG_MAX 1024 #define NICK "whoami_" #define HOST "irc.hanirc.org" #define PORT "6667" void error_handling(char *msg); void handler(int sig); typedef struct _info{ char *nick; char *host; char *port; char *user_name; char *user_whois1; char *user3; char *user_whois2; } INFO; INFO info = {NICK, HOST, PORT, "a", "b", "c", "d"}; int main(int argc, char *argv[]) { int sockfd; struct sockaddr_in ina; struct sigaction act; struct hostent *h; pid_t pid; char msg[MSG_MAX]; int msg_len; char check_ping[7]; char pong[11]; int join_flag = 0; sockfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if(sockfd == -1) error_handling("socket() error: sockfd"); h = gethostbyname(info.host); memset(&ina, 0, sizeof(ina)); ina.sin_family = AF_INET; ina.sin_addr = *(struct in_addr *)h->h_addr_list[0]; ina.sin_port = htons(atoi(info.port)); if(connect(sockfd, (struct sockaddr *)&ina, sizeof(ina)) == -1) error_handling("connect() error: "); act.sa_handler = handler; sigemptyset(&act.sa_mask); act.sa_flags = 0; sigaction(SIGCHLD, &act, 0); pid = fork(); if(pid == -1) error_handling("fork() error: "); else if(pid == 0){ while(1){ msg_len = recv(sockfd, msg, MSG_MAX-1, 0); if(msg_len > 0){ msg[msg_len] = ''; printf(msg); } if(strstr(msg, "NOTICE AUTH :*** Checking Ident") != NULL){ sleep(1); sprintf(msg, "user %s %s %s %sn", info.user_name, info.user_whois1, info.user3, info.user_whois2); send(sockfd, msg, strlen(msg), 0); sprintf(msg, "NICK %sn", info.nick); send(sockfd, msg, strlen(msg), 0); printf("Connect Initialization Succeed!n"); } else{ sscanf(msg, "%6c%s",check_ping, pong); if(strncmp(check_ping, "PING :", 6) == 0){ sprintf(msg, "PONG %sn", pong); send(sockfd, msg, strlen(msg), 0); if(join_flag == 0){ sleep(1); join_flag = 1; send(sockfd, "join #linuxn", 12, 0); } } } msg[0] = ''; } exit(0); } else{ fprintf(stderr, "Child Process Created!: pid = %dn", pid); } while(1){ fgets(msg, MSG_MAX, stdin); send(sockfd, msg, strlen(msg), 0); if(strcmp(msg, "quitn") == 0) break; } kill(0, SIGKILL); // . return 0; } void error_handling(char *msg) { fprintf(stderr, "%sn", msg); exit(-1); } void handler(int sig) { pid_t pid; int last; pid = waitpid(-1, &last, WNOHANG); fprintf(stderr, "Child Process Closed!: pid = %d, WEXITSTATUS = %Xn", pid, WEXITSTATUS(last)); }