我正在尝试使用NAS
连接到本地SMBConnection
下面是完整的代码
from smb.SMBConnection import SMBConnection
def connector():
conn =SMBConnection('admin','********',remote_name='MyCloudEX2Ultra',my_name='DESKTOP-I7')
ret =conn.connect('192.168.0.102')
print("return val " + str(ret))
res = conn.listPath(service_name= 'smbclient' ,path= '/Public2')
for i in res:
print (i)
return
if __name__ == "__main__":
print("In main module")
ret = connector()
我发现访问没有通过,进一步检查时,我在Wireshark上看到错误代码STATUS_BAD_NETWORK_NAME
。我没有看到有关此问题的参考,也没有人看到类似的错误,并想出了一种通过该途径进行访问的方法,下面是wireshark输出
编辑1 删除Try catch块后,我看到以下错误
OperationFailure:无法在smbclient上列出Public2:无法连接到共享设备 =================== SMB讯息0 ==================
命令:0x03(SMB2_COM_TREE_CONNECT) 状态:0x00000000 标志:0x00 PID:14404 中端:3 TID:0 数据:62字节 b'09000000480036005c005c004d00590043004c004f005500440045005800320055004c005400520041005c0073006d00620063006c00690065006e007400'
b'fe534d42400000000000000003000000000000000000000003000000000000004438000000000000a9a30c72000000000000000000000000000000000000000000000000000000000000000036036005c005c004d00590043004c004f005500440045005800320055004c005400520041005c0073006d00620063006c00690065006e007400' =================== SMB消息1 ==================
命令:0x03(SMB2_COM_TREE_CONNECT) 状态:0xC00000CC 标志:0x01 PID:14404 中端:3 TID:0 数据:9个字节 b'090000000000000000'
b'fe534d4240000000cc0000c003000100010000000000000003000000000000004438000000000000a9a30c720000000000000000000000000000000000000000000000000000090000000000000000'