#!/usr/bin/python import pwn import re import time r = pwn.remote('0c2450d17014ac4e.247ctf.com', 50319) while not r.can_recv(0): time.sleep(0.5) # can be substituted by True to speed up the process (: while r.can_recv(0): answ = r.recvline().decode('utf-8') ns = re.findall("\d{1,4}", answ) if len(ns) == 2: sum = int(ns[0]) + int(ns[1]) ans = bytes(str(sum) + '\r\n', 'utf-8') r.send(ans) time.sleep(0.05) else: print(answ)