unable to connect to remote device in python

0

I am trying to connect to my local NAS using SMBConnection

Below is the complete code

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()

I see that the access didn't go through , on further checking I see on wireshark an error code STATUS_BAD_NETWORK_NAME. I didn't see any reference for this issue , has any one seen similar error and figured out a way to get the access through , below is wireshark output

enter image description here

Edit 1 After removing Try catch block, i see the below error

OperationFailure: Failed to list Public2 on smbclient: Unable to connect to shared device ==================== SMB Message 0 ====================

SMB Header:

Command: 0x03 (SMB2_COM_TREE_CONNECT) Status: 0x00000000 Flags: 0x00 PID: 14404 MID: 3 TID: 0 Data: 62 bytes b'09000000480036005c005c004d00590043004c004f005500440045005800320055004c005400520041005c0073006d00620063006c00690065006e007400'

SMB Data Packet (hex):

b'fe534d42400000000000000003000000000000000000000003000000000000004438000000000000a9a30c72000000000000000000000000000000000000000009000000480036005c005c004d00590043004c004f005500440045005800320055004c005400520041005c0073006d00620063006c00690065006e007400' ==================== SMB Message 1 ====================

SMB Header:

Command: 0x03 (SMB2_COM_TREE_CONNECT) Status: 0xC00000CC Flags: 0x01 PID: 14404 MID: 3 TID: 0 Data: 9 bytes b'090000000000000000'

SMB Data Packet (hex):

b'fe534d4240000000cc0000c003000100010000000000000003000000000000004438000000000000a9a30c720000000000000000000000000000000000000000090000000000000000'

python
wireshark
smb
asked on Stack Overflow Jan 27, 2019 by brijeshv • edited Jan 28, 2019 by brijeshv

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0