I am trying to generate ascii to javascript unicode , and I could generate it , but after checking some aspects . I notice my program is eating the last part of the string. how can I fix this?
import binascii
content = 'string\n'
first_byte = ""
second_byte = ""
shellcode = ""
flag = 0
for b in content:
if flag == 0:
shellcode += "%u"
first_byte = binascii.hexlify(b)
flag += 1
else:
second_byte = binascii.hexlify(b)
shellcode += second_byte
shellcode += first_byte
flag = 0
print shellcode
my output from the script
%u6c62%u6361%u6c6b%u6965%u7574%u
desired one, but in general whatever string
%u6c62%u6361%u6c6b%u6965%u7574%u0a73