Lilliputian concerns – understanding endianness 

"It is computed that eleven thousand persons have at several times suffered death, rather than submit to break their eggs at the smaller end."
                                                                                                               –Gulliver's Travels

Take a break from the keyboard for a moment and enjoy a literary tidbit. In Gulliver's Travels by Jonathan Swift, published in 1726, our narrator and traveler Lemuel Gulliver tells of his adventure in the country of Lilliput. The Lilliputians are revealed to be a quirky bunch, known for deep conflict over seemingly trivial matters. For centuries, Lilliputians cracked open their eggs on the big end. When an emperor tried to enforce by law that eggs are to be cracked open at the little end, it resulted in rebellions and many were killed.

In the world of computing, it turns out that not everyone agrees on how bytes should be ordered in memory. If you spent a lot of time with networking protocols, you'll be used to what is intuitive for people who read from left to right: big-endian, meaning the most significant bits are in memory first. With little-endian, the least significant bits go first. In layman's terms, little-endian looks backwards. This is important for us as hackers because, like the Lilliputians, not everyone agrees on some things you may consider trivial. As a shellcoder and reverser in particular, you should immediately get comfortable with little-endian ordering as it is the standard of Intel processors.

Let's give a quick example using a hexadecimal word from memory. Let's say you want 0x12345678 to appear in the stack. The string you'd pass to the overflowing function is x78x56x34x12. When your exploits fail, you'll find yourself checking byte order before anything else as a troubleshooting step.

Now, we're going to get into the wacky world of shellcoding. We previously mentioned that stuffing 400 bytes of the ASCII letter z into the buffer caused the return address to be overwritten with 0x7a7a7a7a. What return address will we jump to if we execute the program with the following input? Try it out before moving on to the next section:

# demo $(python -c 'print "x7a"*300 + "xefxbexadxde"')

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.84.155