Skip to content

Instantly share code, notes, and snippets.

@jorotenev
Last active November 13, 2016 14:34
Show Gist options
  • Save jorotenev/8171c5ec478ee2b0f556e6a62e3fe193 to your computer and use it in GitHub Desktop.
Save jorotenev/8171c5ec478ee2b0f556e6a62e3fe193 to your computer and use it in GitHub Desktop.
example3.c from "smashing the stack for fun and profit"
#include <stdio.h>
#include <string.h>
void function(int a, int b, int c) {
char buffer1[5];
char buffer2[10];
int *ret;
ret = buffer1 + 12;
(*ret) += 8;
}
void main() {
int x;
x = 0;
function(1,2,3);
x = 1;
printf("%d\n",x);
}
// http://phrack.org/issues/49/14.html#article
// the `x=1` in the main will be jumped
/*
Stack contents as per gdb:
Variable | Address
------------------
c 0xbffff618
b 0xbffff614
a 0xbffff610
ret 0xbffff60c
sfp ...
buffer1 0xbffff5ff
buffer2 0xbffff5f5
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment