6.1 Overflow1
6.1 Overflow1
http://www.cs.rpi.edu/
~hollingd/netprog/overflow.ppt
Addresses
00000000 low
Netprog: Buffer Overflow 9
18
addressof(y=3) return address
Sample saved stack pointer
y
Stack x
buf
address of s address of s
return-address pointer to pgm
saved sp
buf
Small Program
void execls(void) {
execv("/bin/ls",args);
printf(“I’m not printed\n");
}
Netprog: Buffer Overflow 16
Generating a String
• You can take code like the previous
slide, and generate machine language.
• Copy down the individual byte values
and build a string.
• To do a simple exec requires less than
100 bytes.
Real program
i nt
po ere (exec /bin/ls or whatever)
an h
C yw e
an her
in
nop instructions
nop instructions