rendered paste body/***************************************//*NanoIRCBot by nano a.k.a Quan Chi2 *//*(c) 2007 *//***************************************//* *//* usage: NanoIRCBot <serverip> *//* */ /***************************************/ /* C:\Program Files\Microsoft Visual Studio\MyProjects\NanoIRCBot\Debug */#include <winsock2.h>#include <stdio.h>#include <windows.h>#include <stdlib.h>#include <iostream.h>#define PORT 6667int main(int argc, char *argv[]){ char *nick = "NICK nanobot\r\n"; //bot name char *channel = "JOIN #social\r\n"; //PRIVMSG #social :[-]Hello world![-]\r\n //channel the bot will join char *user = "USER nanobot nanobot nanobot :nanobot bot\r\n"; char *entermsg = "PRIVMSG #test :[-]![-]\r\n"; char *exitmsg = "PRIVMSG #test :[-]Exit...[-]\r\n"; char buf[512]; if (argc != 2) { fprintf(stderr,"[-]Usage: NanoIRCBot <serverip>\n"); exit(1); } WSADATA WSAData; WSAStartup(MAKEWORD(2,0), &WSAData); //Winsock 2.0 SOCKET connection;//this is a socket named 'connection' SOCKADDR_IN sin; connection = socket(AF_INET, SOCK_STREAM, 0); //'connection' is a stream socket struct hostent *he; if ((he = gethostbyname(argv[1])) == NULL) //get the ip of parameter 1 in command prompt { perror("gethostbyname"); //if there is a problem in gethostbyname, print the error exit(EXIT_FAILURE); } sin.sin_addr = *((struct in_addr *)he->h_addr); //address to connect to sin.sin_family = AF_INET; //potocol AF_INET is everything sin.sin_port = htons(PORT); //the port the irc server has open for connections memset(&(sin.sin_zero), '\0', 8); connect(connection, (SOCKADDR*)&sin, sizeof(sin)); send(connection,nick,strlen(nick),0); send(connection,user,strlen(user),0); do { recv(connection,buf,512,0); if (strncmp("PING", buf, 4) == 0) { printf("[-]Received PING... Sending PONG\n"); buf[1] = 'O'; send(connection, buf, strlen(buf), 0); } //:nano!nano@X-80B69AC9.ny5030.east.verizon.net PRIVMSG #test :exit //C:\Program Files\Microsoft Visual Studio\MyProjects\NanoIRCBot\Debug if (strncmp("End of /MOTD command.", buf, sizeof(buf))) { send(connection,channel,strlen(channel),0); Sleep(1000); } printf("\n%s \n\n", buf, connection); }while(1); //if (strncmp("PRIVMSG #test :exit", buf, sizeof(buf))) // { // send(connection, exitmsg, strlen(exitmsg), 0); // break; // } return 0;}