220 likes | 295 Views
Part I The Basic Idea. return result. getURL. call getURL. IE. software. sequence of instructions in memory logically divided in functions that call each other function ‘IE’ calls function ‘ getURL ’ to read the corresponding page
E N D
return result getURL call getURL IE software • sequence of instructions in memory • logically divided in functions that call each other • function ‘IE’ calls function ‘getURL’ to read the corresponding page • in CPU, the program counter contains the address in memory of the next instruction to execute • normally this is the next address (instruction 100 is followed by instruction 101, etc) • not so with function call 204 203 202 201 200 104 103 102 101 100
PC PC PC PC PC PC PC PC PC PC software • sequence of instructions in memory • logically divided in functions that call each other • function ‘IE’ calls function ‘getURL’ to read the corresponding page • in CPU, the program counter contains the address in memory of the next instruction to execute • normally this is the next address (instruction 100 is followed by instruction 101, etc) • not so with function call return result 204 203 202 getURL 201 200 104 103 call getURL 102 IE 101 100
PC PC PC PC PC PC PC PC PC 1024 software 103 1023 • stack pointer (SP) • Points to last added entry • on the stack 1022 stack 1021 1020 • so how does our CPU know where to return? • it keeps administration • on a ‘stack’ return result 204 203 202 getURL 201 200 104 103 call getURL 102 IE 101 100
real functions variables getURL () { char buf[10]; read(keyboard,buf,64); get_webpage (buf); } IE () {getURL (); }
real functions variables getURL () { char buf[10]; read(keyboard,buf,64); get_webpage (buf); } IE () {getURL (); } 203 return result 202 getURL call read 201 200 104 103 call getURL 102 101 IE 100
real functions variables 103 1024 • frame pointer (FP) • Points to start of this function’s stack frame stack 1023 old FP 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 1020 1019 203 return result 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 1012 103 1011 call getURL 102 1010 101 IE 100
real functions variables 103 1024 stack 1023 old FP 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 1020 1019 203 return result 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 1012 103 1011 call getURL 102 1010 101 IE 100
real functions variables 103 1024 303 return stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result buf 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 1012 103 1011 call getURL 102 1010 101 1009 IE 1008 100 1007
real functions variables 103 1024 303 return stack stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result buf 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 64 1012 (buf) 103 1011 fd call getURL 102 1010 101 1009 IE 1008 100 1007
real functions variables 103 1024 303 return stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result buf 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 64 1012 (buf) 103 1011 fd call getURL 102 1010 101 202 1009 IE 1008 100 1007
real functions variables 103 1024 303 return frame pointer (FP) stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 64 1012 (buf) 103 1011 fd call getURL 102 1010 202 101 1009 IE 1023 1008 100 1007
real functions variables 103 1024 303 return stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 64 1012 (buf) 103 on “return from read” 1011 fd call getURL 102 1010 202 101 1009 IE 1023 1008 100 1007
real functions variables 103 1024 303 return stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 64 1012 (buf) 103 1011 fd call getURL 102 1010 POP 202 101 1009 IE 1023 1008 100 1007
real functions variables 103 1024 303 return stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 64 1012 (buf) 103 1011 fd call getURL 102 1010 202 101 1009 IE 1023 1008 100 1007
real functions variables 103 1024 303 return stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 64 1012 (buf) 103 1011 fd call getURL 102 1010 202 101 1009 IE RET 1023 1008 100 1007
real functions variables 103 1024 303 return stack 1023 old FP 302 read 301 1022 getURL () { char buf[10]; read(keyboard,buf,64);get_webpage(buf); } IE () {getURL (); } 1021 300 1020 1019 203 return result 1018 202 1017 getURL call read 201 1016 200 1015 1014 1013 104 64 1012 (buf) 103 1011 fd call getURL 102 1010 202 101 1009 IE 1023 1008 100 1007
1013 Exploit 103 1024 1023 1022 getURL () { char buf[10]; read(keyboard, buf, 64);get_webpage (buf); } IE () {getURL (); } 1021 1020 1019 buf 1018 1017 1016 1015 1014 1013 1012 1011 1010
Youmayalsooverwriteotherthings • For instance: • Other variables that are alsoon the stack • Otheraddresses • Etc.
Memory CorruptionFinal words Part I • We have sketched only the most common memory corruption attack • many variations, e.g.: • heap stack • more complex overflows • off-by-one • But there are others also • integer overflows • format string attacks • double free • etc. • Not now, perhaps later… *different kinds