Tuesday, October 18, 2005

Hide Mp3 in GIF

its surprising but , yeah , it is possible to hide a mp3 inside a harmless looking gif. It is really one of the most simplest methods of steganography.

just type in following dos command at your command prompt

c:\> copy image.gif + music.mp3 new_image.gif

The command will append the mp3 file to the end of GIF file.

This new file can viewed as an image file and can be played as an mp3. however this file will play ONLY in winamp. i dont know why so, but i couldnt get it playing in WMP.

The following shows a C# sample code of doing the above.

public void Embed(string imageFile,string mp3File,string outputPath)
{
FileStream readImage=new FileStream(imageFile,FileMode.Open);
FileStream readMp3=new FileStream(mp3File,FileMode.Open);
FileStream write=new FileStream(outputPath,FileMode.Create);
int readByte;
while((readByte=readImage.ReadByte())>=0)
{
write.WriteByte((byte)readByte);
}
while((readByte=readMp3.ReadByte())>=0)
{
write.WriteByte((byte)readByte);
}
readImage.Close();
readMp3.Close();
write.Close();
}