Open yellephen opened 4 days ago
The writable
member is not an attribute but rather a method https://docs.python.org/3/library/io.html#io.IOBase.writable. You can see this when you compare it to the builtin open
method where writeable
is also a function.
with open("/tmp/test.txt, mode="wb") as fd:
print(fd.writable) # <built-in method writable of _io.BufferedWriter object at 0xffffa23f4f60>
print(fd.writeable()) # True
You need to do
with smbclient.open_file(file, 'wb') as fd:
if fd.writable():
print(" [x] The above file is writable by the smbuser passed.")
fd.write("test")
Keep in mind it doesn't do an access check, it just tells you whether the opened IO object is opened as a writable stream.
I noticed that fd.writable was returning true when a file was opened with 'rb'.
The print line was printed and fd.write resulted in an exception.
The following works for the purpose.