| 10 | from qiling.const import QL_VERBOSE |
| 11 | |
| 12 | class SimpleGdbClient: |
| 13 | DELAY = 0.6 |
| 14 | |
| 15 | def __init__(self, host: str, port: int): |
| 16 | sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) |
| 17 | txtf = sock.makefile('w') |
| 18 | |
| 19 | sock.connect((host, port)) |
| 20 | |
| 21 | self.__sock = sock |
| 22 | self.__file = txtf |
| 23 | |
| 24 | def __enter__(self): |
| 25 | return self |
| 26 | |
| 27 | def __exit__(self, ex_type, ex_value, ex_traceback): |
| 28 | self.__sock.close() |
| 29 | |
| 30 | @staticmethod |
| 31 | def checksum(data: str) -> int: |
| 32 | return sum(ord(c) for c in data) & 0xff |
| 33 | |
| 34 | def send(self, msg: str): |
| 35 | time.sleep(SimpleGdbClient.DELAY) |
| 36 | |
| 37 | self.__file.write(f'${msg}#{SimpleGdbClient.checksum(msg):02x}') |
| 38 | self.__file.flush() |
| 39 | |
| 40 | class DebuggerTest(unittest.TestCase): |
| 41 |
no outgoing calls