SHARE
TWEET

Untitled

a guest Apr 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4.  
  5. int main(int argc, char const *argv[])
  6. {
  7.     if (argc == 2)
  8.     {
  9.         setuid(0);
  10.         char pwd[100], cmd[400];
  11.  
  12.         printf("New password:\n");
  13.         scanf("%s", pwd);
  14.  
  15.         sprintf(cmd, "echo -n '%s\\n%s' | /usr/bin/passwd %s &> /dev/null", pwd, pwd, argv[1]);
  16.         // printf("%s\n", cmd);
  17.         // system(cmd);
  18.         // if (!system("echo $? &> /dev/null"))
  19.         // {
  20.         //     printf("Password for user %s is now changed successfully.\n", argv[1]);
  21.         // } else {
  22.         //     printf("Something went wrong, password for user %s is unchanged.\n", argv[1]);
  23.         // }
  24.         printf("%s\n", cmd);
  25.     } else {
  26.         printf("./fake_passwd user\n");
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top