2018-5-2 缓冲区溢出攻击实验

2018-5-2 缓冲区溢出攻击实验

实验环境:实验楼自带的linux虚拟系统

1.sudo apt-get update
更新linux,主要是下载C的编译器
enter description here
enter description here
enter description here

2.进入linux操作环境并使用bash
enter description here

3.关闭系统地址的随机分配,立于之后寻址找到有漏洞的缓冲区。
此外,为了进一步防范缓冲区溢出攻击及其它利用shell程序的攻击,许多shell程序在被调用时自动放弃它们的特权。因此,即使你能欺骗一个Set-UID程序调用一个shell,也不能在这个shell中保持root权限,这个防护措施在/bin/bash中实现。

linux系统中,/bin/sh实际是指向/bin/bash或/bin/dash的一个符号链接。为了重现这一防护措施被实现之前的情形,我们使用另一个shell程序(zsh)代替/bin/bash。下面的指令描述了如何设置zsh程序:
enter description here

4.写shellcode
这里已经给出了,所以直接copy一下就行。
enter description here
5.输入漏洞代码
enter description here
6.编译
GCC编译器有一种栈保护机制来阻止缓冲区溢出,所以我们在编译代码时需要用 –fno-stack-protector 关闭这种机制。

而 -z execstack 用于允许执行栈。
enter description here

7.获得缓冲区地址
enter description here
enter description here
根据语句 strcpy(buffer+100,shellcode); 我们计算shellcode的地址为 0xffffd350(十六进制)+100(十进制)=0xffffd3b4(十六进制)

现在修改exploit.c文件!将 \x??\x??\x??\x?? 修改为 \xb4\xd2\xff\xff

然后,编译exploit.c程序:
enter description here
enter description here
8.获得ROOT权限
enter description here

猜你喜欢

转载自www.cnblogs.com/nalanruntu/p/8979816.html
今日推荐