从题目中可以看出,本题应该是一个没有提供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.查看文件保护64位,开启了NX(数据不可执行)、Canary(栈保护)和Full RELRO(无法修改GOT表)运行程序图画之后的提示中有两个secretsecret[0] is 12b32a0secret[1] is 12b32a4用户输入名字后,出现一大段故事,接着有两次选择:(1)east or up?选up后会让用户重新选择,所以只能选east(2)选east后:there(1)or leave(0)?输入0选择leave,则程序输出一段字符后程序退出输入1后程序提示用户输入一个地址和一个愿望,接着程序输出一段字符后退出2.IDA静态分析(1)main程序逻辑分析:1)启动计时器后执行sub_400996,接着定义数组v4,且v4[0]=68,v4[1]=852)第13、14行给出的secret是v4[0](68)和v4[1](85)的地址3)输出一系列字符串后执行sub_400D72(2)sub_400996输出off_603010,跟进后发现为asc_400F98,内容为龙的图画(3)sub_400D72判断角色名长度小于0x28,执行之后三个函数1)sub_400A7
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(数据不可执行)运行程序欢迎提示后是一个选项,选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函数的判断,
1.查看文件保护64位程序,开启了NX(堆栈不可执行)、CANNARY(栈保护)和PIE(地址随机化)运行程序输出欢迎提示后,让用户输入名字和所猜数字,中间可能经过数字判断,输出错误提示GG后程序退出2.IDA静态分析(1)main程序逻辑分析:1)通过srand()和rand生成随机数,与用户输入的数进行对比。2)要成功猜中十次,错一次都会输出“GG!”然后退出程序;猜中10次后执行sub_C3E(2)sub_C3E输出成功提示后,执行系统命令输出flag。(3)思路整理所以本题关键在于,将随机数变成可控的数rand函数产生随机数的时候,需要一个种子,如果这个种子是一样的话,产生的随机数也是一样的。 因为用户先要输入name,要是我们通过main第22行的gets(),输入一个很长的字符串,刚好把seed的值覆盖掉,那么seed的产生的随机值就会成为可控的一个序列。v7的地址与seed相差0x203.解题(1)通过main第22行的gets()的输入,直接覆盖seed种子的值,将其固定为0(2)再通过cdll.LoadLibrary()拿到libc的函数来计算随机数 EXP代码如下
Norman1z