- Apr 25, 2015
- 1,845
- 2
- 2,199
- 327
Part 1: Introduction to Linux Exploit Development
Tools Of The Trade
Definitely working mirror: https://users.ece.utexas.edu/~adnan/gdb-refcard.pdf
Umm... probably print the gdb shit out.
---
Part 2: Linux Format String Exploitation
Resources:
Exploiting Format String Vulnerabilities (by scut): Link
Advances in format string exploitation (by gera & riq): Link
Introduction
Sample code used in the first and second part of the video tutorial:
Format String Tutorial
Hello and welcome! As I'm sure you know by know, if your reading this, I have a passion for exploit development. My journey into Windows exploit development has even taken me into the depths and insanity of Ring0 exploitation [Thx Ryujin for expanding the pain!]. I will continue to write and publish Windows exploit development tutorials but the time has come for FuzzySecurity to branch out into Linux exploitation! A good friend and colleague of mine Donato Capitella (aka kyuzo) has graciously offered to share his knowledge on this subject matter with us and I know we can all learn a lot from his experience. I won't bore the reader with an overly long introduction, I will just mention that these tutorials require a certain familiarity with general Operating System Internals (nothing that a good Google-search won't teach you). Now go forth and get yourself a shell!!
Tools Of The Trade
Dead link was (1, followed by mirror 2/3): https://www.cs.berkeley.edu/~mavam/teaching/cs161-sp11/gdb-refcard.pdf // http://www.cs.ucr.edu/~nael/cs153/resources/gdbcard.pdf // https://inst.eecs.berkeley.edu/~cs61c/resources/gdb-refcard.pdfA Brain/Persistence
Keep your head cool, read up on subject matter topics, enjoy bending your OS to your strength and pop a shell!
Linux GDB Debugger - Quick reference guide
GNU debugger or more typically referenced as gdb is the default debugger on Linux and is also the defacto debugger we will be using in these tutorials. The command line interface can be a bit daunting at first but once you get used to it you will not regret the effort. If you want to use a graphical debugger you can try edb (Evan's Debugger) which is skinned to be similar to OllyDBG on windows.
Virtualization Software
Basically there are two options here VirtualBox which is free and Vmware which isn't. If its possible I would suggest using Vmware; a clever person might not need to pay for it ).
Definitely working mirror: https://users.ece.utexas.edu/~adnan/gdb-refcard.pdf
Umm... probably print the gdb shit out.
---
Part 2: Linux Format String Exploitation
Welcome to the first part in our Linux Exploitation Tutorial Series. Again I would like to thank kyuzo for taking the time to share his knowledge with us! In this part we will be looking at Format String Exploitation. Format string vulnerabilities usually occur when a programmer wants to print out a user controlled function but does not sanitize the user input allowing the malicious attacker to inject their own format specifiers. This in turn allows the malicious attacker to read and write arbitrary memory.
In my own attempt to educate myself in the fundamentals of format string exploitation I read two most excellent resources: (1) Exploiting Format String Vulnerabilities [scut / Team Teso – 2001] and (2) Advances in format string exploitation [gera & riq / Phrack – 2002]. I have included links to both resources below and I can highly recommend them for background reading.
Before we get to the good stuff I just want to mention that by default gdb unassembles opcode in AT&T syntax, for those of us who have done allot of Windows exploit development this is a bit confusing. Fortunately you can easily change the disassembly flavor in gdb with the following commands..
Code:
set disassembly-flavor intel
set disassembly-flavor att
Resources:
Exploiting Format String Vulnerabilities (by scut): Link
Advances in format string exploitation (by gera & riq): Link
Introduction
A few months ago b33f and myself put together a workshop on software exploitation to be presented in a university environment. The workshop had two main ideas: (1) deal with non-buffer overflow exploitation vulnerabilities and (2) talk about both Windows and Linux. So I picked up a list of less glamorous and more esoteric(!) vulnerabilities; among these we decided to include format strings, as they have been quite important in the last few years as far as Linux is concerned. Just to mention one, at the beginning of 2012 sudo was released with a format string flaw in the sudo_debug function and that was shipped with main-stream distributions like Fedora and OpenSUSE.
After the workshop, I had promised b33f I would contribute some material to FuzzySecurity and, a few months later, I finally made up my mind and decided to make a couple of videos about format string exploitation.
Sample code used in the first part of the video tutorial:
C++:
/* example.c
*
* $ gcc -o example example.c
* $ execstack -s example # make stack executable
*/
#include <stdio.h>
int main() {
int a = -5;
float b = 5.5;
char *c = "My String";
printf("A = %d, B = %f, C = %s\n", a, b, c);
}
Sample code used in the first and second part of the video tutorial:
C++:
/* fmt.c - sample program vulnerable to format string exploitation
*
* $ gcc -o fmt fmt.c
* $ execstack -s fmt # make stack executable
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
char b[128];
strcpy(b, argv[1]);
printf(b);
printf("\n");
}
Format String Tutorial
The first video offers an introduction to what format strings are and how they can lead to information leakages (some of the topics include: conversion specifiers usage and direct parameter access). The second part moves things a step forward and shows how to own a program leveraging arcane format string features like the evil %n conversion specifier!