Is this what you thought of?
>>> bytes('\x54\x68\x69\x73\x20\x70\x72\x6F\x67\x72\x61\x6D\x20\x6D\x75\x73\x74\x20\x62\x65')
'This program must be'
>>>
if you would wanted to use that in a script:
#!/usr/local/bin/python
# You can encode the python instructions on this webpage:
# http://www.string-functions.com/string-hex.aspx
#
#
# The following hex string encodes this:
# for i in xrage(0,10):
# print i
thestring = "\x66\x6f\x72\x20\x69\x20\x69\x6e\x20\x78\x72\x61\x6e\x67\x65\x28\x30\x2c\x31\x30\x29\x3a\x0d\x0a\x20\x20\x20\x20\x70\x72\x69\x6e\x74\x20\x69"
# Demonstration of possible code injection
# in the function:
thehack = "import os;os.system('echo foobar')"
def hex2string(myhexstring):
"""be carefull with this function possible codeinjection"""
myhexcmd = bytes("%s" % myhexstring)
exec myhexcmd
hex2string(thestring)
kind regards,
Dirk