Now i used SMBConnection from pysmb directly instead of @brumm 's SMB client. Everything is the same; can use it with guest account but could not with authenticated user. So, i tried this very same code on OSX and and on IPad Pro.
Under OSX this works perfectly without any authentication problem. However, under IPad IOS; it simply doesnt work:
import socket
from smb.SMBConnection import SMBConnection
import logging
import platform
username = 'admuser'
password = 'admpass'
server_ip = '192.168.1.20'
system_name = 'SMBSERVER'
share_name = 'general'
logging.basicConfig(filename='example.log', level=logging.DEBUG)
print (socket.gethostname())
conn = SMBConnection(username=username, password=password, my_name=socket.gethostname(), remote_name=system_name, use_ntlm_v2=True)
conn.connect(server_ip, 139)
logging.info(conn.listPath(share_name,'/'))
conn.close()
OSX:
INFO:SMB.SMBConnection:Authentication with remote machine "FEBSTATION" for user "febalci" will be using NTLM v2 authentication (with extended security)
INFO:SMB.SMBConnection:Now switching over to SMB2 protocol communication
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_NEGOTIATE" (command:0x0000 flags:0x0001)
INFO:SMB.SMBConnection:SMB2 dialect negotiation successful
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_SESSION_SETUP" (command:0x0001 flags:0x0001)
INFO:SMB.SMBConnection:Performing NTLMv2 authentication (on SMB2) with server challenge "b'7c9f209be7a4da06'"
INFO:SMB.SMBConnection:Performing NTLMv2 authentication (on SMB2) with server challenge "b'7c9f209be7a4da06'"
DEBUG:SMB.SMBConnection:NT challenge response is "b'3ccca33bd0d432f9efdc8280caf3e4870101000000000000000000000000000010af8ad0e64fc2a70000000002001400460045004200530054004100540049004f004e0001001400460045004200530054004100540049004f004e0004000200000003001400660065006200730074006100740069006f006e0007000800506d040a3fe2d40100000000'" (138 bytes)
DEBUG:SMB.SMBConnection:LM challenge response is "b'4582a0d54eb37d03d5f306266811552410af8ad0e64fc2a7'" (24 bytes)
INFO:SMB.SMBConnection:Server supports SMB signing
INFO:SMB.SMBConnection:SMB signing deactivated. SMB messages will NOT be signed.
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_SESSION_SETUP" (command:0x0001 flags:0x0009)
INFO:SMB.SMBConnection:Authentication (on SMB2) successful!
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_TREE_CONNECT" (command:0x0003 flags:0x0001)
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_CREATE" (command:0x0005 flags:0x0001)
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_QUERY_DIRECTORY" (command:0x000E flags:0x0001)
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_QUERY_DIRECTORY" (command:0x000E flags:0x0001)
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_CLOSE" (command:0x0006 flags:0x0001)
INFO:root:[, , , , , , , , , , , , , ]
IOS:
INFO:SMB.SMBConnection:Authentication with remote machine "FEBSTATION" for user "febalci" will be using NTLM v2 authentication (with extended security)
INFO:SMB.SMBConnection:Now switching over to SMB2 protocol communication
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_NEGOTIATE" (command:0x0000 flags:0x0001)
INFO:SMB.SMBConnection:SMB2 dialect negotiation successful
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_SESSION_SETUP" (command:0x0001 flags:0x0001)
INFO:SMB.SMBConnection:Performing NTLMv2 authentication (on SMB2) with server challenge "b'f0202135e4a8887e'"
INFO:SMB.SMBConnection:Performing NTLMv2 authentication (on SMB2) with server challenge "b'f0202135e4a8887e'"
DEBUG:SMB.SMBConnection:NT challenge response is "b'5592e18ef198ca1331d9e4c86e035d8d010100000000000000000000000000001bddb210e8e728520000000002001400460045004200530054004100540049004f004e0001001400460045004200530054004100540049004f004e0004000200000003001400660065006200730074006100740069006f006e00070008000e278c4f40e2d40100000000'" (138 bytes)
DEBUG:SMB.SMBConnection:LM challenge response is "b'f69c607446c5e5d044e3d694a49b3bab1bddb210e8e72852'" (24 bytes)
INFO:SMB.SMBConnection:Server supports SMB signing
INFO:SMB.SMBConnection:SMB signing deactivated. SMB messages will NOT be signed.
DEBUG:SMB.SMBConnection:Received SMB2 message "SMB2_COM_SESSION_SETUP" (command:0x0001 flags:0x0001)
INFO:SMB.SMBConnection:Authentication (on SMB2) failed. Please check username and password.
This line on OSX has flags 0x0009 whereas in IOS it is 0x0001; Like if the password is wrong. Yeah this still gives nothing, i try to use wireshark on Ipad hoping i might catch something; but Apple changed UDID structure of newer devices, so i have to wait for the new version of XCode. At least i understand that it is directly a problem on pysmb side...