08/08/2020
How do hackers attach virus to files (like jpg files)?
~ How do hackers attach virus to files (like jpg files)?
Swipe. Match. Chat. Download Tinder.
A2A
I think it’s pretty clear that what you have is not technically a virus, but I’m not going to bother to go through all the correct terminology of the difference between a virus, a worm, a data handler exploit, a container exploit, and so forth. You can look those up.
Mostly, they do not “attach viruses” to data files.
While it’s true that it’s possible to embed a “macro virus” in a data file, such as a Word document, or another document with active code content, JPEG files (.jpg) do not have active content components, unlike word processing files.
Instead, you have to exploit the data handler.
The way you do this is to understand that all software has bugs.
You identify the bug in the software that handles the JPEG image.
There are a number of steps between pulling a JPEG image out of storage, and putting it up on the screen. At a minimum, they involve:
Opening the JPEG
Using the contents of the JPEG in order to turn it into a bitmap; this process is called “rendering”
Typically, JPEG exploits involve the renderer.
You give the renderer an intentionally malformed image file, and it goes off into the weeds because of this. Because you know the software that makes up the renderer, you have it go off into the weeds in a very specific way, which causes it to interpret the remainder of the data in the JPEG as computer instructions.
This typically involves a buffer overflow attack into a stack variable (a so-called “stack smash”) that causes the rendering function to return to the incorrect address, which happens to be in part of the stack, which contains the data that shouldn’t be in the JPEG file in the first place (but is, because it’s intentionally malformed).