buf=int(p.recv()[20:34],16)
buf2sfp =int(p.recv()[31:33])
buf2cnry = length-8
fir_input = b'Q'*(buf2cnry +1)
p.sendafter(b'Input:',fir_input)
recv를 사용하면 sendafter이 안되고 타임 아웃이 되던데 이유가 너무 궁금합니다
buf,buf2sfp,buf2cnry까지 값이 정상적으로 잘 들어갔는데 sendafter만 이해가 안가서 질문해봅니다.
일단 sendafter에서 오류가 나는게 아닙니다.
두번째 p.recv()
를 호출한 buf2sfp =int(p.recv()[31:33])
에서 타임아웃이 난겁니다.
buf=int(p.recv()[20:34],16)
에서 recv을 호출할때
b'Address of the buf: 0x7fffe63a20d0\n'
b'Distance between buf and $rbp: 96\n'
b'[1] Leak the canary\n'
b'Input: '
위에 같이 출력된 모든 스트링을 받아왔습니다.
이 상태에서 buf2sfp =int(p.recv()[31:33])
에서 recv을 호출한다면 다음 출력을 계속해서 기다리게됩니다.
하지만 프로그램은 이 다음에 어떠한 출력도 내지 않습니다.
recvline은 한줄만 받는 함수이므로 개행문자까지만 출력을 받습니다.
만약 recvline을 호출한다면
buf=int(p.recvline()[20:34],16)
에서
b'Address of the buf: 0x7fffe63a20d0\n'
까지만 일단 받고
buf2sfp =int(p.reclinev()[31:33])
에서
b'Distance between buf and $rbp: 96\n'
까지만 받습니다.
이제 여기서p.sendafter(b'Input:',fir_input)
가 실행되면
b'[1] Leak the canary\n' b'Input: '
출력을 받은 후 fir_input을 보내게됩니다.