Friday, April 3, 2015

Convert any string into HEX \x41\x41 bytes array

A little add-on to previous blogpost, here is a short script in python that will convert your input string to \x00\x00 bytes array:


from struct import pack
import sys

W  = '\033[0m'  # white (normal)
G  = '\033[32m' # green
if not len(sys.argv[1:]):
  print '\n\t%sUsage: string2hex "alert()"%s\n\n\t\tWill output \'\\x61\\x6C\\x65\\x72\\x74\\x28\\x29\'\n' % (G,W)

b = sys.argv[1]

print '%s%s%s' % (G,''.join(["\\x%02X" % ord( x ) for x in b]),W)

root@nopernik:~# string2hex "<script>alert()</script>" 

No comments:

Post a Comment