CSE 351: Week 6
Tom Bergan, TA
1
CSE 351: Week 6 Tom Bergan, TA 1 Today Questions on the midterm? - - PowerPoint PPT Presentation
CSE 351: Week 6 Tom Bergan, TA 1 Today Questions on the midterm? Lab 3 2 Lab 3: Buffer Overflow This has a buffer overflow The Stack in getbuf() : int getbuf() { : char buf[36]; Gets(buf); return addr return 1; } saved regs
1
2
3
int getbuf() { char buf[36]; Gets(buf); return 1; }
The Stack in getbuf()
return addr
: :
saved regs (if any) local vars
This has a buffer overflow Why?
4
int getbuf() { char buf[36]; Gets(buf); return 1; }
The Stack in getbuf()
return addr
: :
saved regs (if any) local vars
This has a buffer overflow Why?
5
int getbuf() { char buf[36]; Gets(buf); return 1; }
The Stack in getbuf()
return addr
: :
saved regs (if any)
This has a buffer overflow Why?
: buf [35] : buf [0] :
36 bytes{
6
int getbuf() { char buf[36]; Gets(buf); return 1; }
Goal: call the smoke() function from getbuf() The Stack in getbuf()
return addr
: :
saved regs (if any) : buf [35] : buf [0] :
36 bytes{
How?
so we “return” to smoke()
7
Goal: call fizz() with a special parameter (your “cookie”)
int getbuf() { char buf[36]; Gets(buf); return 1; }
The Stack in getbuf()
return addr
: :
saved regs (if any) : buf [35] : buf [0] :
36 bytes{
8
Goal: call fizz() with a special parameter (your “cookie”)
How?
(the write-up tells you which instructions to use)
int getbuf() { char buf[36]; Gets(buf); return 1; }
The Stack in getbuf()
return addr
: :
saved regs (if any) :
: : (your code here)
:
9
How? Same as before!
int getbuf() { char buf[36]; Gets(buf); return 1; }
Goal: call bang() after writing your “cookie” to a global variable The Stack in getbuf()
return addr
: :
saved regs (if any) :
: : (your code here)
: