How I used eog utility to pull off a small Linux exploit

Back in 2012, after my article on Linux ELF Virus was published in Linux Journal, I was curious to come up with a trigger point for this virus. I mean what would compel a Linux user to execute it for the very first time? I thought about it many times but could not come up with something in a working state.

Cut to the present times – Last Friday, when I was coming back from my office through office bus, I was indulged in some technical talk with a guy who works on encoders and decoders for various media file formats. Suddenly the same thought struck in my mind and I asked him whether it is possible for him to come up with a situation where a Linux user clicks on an image file, the image gets displayed but a notorious code gets executed in the back end?

Initially both of us were thinking on how an executable can be run from an image displaying program. After a while, an idea struck my mind. I said how about reversing the approach, ie, can we display an image (using an image display program) from within an executable? Well, the answer was YES. All we need is a command line utility for displaying images that can be run from within the code.

I sat down today to find such a command line utility. Since I was aiming a proof of concept so I was looking forward to any decent command line utility that can do the trick. Soon, I found out a utility named eye of gnome or eog. As I already use gnome desktop environment so I though of giving it a try.

With all the comments, I think the code is self explanatory. But, for the records, here is what this code intends to do :

Use eog utility to display a small icon image for a lock.

The code itself contains the buffer of image so it does not depend on any external image.

After the user closes the window of image displayer program, a small notorious piece of code is executed.

This code opens 5 back to back separate Firefox tabs with a message – YOU GOT TRICKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :-).

Just like image buffer, the HTML buffer is also contained within the program so it does not have any dependency on any external HTML page.

Further, what I did is, I compiled this code and named the output binary as lockImage.

$ gcc -Wall image.c -o lockImage

Now, when I ran this binary, here is what I saw :

(Click to Enlarge)

So we can see that the small icon image was displayed. Now, when I closed this image display window, this is what happened :

(Click to Enlarge)

Back to back 5 tabs of Firefox were opened with the HTML page saying that YOU HAVE GOT TRICKED!!!!!!!!!!!!!!!!!!!!!!! .

I know most of you will say stuff like :

What if eog is not present on a Linux system?

What if Firefox is not present on a Linux system?

…..All sorts of failure scenarios….

etc

Well, all I can say is that its just a proof of concept and nothing more than that, but all major things start with proof of concepts correct? I am not saying that this THE solution but at least this is what I think can lead to something meaningful which can be integrated with the actual code written in this article.

There are a couple of real improvements that I have to think about it as of now. These are :

Instead of naming it to something like lockImage, I would like to rename it to lockImage.png. Reason being, the name lockImage.png produces a file icon that can make anyone believe that it is a PNG file. But, when I rename it as .png, it’s mime type gets changed and hence a double click on this file triggers the default Image displayer program of your desktop environment. Which obviously fails to display it as it is an executable file. So, a name ending with .png coupled with the fact that a mouse click on file executes it, is what I desire.

Then comes the second problem,. This is more of a generic problem, whenever I’ll send this file to someone over e-mail and the other person downloads it, the file will not have execute permissions by default. Achieving this is really desirable.

I know that this is a kiddish start but I would really appreciate if you can provide your inputs to make it a better solution.

NOTE – For those who think that I am encouraging virus development, I would like to argue that I have not given any destructive code neither in this article, nor in my article on Linux Journal. My motive is to explore more about Linux and stuff related to it and if in the process I can bring up a loop hole then it would be great for Linux community as it can be corrected without any delay.

About Himanshu Arora

Himanshu Arora is a software programmer, open source enthusiast and Linux researcher. He writes technical articles for various websites and blogs. Some of his articles have been featured on IBM developerworks, ComputerWorld and in Linux Journal. He is the administrator of the blog and also contributes useful posts on the blog. Visit his google+ profile or mail him at himanshuz.chd[at]MAILSERVER[dot]com (where MAILSERVER=gmail)

4 thoughts on “How I used eog utility to pull off a small Linux exploit”

I am confused, you are just creating an executable which opens an image and then opens 5 firefox windows with html content. Why did you not do it in shell script, 2 mins you would be done.

Now, for executable I would need to execute it whereas for image, I need to display it. So, unless you have something that can execute out of image display utility, I think you cannot call it a Proof of Concept.

Thanks for sharing your opinion Amit. Doing it with shell script was a definite possiblity but I wanted the file to be in form of machine code (executable) rather than plain text (shell script) which anybody can see.

On the other part, you are absolutely correct. What I was really looking forward to was something that can execute out of image display utility. But I could not find anything like that. If you read my article, I said exactly the same at the beginnning.

Whether it’s a proof of concept or not, its your own opinion. I believe if the shortcomings that I have listed towards the end can be addressed, it would become exactly what I want.

It’s rather an old post, But I think I’ll leave my opinion just in case you know sth new and want to share.
I remember a virus in “windows”, It was an”executable file” with “exe” extension and it had the icon that is used for pictures in windows by default.
By default windows doesn’t show the extension, so you didn’t know that this is executable, you just double click that file and windows shows you a picture, but in the background the virus is spreading…
This is the same thing that you’ve done here. BUT…
In linux, there is “executable permission”! which makes it impossible for a virus to spread using internet or flash drives! (Fat file system doesn’t support file permissions).
In linux, By default you are a USER, and you don’t have SU permissions, so the virus can do no harm to your system.
And I’ve studied some of “media formats” like “mpeg, jpeg, h264,…” and they can not run any harmful code!
Permissions in linux is the most important feature that makes linux a SAFE OS.
The only way to make a user run your code is packaging it in a zip file and send the user the instruction to run the virus. And believe me, there are people who would just do as they’re told by strangers no matter what…

Himanshu Arora is a software programmer, open source enthusiast and Linux researcher. He writes technical articles for various websites and blogs. Some of his articles have been featured on IBM developerworks, ComputerWorld and in Linux Journal. He is the administrator of MyLinuxBook and also contributes useful posts on the blog. When he is not busy writing articles, he likes to explore various food joints in his city, explore new hill stations and party at weekends. You can catch him on Google+.