I had an idea (crazy i know) to hide messages inside the data of image files just so i could say to some random idiot "hey you did it nerd, congrats and ____ you". So what did I do? One word, Notepa- thats two. So I opened up notepad and started typing, after all, I had corrupted files like this before. It'll be as easy as plucking the hairs off a bald cat. So I added some text and saved the ima- Corrupted. The same way as if I had just changed the file extension, bummer. What if I just changed a single lette- Corrupted. Oh, What if I change the letter, save, then change it ba- Corrupted. Huh. What if I dont change anything and just save the fi- Corrupted.
You can probably guess that I lost my ____ at that, but what exactely happened? Well, after a few more tests I found that the notepad-saved image had no metadata for the image width, height or dimensions. My brain immediately went to the obvious place to learn more but it was correlation not causation. Google led me to reddit, archive.org, superuser and wikipedia (again), but heres what I learnt. Lets start with how files store data. As far as I'm aware, files have three sections, a header with information about what type of file the file is, the content which is the content, and the footer, which tells the system that any data afterward is not what you're looking for. Now for the Notepad stuff. Notepad shows text to you in the standard ASCII, which is normal. It has a huge list of characters and numbers and its a mix and match thing. What it doesnt know how to do is null characters (hex 00), so instead of throwing a hissy fit and crashing, it changes it to a space. Cool righ- WRONG. Spaces have a different value (hex 20) from null characters and as such, the header of the file gets its 00s turned into 20s (which is reversible) and the file is unreadable because the OS thinks that the file extension is wrong and you're trying to do something funky. If you're trying anything similar to this, I recommend getting/using sublime, its free.