Results 1 to 2 of 2
Dear all,
I'm trying to use fgets to read in Hex value
I need the memory value to appear as 0x08048760
however if I just type 08048760, the memory will ...
- 10-23-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 1
fgets in linux
Dear all,
I'm trying to use fgets to read in Hex value
I need the memory value to appear as 0x08048760
however if I just type 08048760, the memory will show 30 38 30 34 ..... (0 8 0 4 8 ....) instead
I read the following code from web
char shellcode[]=
"\xeb\x17\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\ x89\ x46\x0c\xb0\x0b\x89\xf3\x8d"
"\x4e\x08\x31\xd2\xcd\x80\xe8\xe4\xff\xff\xff\ x2f\ x62\x69\x6e\x2f\x73\x68\x58";
how come the above code can work? Why doesn't \x prefix working with fgets since it is saved in the char buffer too?
I have to use fgets
Thank you in advance
- 10-24-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
When you type in from the keyboard, the system puts ascii data into the buffer - 0 == 0x30, 8 == 0x38 which are the ascii values for the characters 0 and 8 respectively. If you are trying to input hex data to the application, then you need to decode the string data in the buffer you fill with fgets using atoh() or strtol() using 16 as the base.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote