I had to do a final project for my "information warfare" class, so I did it on exploiting buffer overflows. I wrote two programs, one which is exploited with a stack-smashing attack, and another which overflows a buffer on the heap and works by messing with the data used for virtual functions. Stack-smashing was covered in detail in a CS class I took a few years ago, but I've never read any info about actually exploiting buffer overflows in the heap.
I thought some people here might find them interesting, so here they are:
stack-smashing (poorly commented)
overflowing a heap-allocated buffer (better commenting)
If you actually compile them, you'll probably have to run them under a debugger, and they may still need to be modified to work in your own environment.
The first program requires user interaction (i.e. it acts like a legitimate program unless you attack it), and the second program exploits itself directly for simplicity.
The paper I wrote for the project is here, though the exploit-explanation to BS ratio is sort of low 😉.
I thought some people here might find them interesting, so here they are:
stack-smashing (poorly commented)
overflowing a heap-allocated buffer (better commenting)
If you actually compile them, you'll probably have to run them under a debugger, and they may still need to be modified to work in your own environment.
The first program requires user interaction (i.e. it acts like a legitimate program unless you attack it), and the second program exploits itself directly for simplicity.
The paper I wrote for the project is here, though the exploit-explanation to BS ratio is sort of low 😉.