1.查看文件保护题目名提示为整数溢出ELF32 开启了NX(数据不可执行)运行程序欢迎提示后是一个选项,选1则要求输入名字和密码,判断后输出提示,退出程序;选2则直接退出程序2.IDA静态分析(1)main较为简单的程序逻辑:选1后执行login()(2)login()接收长度为0x19的username并在Hello中输出再接收一个为0x199的passwd返回中执行check_passwd()跟进check_passwd()passwd长度为3-7时提示成功,在范围之外提示失败,并且在输出提示后清空输出缓冲区,最后执行strcpy将passwd复制给dest并返回用来存储passwd的变量v3类型为无符号的int8,范围为[0,255],超出255就会发生整数溢出,而程序读入passwd输入时,大小为0x199,远远超出此范围,因此可以利用。(3)查看字符串窗口看到关键字符cat flag跟进并查看交叉引用找到一个what_is_this()函数,其内容为执行系统命令输出flag内容,其地址为0804868B(4)思路整理构建一个指定长度的串,传入函数,整数溢出突破if函数的判断,
一、ELF文件结构Linux下的可执行文件格式为ELF(Executable and Linkable Format),类似Windows的PE格式。ELF文件格式比较简单,PWN参赛者最需要了解的是ELF头、Section(节)、Segment(段)的概念。ELF头必须在文件开头,表示这是个ELF文件及其基本信息。ELF头包括ELF的magic code、程序运行的计算机架构、程序入口等内容,可以通过“readelf-h”命令读取其内容,一般用于寻找一些程序的入口。ELF文件由多个节(Section)组成,其中存放各种数据。描述节的各种信息的数据统一存放在节头表中。ELF中的节用来存放各种各样不同的数据,主要包括:❖ .text节——存放一个程序的运行所需的所有代码。❖ .rdata节——存放程序使用到的不可修改的静态数据,如字符串等。❖ .data节——存放程序可修改的数据,如C语言中已经初始化的全局变量等。❖ .bss节——用于存放程序的可修改数据,与.data不同的是,这些数据没有被初始化,所以没有占用ELF空间。虽然在节头表中存在.bss节,但是文件中并没有对应的数据。在程序
Norman1z