Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Files App or SMB access to NAS and read filenames from it
-
Maybe I can check it at the weekend. Stay tuned.
-
@brumm Thanks. But don't sacrify your week-end 😀
-
user = '' works
user = 'bad user' works<==================
user = 'correct user' does not work -
Mmmh, same here...
print(smb.has_authenticated) #true if emptyAuthentication (with extended security) successful! #username+password empty
vs.
Authentication (with extended security) failed. Please check username and password. #username+password correctSo maybe you like to open an issue or switch to impacket???
-
@brumm what is strange is that I use a smb connection to a usb key connected to my router and only a correct user is accepted, thus perhaps the code is correct but needs some parameters for the nas.
In the case of the usb slot of my router, there is no free user defined. -
The SMB dialect negotiation is always good, but the authentication fails in my case. Don't know if SMB signing deativated is okay... it is always deactivated with my smal travel router. So if you like you can check the base.py file and log the output.
-
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:[<smb.base.SharedFile object at 0x10f898ac8>, <smb.base.SharedFile object at 0x10f898b70>, <smb.base.SharedFile object at 0x10f898ba8>, <smb.base.SharedFile object at 0x10f898be0>, <smb.base.SharedFile object at 0x10f898c50>, <smb.base.SharedFile object at 0x10f898c88>, <smb.base.SharedFile object at 0x10f898cc0>, <smb.base.SharedFile object at 0x10f898d30>, <smb.base.SharedFile object at 0x10f898da0>, <smb.base.SharedFile object at 0x10f898dd8>, <smb.base.SharedFile object at 0x10f898e10>, <smb.base.SharedFile object at 0x10f898e48>, <smb.base.SharedFile object at 0x10f898e80>, <smb.base.SharedFile object at 0x10f898eb8>]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...
-
@febalci I'm really sorry but I can't help, just 😢
-
If there's no need for python3, again, I recommend the impacket library. Here you can find a working ui example. Just make sure that impacket and ntpath.py is installed.
If you like to go further with pysmb, then you find more information in the Microsoft openspecs of SMB2 (Connecting to a Share by Using an SMB2 Negotiate, Message Syntax and SMB2 Packet Header - SYNC). Good luck! -
@febalci connect with your little script to a flash drive in an usb slot of my router, log follows, hoping it could help you because I'm not enough skilled in this matter.
Edit: no error even if invalid user or invalid password, thus that does not help at all, sorry
INFO:SMB.SMBConnection:Authentication with remote machine "VOO-USB" for user "admin" will be using NTLM v2 authentication (with extended security) DEBUG:SMB.SMBConnection:Received SMB message "SMB_COM_NEGOTIATE" (command:0x72 flags:0x88 flags2:0xC001 TID:0 UID:0) INFO:SMB.SMBConnection:SMB dialect negotiation successful (ExtendedSecurity:False) INFO:SMB.SMBConnection:Performing NTLMv1 authentication (without extended security) with challenge "b'11a5b2121f990f0c'" and hashed password of "b'b167b87b195510e8f49cc5dc2cf310e87497d7cc991c4908'" DEBUG:SMB.SMBConnection:Received SMB message "SMB_COM_SESSION_SETUP_ANDX" (command:0x73 flags:0x88 flags2:0xC001 TID:0 UID:0) DEBUG:SMB.SMBConnection:SMB uid is now 0 INFO:SMB.SMBConnection:Authentication (without extended security) successful! DEBUG:SMB.SMBConnection:Received SMB message "SMB_COM_TREE_CONNECT_ANDX" (command:0x75 flags:0x88 flags2:0xC001 TID:0 UID:0) INFO:SMB.SMBConnection:Authentication with remote machine "VOO-USB" for user "admin" will be using NTLM v2 authentication (with extended security) DEBUG:SMB.SMBConnection:Received SMB message "SMB_COM_NEGOTIATE" (command:0x72 flags:0x88 flags2:0xC001 TID:0 UID:0) INFO:SMB.SMBConnection:SMB dialect negotiation successful (ExtendedSecurity:False) INFO:SMB.SMBConnection:Performing NTLMv1 authentication (without extended security) with challenge "b'0a5f922ce062ad4c'" and hashed password of "b'55c03ccd143e02c6cdf2ae1bae2646c8cc9b240ad99f2e40'" DEBUG:SMB.SMBConnection:Received SMB message "SMB_COM_SESSION_SETUP_ANDX" (command:0x73 flags:0x88 flags2:0xC001 TID:0 UID:0) DEBUG:SMB.SMBConnection:SMB uid is now 0 INFO:SMB.SMBConnection:Authentication (without extended security) successful! DEBUG:SMB.SMBConnection:Received SMB message "SMB_COM_TREE_CONNECT_ANDX" (command:0x75 flags:0x88 flags2:0xC001 TID:0 UID:0)
-
-
this might not be a pysmb issue, but old modules in pythonista.
you might try in a pc firstdoes pysmb depend on paramiko, or openssl or anything?