daily pastebin goal
9%
SHARE
TWEET

Path reversing for assembly in python

heret1c Mar 14th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. # reverses a string and converts it to hex for further use.
  3. # written by heret1c
  4. import sys
  5. s = sys.argv[1]
  6. #reverse string
  7. reversed = s[::-1]
  8.  
  9. #printout
  10. sys.stdout.write("Reversed:\t ")
  11. sys.stdout.write(reversed)
  12.  
  13. while len(reversed) % 4 != 0:
  14.     index = reversed.find('/')
  15.     reversed = reversed[:index] + '/' + reversed[index:]
  16. sys.stdout.write("\r\nReversed filled: ")
  17. sys.stdout.write(reversed)
  18. sys.stdout.write("\r\nReversed Hex ready to paste!:\r\n")
  19. #convert it to hex
  20. reversedHex = "".join("{:02x}".format(ord(c)) for c in reversed)
  21.  
  22. for i,c in enumerate(reversedHex):
  23.     if i % 8 == 0:
  24.         sys.stdout.write("\r\n\t\tpush dword 0x")
  25.     sys.stdout.write(c)
  26. sys.stdout.write("\r\n")
  27. sys.stdout.write("\r\n")
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