miketeo / pysmb

pysmb is an experimental SMB/CIFS library written in Python. It implements the client-side SMB/CIFS protocol (SMB1 and SMB2) which allows your Python application to access and transfer files to/from SMB/CIFS shared folders like your Windows file sharing and Samba folders.
Other
338 stars 95 forks source link

Anonymous connections #46

Open hegusung opened 8 years ago

hegusung commented 8 years ago

Hi,

is it possible to perform anonymous smb connections with pysmb ?

thanks !

historicbruno commented 8 years ago

I have tried this with a Windows 7 Pro share, so far without luck. I tried "guest" as the username and left the password empty. I gave "Everyone" access to the share. After enabling the guest account on the server, I still receive undocumented errors. I don't know if it's a permissions issue on the server or a bug in pysmb.

keeely commented 8 years ago

For anon connections, I have it working fine to a samba server. I tried playing around with the parameters to the SMBConnection constructor. username - Can be anything you want (doesn't need to be 'guest') password - Can be anything you want my_name - Can be anything you want remote_name - Can be anything you want, it says in the manual "This parameter must be the same as what has been configured on the remote server, or else the connection will be rejected." however that doesn't seem to hold true for me, I set it to some garbage and still got connected to an anonymous share. However: If you set this to an empty string, it won't connect. Go figure. domain - doesn't have to match the samba domain.

In case it helps, here is my Samba 4.1 config:

[global]
workgroup = WORKGROUP

server string = Samba Server
server role = standalone server
log file = /var/log/samba.%m
max log size = 50000
dns proxy = no
log level = 2
guest account = nobody
map to guest = Bad User

#============================ Share Definitions ==============================
[homes]
   comment = Home Directories
   browseable = no
   writable = yes

[test]
    comment = test share
    path = /test
    public = yes
    only guest = yes
    guest ok = yes
    writeable = yes
    read only = no
    browseable = yes
    create mode = 0777
    directory mode = 0777

The following code connects to the above share:

    conn = SMBConnection("guekljst", "bbbb", "sdf", "sdflva", domain="mmmd", use_ntlm_v2 = True)