logo

Understanding Buffer Overflow: Stack and Heap Buffer Overflows, Exploiting Buffer Overflow, JOP and ROP

   

Added on  2023-06-07

11 Pages1080 Words283 Views
1. Understanding Buffer Overflow
1.1 Stack Buffer Overflows
a) Architecture of Stack OverFlow
Before Stack-Overflow
Understanding Buffer Overflow: Stack and Heap Buffer Overflows, Exploiting Buffer Overflow, JOP and ROP_1
After Stack-Overflow
b) Program Execution
#include <stdio.h>
int main(int argc, char *argv[])
{
char buf[12];
memcpy(buf, argv[1], strlen(argv[1]));
printf(buf);
}
As stack grows from bottom to top, memory address decreases from high to low
Buf size: 12 bytes
Frame pointer 4 bytes
Return address 4 bytes
Arguments 4 bytes
Understanding Buffer Overflow: Stack and Heap Buffer Overflows, Exploiting Buffer Overflow, JOP and ROP_2
1.2 Heap buffer overflow
a)
Understanding Buffer Overflow: Stack and Heap Buffer Overflows, Exploiting Buffer Overflow, JOP and ROP_3
b) Testing Program
int main(int argc, char *argv[])
{
......
vulnerable(argv[1]);
return 0;
}
int vulnerable(char *buf)
{
HANDLE hp = HeapCreate(0, 0, 0);
HLOCAL chunk = HeapAlloc(hp, 0, 260);
strcpy(chunk, buf); ''' Vulnerability'''
Understanding Buffer Overflow: Stack and Heap Buffer Overflows, Exploiting Buffer Overflow, JOP and ROP_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Common Errors in C Programming and How to Fix Them
|6
|1243
|342

Common Programming Errors and Security Measures
|9
|2871
|70

Secure Systems Programming
|13
|1507
|3

Secure Programming in C
|14
|2158
|367