I'm back :?
I still wants to easily sends hexadecimal data by socket. I already has this piece of code:
Code:
file = fdopen(socket, "w");
fwrite("\x15\x00", 1, 2, file);
char data_hex[] = "\x20\x30\x40\x50";
fwrite(data_hex, 1, 4, file);
fwrite("\x14\x24\xbc", 1, 3, file);
fclose(tmp_file);
Code works fine, I see in my Wireshark that it's send exactly as I want, except that data_hex variable. It's sent not as hexadecimal value but mhm "plain text".
And it's my exact question: How can I pass to fwrite() some variable and cause fwrite() to send it as hexadecimal? In other words:
fwrite("\x20\x30\x40\x50", 1, 4, file); -> WORKS
fwrite(data_hex, 1, 3, file); -> DOESN'T WORKS
data_hex will have different values so I can't pass it as "\x20\x30\x40\x50"