Saturday 14 July 2012

Fiddle with Binary Files

I know I promised myself to blog regularly... But the thing is: The solution to the problems I could imagine are already available on the vast Internet (Dude, If Internet wasn't here, I can't even imagine the scenario).. So Moral of the story is: I don't like to write about something which is available on the first page search results of any search engine available out there.
Moving on the topic I was thinking to write about someday.. Today is the Day.. :) Lets start.

NOTE: While reading the following, avoid the text in parenthesis.. It makes grasping the text difficult for some people, it seems.
The average programmer around you is a worker who would write code for the artificial problems available on the websites or asked by the employers to write... And The day ends for them. They use the compilers and interpreters to  Solve the problem. Created binaries and run.. If its working.. Story over. Lets go to bed.
For me too, the day goes like this now-a-days. But you see I work at Night too. So I started some experiments.. As you already know I would love to be able to understand binary files and hack them as I see fit.. This post is the funny(supposed to be) introduction where I try to look into binary files.. Here no theories is being provided for static binaries, dynamic binaries etc. (Static binaries are complete in themselves binary which do not depend on the library provided by the operating system to execute. whereas dynamic binaries use the other libraries to be able to execute). The binary file used in linux machines have elf format. i.e. Executable and linkable format...  The file is composed for various headers, sections and lot of other things, which in general is not supposed to be known for an average programmer. We don't need the details here either...

As its a well known truth that: In Linux, Everything is A File.  (Exceptions are there, which I don't care about, but if you don't believe in this fact. -> You don't care to learn un*x machines..  I don't care about you moron then.)
Now that you'll always keep this fact in your conscience, read on further...

So in linux (we are not bothering about other un*x systems here), You can modify the file and try to make it work a bit differently. You can't mess with the functionality of the binary files (Its what I believe but it can be b*llsh*t too) but you can most probably always tweak the appearance a bit...  Which is essentially what I am gonna' demonstrate here....

Moving a bit in different direction, I also like the games which I can play in terminal emulators.. The games you wanna' try are ninvaders, moon-buggy, packman for console..  These are few of my favorites.  `fortune | cowsay` is  a nice fun command if you have those two installed on your machine.  I would like you to love these games too (atleast pretend that you love them for the sake of this post).. Ok, atleast install ninvaders and play a bit with it. It'd be fun I promise..

Supposing that you have the ninvaders installed on your linux system, start the game. . Its a game where you are at the bottom of the game window represented by /-^-\  and you have to shoot the aliens coming down with the bullets which are represented by '!'. That's right, /-^-\  is the player's sprite and the character ! is used as bullets in the game..  You shoot with the spacebar ( or k if you're a vim guy). Move with arrow keys (or with h and l, if you're a vim guy).. 

Sorry for this incomplete post. Will complete it as soon as possible.

To be continued....  :)

No comments:

Post a Comment