def __connect_tree(self, path, service, password, timeout = None):
if password:
# Password is only encrypted if the server passed us an "encryption" during protocol dialect
# negotiation and mxCrypto's DES module is loaded.
if self.__enc_key and DES:
password = self.__deshash(password)
self.__send_smb_packet(SMB.SMB_COM_TREE_CONNECT_ANDX, 0, 0x08, 0, 0, 0, pack('<BBHHH', 0xff, 0, 0, 0, len(password)), password + string.upper(path) + '\0' + service + '\0')
else:
self.__send_smb_packet(SMB.SMB_COM_TREE_CONNECT_ANDX, 0, 0x08, 0, 0, 0, pack('<BBHHH', 0xff, 0, 0, 0, 1), '\0' + string.upper(path) + '\0' + service + '\0')
while 1:
data = self.__sess.recv_packet(timeout)
if data:
cmd, err_class, err_code, flags1, flags2, tid, _, mid, params, d = self.__decode_smb(data)
if cmd == SMB.SMB_COM_TREE_CONNECT_ANDX:
if err_class == 0x00 and err_code == 0x00:
return tid
else:
raise SessionError, ( "Cannot connect tree. (ErrClass: %d and ErrCode: %d)" % ( err_class, err_code ), err_class, err_code )
smb.py 文件源码
python
阅读 36
收藏 0
点赞 0
评论 0
评论列表
文章目录