[PLUG] stack smash issue

abhi abhi.elementx at gmail.com
Fri Jul 31 04:35:56 PDT 2009


Hello all.
 I m trying to smash(change the return address) the stack.

I think i m missing the correct numbers(sue to differences in krnl and gcc
versions).
Heres the code :

#include<stdio.h>
void function(int a, int b, int c) {
char buffer1[5];
char buffer2[10];
int *ret;

ret = buffer1 + 9;//I think that ret address is 5 bytes away...
(*ret) += 7;//diff between actual ret address and target
}

int main() {
int x;
x = 0;
function(1,2,3);
x = 1;//shud skip this
printf("%d\n",x);//shud print 0
return 0;
}



The program prints 1 when it shud print 0.

I m using ubuntu 9.04 kernel 2.6.28-14-generic and gcc version 4.3.3 (Ubuntu
4.3.3-5ubuntu4)

Cud someone tell me how to find the  size of the arrays, variables on stack
from the assembly code?

Thank u.


More information about the plug-mail mailing list