Skip to content

Instantly share code, notes, and snippets.

@juliusknorr
Last active August 29, 2015 14:02
Show Gist options
  • Save juliusknorr/cb8e1ed5a89519c7a1d0 to your computer and use it in GitHub Desktop.
Save juliusknorr/cb8e1ed5a89519c7a1d0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Change byte order of 4-byte words
# Usage: ./revert.py "\x00\x01\x02\x03"
#
# output \x03\x02\x01\x00
import sys
if len(sys.argv) != 2:
print("Usage: revert.py [SHELLCODE]")
exit()
shellcode = sys.argv[1]
#hex = "".join(["\\x%02x" % ord(c) for c in shellcode])
hex = shellcode
print("Input: %s" % hex)
list = hex.split("\\x")[1:]
listnew = []
i = 0
while i < len(list):
word = [ list[3+i], list[2+i], list[1+i], list[0+i] ]
for c in word:
listnew.append('\\x%s' % c)
i+=4
print("Output: %s" % ''.join(listnew))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment