I got an image file img.jpg and did the following
strings img.jpg | hexdump -C
which gave me this output
Now I need to get the camera and date information using ac programm with open, lseek and read ... My question is, how do I jump to the date 2015:08:05 with lseek?
I tried to use the offset 0x40 but don't really know what's going on ...
Edit: As pointed out in the answers the 2 of 2015 should be in 2015 but this code doesn't output 2 but 0.
int rd = lseek(filedesc, 0x49, SEEK_SET);
if(rd < 0){
perror("lseek");
close(filedesc);
return 1;
}
read(filedesc, &output, 1);
printf("%d", output);
0x40
is the address represents the beginning of the row. The 2
in 2015
is in address 0x49
- that's the address you need. Its content is 32
in Hexa or 2
as text.
In every row, the addresses go like that - for the line begins with 0x40
:
0x40 0x41 0x42 ... 0x48 0x49 0x4A 0x4B ... 0x4F
. Then begins the next row.
The columns in the file are:
You should check of course that this offset is true for every JPG file.
ADDITION: Running hexdump -C
will give different results when executing on strings img.jpg
and when executing on img.jpg
. If you're searching for a specific data in the file you should examine cat img.jpg | hexdump -C
cat img.jpg | hexdump -C
. The offsets there will fit the results of fopen
the file and then lseek
in it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.