Buffer Overflow Vulnerability Lab实验记录

    科技2022-07-11  116

    一次缓冲区溢出攻击实验,难度不高,利用了C的栈指针存储原理。在此简单记录一下。

    实验官网地址:http://www.cis.syr.edu/~wedu/seed/Labs_12.04/Software/Buffer_Overflow/

    文章目录

    禁用地址随机化程序源码获取str起始地址函数栈结构图

    禁用地址随机化

    程序源码

    /* stack.c */ /* This program has a buffer overflow vulnerability. */ /* Our task is to exploit this vulnerability */ #include <stdlib.h> #include <stdio.h> #include <string.h> int bof(char *str) { char buffer[24]; /* The following statement has a buffer overflow problem */ strcpy(buffer, str); return 1; } int main(int argc, char **argv) { char str[517]; FILE *badfile; badfile = fopen("badfile", "r"); fread(str, sizeof(char), 517, badfile); bof(str); printf("Returned Properly\n"); return 1; } /* call_shellcode.c */ /*A program that creates a file containing code for launching shell*/ #include <stdlib.h> #include <stdio.h> const char code[] = "\x31\xc0" /* xorl
    转载请注明原文地址:https://blackberry.8miu.com/read-2334.html
    最新回复(0)