LyScript
LyScript copied to clipboard
调用Debuger.is_connect()导致连接异常断开
例子
C:\>python
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from x64dbg import Debugger
>>> dbg = Debugger()
>>> dbg.connect()
True
>>> dbg.get_thread_id()
29796
>>> dbg.get_thread_id()
29796
>>> dbg.is_connect()
True
>>> dbg.get_thread_id()
False
>>> dbg.is_connect()
False
>>> dbg.get_thread_id()
False
>>> dbg.connect()
True
>>> dbg.get_thread_id()
29796
>>> dbg.get_thread_id()
29796
>>> dbg.is_connect()
True
>>> dbg.get_thread_id()
False
现象
看起来Debugger.is_connect()会导致连接异常断开 ,但是调用connect()又能重新连接上。
原因
检查x64dbg库的__init__.py后发现在Debugger类中定义了两次is_connect()方法,第一次在L468,该版本与本仓库中的版本一致,无问题。但是在L6420再次定义的版本中
def is_connect(self):
try:
send_struct = MyStruct()
send_struct.ControlId = SocketIsConnectDef
send_buffer = send_struct.pack()
self.sock.send(send_buffer)
recv_flag = self.sock.recv(18)
if recv_flag.decode("utf8") == "Connection Enabled":
return True
else:
return False
except Exception:
return False
return False
虽然也能正确返回Connection Enabled,但却会导致连接断开。
由于python在同一个类中多次定义同样签名的方法会导致覆盖,因此只有L6420处的方法会被实际执行。
也许应该更新一下pip源上的x64dbg包?