Skip to content

Instantly share code, notes, and snippets.

@joselitosn
Created March 16, 2016 13:45
Show Gist options
  • Save joselitosn/e74dbc2812c6479d3678 to your computer and use it in GitHub Desktop.
Save joselitosn/e74dbc2812c6479d3678 to your computer and use it in GitHub Desktop.
Python SMB Example
from smb.SMBConnection import SMBConnection
userID = 'user'
password = 'password'
client_machine_name = 'localpcname'
server_name = 'servername'
server_ip = '0.0.0.0'
domain_name = 'domainname'
conn = SMBConnection(userID, password, client_machine_name, server_name, domain=domain_name, use_ntlm_v2=True,
is_direct_tcp=True)
conn.connect(server_ip, 445)
shares = conn.listShares()
for share in shares:
if not share.isSpecial and share.name not in ['NETLOGON', 'SYSVOL']:
sharedfiles = conn.listPath(share.name, '/')
for sharedfile in sharedfiles:
print(sharedfile.filename)
conn.close()
# with open('pysmb.py', 'rb') as file:
# conn.storeFile('remotefolder', 'pysmb.py', file)
@yainoit
Copy link

yainoit commented May 8, 2023

I am getting timeout error. I am running a code from aws lambda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment