Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

sending unicode over a socket

Hello, im trying to send a hexed message over a socket but it doesnt seem to want to send it as unicode but instead some weird message

what im trying to send

Code
char *UBERKEK = "echo -ne '\x7f\x45\x4c\x46\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00\x01\x00\x00\x00\xac\x83\x00\x00\x34\x00\x00\x00\xd0\x04\x00\x00\x02\x00\x00\x04\x34\x00\x20\x00\x04\x00\x28\x00\x07\x00\x06\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x80\x00\x00\x78\x04\x00\x00\x78\x04\x00\x00\x05\x00\x00\x00\x00\x80\x00\x00\x01\x00\x00\x00\x78\x04\x00\x00\x78\x04\x01\x00\x78\x04\x01\x00\x10\x00\x00\x00\x10\x00\x00\x00\x06\x00\x00\x00\x00\x80\x00\x00\x07\x00\x00\x00\x78\x04\x00\x00\x78\x04\x01\x00' \n";

how im sending it
Code
send(fd ,UBERKEK, strlen(UBERKEK),0);

What I get
Code
ELF(▒▒4▒4 (▒▒xx▒xxx▒xx

what I want it to send

Code
echo -ne '\x7f\x45\x4c\x46\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00\x01\x00\x00\x00\xac\x83\x00\x00\x34\x00\x00\x00\xd0\x04\x00\x00\x02\x00\x00\x04\x34\x00\x20\x00\x04\x00\x28\x00\x07\x00\x06\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x80\x00\x00\x78\x04\x00\x00\x78\x04\x00\x00\x05\x00\x00\x00\x00\x80\x00\x00\x01\x00\x00\x00\x78\x04\x00\x00\x78\x04\x01\x00\x78\x04\x01\x00\x10\x00\x00\x00\x10\x00\x00\x00\x06\x00\x00\x00\x00\x80\x00\x00\x07\x00\x00\x00\x78\x04\x00\x00\x78\x04\x01\x00
then you need to double escape the hex values
First of all you don't need to double-escape them because then you need to translate those escaped representation of hex values back into bytes from a string. You need to avoid strlen() because this will stop at the first occurrence of a null-terminating byte for a non-unicode string.

Unicode strings don't use char *.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
The process of sending unicode string via sockets is the same as sending any data using sockets. Just pass the pointer to the data and correct size of the data to be sent. Like the user above me said, dont use strlen to calculate unicode string length.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by KeatFeb 21, 2019 08:28 PM 3 182 Feb 21, 2019 08:28 PM
Last Post: 0xDEAD10CC
[Python] by Vishnu™May 6, 2018 02:15 AM 4 208 May 6, 2018 02:15 AM
Last Post: Blackshield_real
[C#] by DeadKubeAug 22, 2017 03:25 PM 41 1,776 Aug 22, 2017 03:25 PM
Last Post: 0xDEAD10CC