I want to send a post request to REST api, but with all my characters unicode encoded, for example the string test i want to send as \u0074\u0065\u0073\u0074. Whatever i try, the string ends up as \\u0074\\u0065\\u0073\\u0074. I can easily modify the request in for example Burp, and remove the double backslashes, to make it work.
So the raw bytes sent to the webserver is \x5c\x5c\x75\x30\x30\x37\x34\x5c\x5c\x75\x30\x30\x36\x35\x5c\x5c\x75\x30\x30\x37\x33\x5c\x5c\x75\x30\x30\x37\x34
While what i want is:
\x5c\x75\x30\x30\x37\x34\x5c\x75\x30\x30\x36\x35\x5c\x75\x30\x30\x37\x33\x5c\x75\x30\x30\x37\x34
One of the things I've tried is this:
import requests
s = 'test'
data = ''
for c in s:
data += "\\u00"+hex(ord(c))[2:].lower()
print(data)
json = {"user":data}
res = requests.post('http://127.0.0.1/api/getusers', json=json)
print(res.text)
even if i set data = '\x5c\x75\x30\x30\x37\x34\x5c\x75\x30\x30\x36\x35\x5c\x75\x30\x30\x37\x33\x5c\x75\x30\x30\x37\x34' is still sends double back slahes (\x5x\x5c)