Created
March 16, 2016 13:45
-
-
Save joselitosn/e74dbc2812c6479d3678 to your computer and use it in GitHub Desktop.
Python SMB Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am getting timeout error. I am running a code from aws lambda.