C'est normal que le dd ne fonctionne pas : regarde ton fichier img.jpg après
dd if=./img.hex of=./img.jpg
tu verras, c'est le même que img.hex
Je peux te proposer un truc qui fonctionne :
Pour avoir le fichier en hexadécimal, utilise la commande hd :
hd image.jpg > img.hex
Tu obtiens un fichier img.hex du genre :
00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 00 |......JFIF......|
00000010 01 00 00 ff fe 00 3b 43 52 45 41 54 4f 52 20 67 |......;CREATOR g|
00000020 64 2d 6a 70 65 67 20 76 31 2e 30 20 28 73 69 6e |d-jpeg v1.0 (sin|
00000030 67 20 49 4a 47 20 4a 50 45 47 20 76 32 29 2c 20 |g IJG JPEG v2), |
00000040 71 75 61 6c 69 74 79 20 3d 20 39 0a ff db 00 43 |quality = 9....C|
00000050 00 02 01 01 01 01 01 02 01 01 02 02 02 02 02 04 |................|
00000060 03 02 02 02 02 05 04 04 03 06 05 06 06 06 05 06 |................|
00000070 06 06 07 09 08 06 07 09 06 06 08 0b 08 09 0a 0a |................|
00000080 0a 0a 0a 06 08 0b 0c 0a 0c 09 0a 0a 0a ff db 00 |................|
00000090 43 01 02 02 02 02 02 05 03 03 05 0a 07 06 07 0a |C...............|
000000a0 0a 0a 0a 0a 0a |.....|
Tu modifies ce que tu veux (mais uniquement les codes ASCII, pas le bazar dans la colonne de droite), tu sauves dans un fichier img-mod.hex, puis tu utilises ce script:
#!/bin/bash
# Sauve ce script dans un fichier hd2ascii
# Rends-le executable : chmod +x hd2ascii
while read -a A ; do
M=${#A[@]}-2
((M>16)) && ((M=16))
for ((i=1;i<=M;++i)); do
(( u=(16#${A[i]}) ))
printf \\$((u/64*100+u%64/8*10+u%8))
done
done
Pour utiliser le script :
./hd2ascii < img-mod.hex > img-mod.jpg
Sinon, plus simple, il existe des éditeurs hexadécimaux :
hexcurse, hexer, hexedit, ghex, bless, okteta, lfhex, shed, tweak, jeex, ...
a+
- GG