Stack memory corruption exploitation
Stack memory exploitation may not be the most likely source of Android bugs and security vulnerabilities, though it is still possible for these kinds of memory corruption bugs to affect native Android executables even in the midst of protections such as ASLR, StackGuard, and SE Linux. In addition to this, most of the Android market share consists of devices that don't have as robust protection against stack and other memory-based exploitation, namely 2.3.3 Gingerbread devices. Another great reason—besides its direct relevance to security research—to include a discussion and walkthrough on stack-based exploitation is because it provides a great gateway into more advanced exploitation techniques.
In this section we will detail how to exploit a common stack-based memory corruption flaw to take control of the flow of execution.
Getting ready
Before we start, you'll need to prepare a vulnerable executable; here's how you do it:
Create a directory with the usual...