Book Image

Learning Pentesting for Android Devices

By : Aditya Gupta
Book Image

Learning Pentesting for Android Devices

By: Aditya Gupta

Overview of this book

Table of Contents (18 chapters)
Learning Pentesting for Android Devices
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Simple stack-based buffer overflow


In simple words, a buffer is a place to store any kind of data. An overflow occurs when the data in the buffer exceeds the size of the buffer itself. An attacker can then perform an overflow attack so as to get control of the program and execute malicious payloads.

Let's use an example of a simple program and see how we could exploit it. In the following screenshot, we have a simple program with three functions: vulnerable, ShouldNotBeCalled, and main. The following is the program we are trying to exploit:

The ShouldNotBeCalled function is never called during the entire runtime of the program.

The vulnerable function simply copies the argument into a buffer named buff that is 10 bytes in size.

Once we have finished writing the program, we could compile it using gcc, as shown in the next command. Also, we will disable the Address Space Layout Randomization (ASLR) here, just to make the scenario a little bit simpler. ASLR is a security technique implemented by...