All pastes #497860 Raw Edit

Something

public c v1 · immutable
·published 2007-05-20 02:55 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <errno.h>#include <string.h>#include <netdb.h>#include <sys/types.h>#include <netinet/in.h>#include <sys/socket.h>#define PORT 6667 //IRC port#define MAXDATASIZE 512;int main(int argc, char *argv[]){	if (argc != 2)	{		fprintf(stderr,"[-]Usage ircbot <serverip>\n");	       exit(1);	}	int connection, numbytes;	char buf[512];	struct hostent *he;	struct sockaddr_in sin;	if ((he = gethostbyname(argv[1])) == NULL)	{		herror("gethostbyname");		exit(1);	}	if ((connection = socket(PF_INET, SOCK_STREAM, 0)) == -1)	{		perror("socket");		exit(1);	}	sin.sin_family 	  = AF_INET;	sin.sin_port 	  = htons(PORT);	sin.sin_addr      = *((struct in_addr *)he->h_addr);	memset(&(sin.sin_zero), '\0', 8);		if(connect(connection, (struct sockaddr *)&sin, sizeof(struct sockaddr)) == -1)	{		perror("connect");		exit(1);	}        char *user    = "USER nanobot nanobot2 nanooo :nano\r\n"; //user		char *nick    = "NICK nanobot\r\n"; //bot nick	send(connection, nick, sizeof(buf), 0);	send(connection, user, sizeof(buf), 0);		while(1)	{			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);		}		printf("buf : %s \n", buf, connection);	}	return 0;}