Guest User

Untitled

a guest
Nov 23rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. /*
  2. run first: sudo echo 0 > /proc/sys/kernel/randomize_va_space
  3. compile code with: gcc buffer-overflow.c -o vuln_disable_canary -fno-stack-protector
  4. buffer will overflow if you input a long string
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. int main()
  11. {
  12. char buff[10];
  13. int pass = 0;
  14.  
  15. printf("\n Enter the password : \n");
  16. gets(buff);
  17.  
  18. if(strcmp(buff, "helloworld"))
  19. {
  20. printf ("\n Wrong Password \n");
  21. }
  22. else
  23. {
  24. printf ("\n Correct Password \n");
  25. pass = 1;
  26. }
  27.  
  28. if(pass)
  29. {
  30. /* Now Give root or admin rights to user*/
  31. printf ("\n Root privileges given to the user \n");
  32. }
  33.  
  34. return 0;
  35. }
Add Comment
Please, Sign In to add comment