SHARE
TWEET

Pwn 1

a guest Jun 15th, 2017 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(){
  5.  
  6.     struct User_login{
  7.         int id;
  8.         char usr[15];
  9.         char pwd[15];
  10. }DB={1337,"nobody","letmein"};
  11. char tmp_usr[15];
  12. char tmp_pwd[15];
  13.  
  14.  
  15. printf("Username : ");
  16. fgets(tmp_usr,128, stdin);
  17. tmp_usr[strcspn(tmp_usr,"\n")] = '\0';
  18. if((strcmp(DB.usr,tmp_usr)) != 0){
  19.     return 0;
  20. }
  21.  
  22. printf("Password : ");
  23. fgets(tmp_pwd,128, stdin);
  24. tmp_pwd[strcspn(tmp_pwd,"\n")] = '\0';
  25. if((strcmp(DB.pwd,tmp_pwd)) != 0){
  26.     return 0;
  27. }
  28.  
  29. if(!strcmp(DB.usr,"root")){
  30.     printf("You are root user");
  31.     system("cat flag.txt");
  32. }else{
  33.     printf("Access Granted, But you are %s\n", DB.usr);
  34. }
  35.  
  36. return 0;
  37. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top