As a part of an assignment I'm working on, I'm trying to read hex values from a file using the following code steps:
char buf[2048];
FILE *fp = fopen("/home/httpd/AS1/binary.bin", "r");
fgets(buf, 1024, fp);
I created a binary file that has values like for example /xff/xff/xff .... etc
and every time I read the file using the provided code, the hex values (shellcode) get change into different numerical values
I also cannot modify to ready the values in a loop one at a time as I am supposed to use the code as is.
I tried creating the file containing the values in various ways:
$ vi shcode.bin
$ vi shcode
I input the values into the file in various ways:
/xff/xff/xff
"/xff/xff/xff"
ÿÿÿ
and every time I read the file, the values gets changed.
I spent countless hours trying to find a solution with no result. Could you please help with what I'm doing wrong