Setting up the Linux Environment
Introduction
Welcome to the workshop on Linux exploit development.In this workshop, we will explore how you can work on exploit development while being on Linux as an operating system. To complete this workshop, you are supposed to have prerequisite requirements in Linux as an operating system.
Prerequisite• Knowledge of TCP/IP protocols
• Basic knowledge of Linux as an Operating System
• Prior hands-on experience with Linux
• Sound Knowledge of “C” programming on Linux
• Understand socket programming
Lab Requirements
To complete this workshop, you basically need a Linux operating system and programming skills.To entertain all levels of audience, we will still present how to setup Linux as an Operating System on Virtual Machine.
We will be setting up Ubuntu Linux on VMware Fusion on Mac OS.
Download Link: https://my.vmware.com/web/vmware/downloads.
We will then be using GDB (GNU Debugger) for debugging the program and GCC (GNU C Complier) for compiling the code. The programming language which we will be working with is “C”.
We will also present sample code for practicing exploit development on Linux platform. You are also free to use any Linux operating system,we recommended Kali Linux or Ubuntu.
Download Ubuntu
Download Link: http://www.ubuntu.com/download/desktop.
Setup VM for Ubuntu
You
should be able to install the virtual machine software on your own or
use virtual box if you are not familiar with VMware fusion on Mac OX.
Open VM Library and follow below steps in order to setup VM and install Ubuntu and prepare your Ubuntu BOX.
Next, click new and continue to setup new virtual machine and you will see below screen as shown in figure.
Next, select more options and continue and you will see below screen as shown below.
Select create a custom virtual machine to continue and you will see below screen.
Now select Linux and Ubuntu as shown in above figure, continue the setup.
You can modify these setting as shown in coming steps, continue and do the need full as suggested.
Now, customize the settings as shown in below steps.
Here you can choose any name you’d like and continue.
Now you can change the memory size as per your setting and availability of memory in your hardware machine.
Setup NAT as shown in above figure.
Connect the CD and select the Ubuntu Image, which you should have downloaded from the link presented above and shown below after selection of image.
Now run the machine and you should be able to see the below screen.
Shortly, Ubuntu will ask you for the following options; it is recommended that you should install Ubuntu.
Click Install Ubuntu and continue as shown below.
Continue if you are meeting the requirements as shown in above figure.
Select erase disk and install Ubuntu and click install now.
Select your geographical location and continue installing.
Select Keyboard layout and continue.
Setup login details and continue.After this step, it will start installing Ubuntu and if all goes well, you will be able to see below screen.
Now restart the machine and login to your fresh installation copy of Ubuntu Desktop.
Ubuntu desktop comes with pre installation of GNU and GDB; just ensure that they are available. For this, run the terminal and check by typing the commands and hit tabs as shown in below figure.
You can see that GCC and GDB are installed already.
Some Basics
What is GCC?
GCC is basically a “C” programming language compiler and stands for GNU Compiler Collection and includes front ends for C, C++, Objective-C, Fortran, Java, Ada, and Go, as well as libraries for these languages (libstdc++, libgcj,...). GCC was originally written as the compiler for the GNU operating system.
Vendor Website: https://gcc.gnu.org/.
What is GDB?
GDB is basically a debugger called GNU Debugger or project debugger, which allows you to see what is going on inside another program during its execution
GDB can perform certain tasks as of its main kind or types as claimed by the vendor. These are listed below.
• Start your program, specifying anything that might affect its behavior.
• Make your program stop on specified conditions.
• Examine what has happened, when your program has stopped.
• Change things in your program so you can experiment with correcting the effects of one bug and go on to learn about another.
Vendor Website: http://www.gnu.org/software/gdb/.
Key Note
These
two software programs don’t depend on Ubuntu but are freely available
for any Linux based operating system. Most of the well known Linux OSs
come pre-installed with these software programs as they form the base of
many key programs specially designed for programmers and development
sides.
It is well known in the industry of exploit development that you should be good at understanding Linux if you want to become an expert in exploit coding.
GDB Environment
To make good use of GDB, you need to know a handful of its commands in order to perform required tasks. It’s worthwhile that you should memorize or practice these commands to be familiar with the GDB environment. For your reference, we have provided the list of commands available in the GDB environment so that you don’t need to search.