Obviously the wildcard %x is not recognized as a byte hex value, so I get the error “ValueError: invalid \x escape”.
How to avoid this? I’m not familiar with python.
for i in xrange(0,length):
if i % 2 == 0:
tempArray.append(unpack("B",payload_raw[x])[0]^key)
x += 1
else:
randomByte = random.randint(65,90)
tempArray.append(randomByte)
for i in range(0,len(tempArray)):
tempArray[i]="\x%x"%tempArray[i]
for i in range(0,len(tempArray),15):
outArray.append("\n'"+"".join(tempArray[i:i+15])+"'")
outArray = "".join(outArray)
devide = "i % 2;"
open_structure = open(structure).read()
code = open_structure % (junkA,outArray,junkB,key,length,devide)
b.write(code)
b.flush()
chr()will give you the bytestring for a value between 0 and 255.