-
-
Save joselitosn/e74dbc2812c6479d3678 to your computer and use it in GitHub Desktop.
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) |
@blinkbink I have the same, did u manage to solve it ?
@blinkbink I have the same, did u manage to solve it ?
Easy and stupid way (mine):
- Download manually from https://miketeo.net/blog/projects/pysmb
- Copy smb and nmb folders to your site-packages folder (usually C:\users\user\AppData\Local\Continuum\anaconda3\Lib\site-packages if using Anaconda)
- Enjoy
from smb.SMBConnection import SMBConnection
To use "from smb.SMBConnection import SMBConnection" I was able to get it working with:
sudo apt install python3-smb
Fyi, for those having the same issue as me :
pysmb
is conflicting with impacket
(they both have a file named smbconnection.py
). You need to remove one before using the other, and vice versa.
I am getting timeout error
errorMessage": "timed out",
"errorType": "TimeoutError",
"requestId": "",
"stackTrace": [
" File "/var/lang/lib/python3.10/importlib/init.py", line 126, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n",
" File "", line 1050, in _gcd_import\n",
" File "", line 1027, in _find_and_load\n",
" File "", line 1006, in _find_and_load_unlocked\n",
" File "", line 688, in _load_unlocked\n",
" File "", line 883, in exec_module\n",
" File "", line 241, in _call_with_frames_removed\n",
" File "/var/task/lambda_function.py", line 134, in \n lambda_handler("e","c")\n",
" File "/var/task/lambda_function.py", line 99, in lambda_handler\n connected = conn.connect(server_ip, 13)\n",
" File "/var/task/smb/SMBConnection.py", line 113, in connect\n self.sock.connect(( ip, port ))\n"
]
}
I am getting timeout error. I am running a code from aws lambda.
root@sfr:/tmp# pip3 install pysmb
Requirement already satisfied: pysmb in /usr/local/lib/python3.6/dist-packages
Requirement already satisfied: pyasn1 in /usr/lib/python3/dist-packages (from pysmb)
root@sfr:/tmp# python3
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
gos this error, why this happen ?