[SMB] Massive Fixes, Features and Refactoring - #1894
Conversation
…lags. Then sort out some mismatching flags.
…, write and delete. I found it out when capturing network traffic and seeing I can manage to read files with open handles. This fixes SHARE_ACCESS_DENIED errors when trying to read files with handles on them. This is the logical thing to do when we open files for reading. We do not want to block other processes from interacting with the file. This may raise problems when reading files that are being written into / being deleted. I still think this is the right move since we usually want to read the files no matter what.
This is related to my older commits on the subject.
Add method parameters to `getFile` to easily communicate with the underlying SMB API.
We obviously do not want to allow others to write to the file while we are writing to it.
…n` values in SMBv2.
|
Really important fix that makes SMB more intuitive! Please merge! |
|
Hello, interesting PR, however, it does not seem to be working on my side, am I missing something? |
|
The problem is with your test case. I am happy to help with any other questions you may have 😊 |
This is done to assist future development of SetInfo operations on files and directories.
```
Date Conversion Example - Year Component:
-----------------------------------------
2009 - 1980 = 29
| (convert to binary)
V
0001 1101
| (position data correctly by shifting)
V
0001 1101
<< 9
---------------------
= 0 0011 1010 0000 0000
| (trim to correct size with bitwise AND of correct mask)
V
0 0011 1010 0000 0000
& 1111 1110 0000 0000
---------------------
= 0011 1010 0000 0000
```
By doing so I also fixed a bad structure definition in the SMBSetFileBasicInfo structure. Now we can modify file information remotely ;)
Also converted the SMB DATETIME methods to use my SMB_DATE and SMB_TIME implementations.
Also implemented setInfo method to use for setting file information.
fileInformationClasses other than the default one.
…s using SMB. for now only implemented query.
|
@anadrianmanrique Done :) |
|
@covertivy I'm currently reviewing this PR. Testing has been great so far. Really nice features has been implemented. I'll post some minor changes for the code review. I'm the meanwhile I would like to request, if possible, to revert changes related to annotations and cosmetic fixes as well ( that doesn't include comments/documentation etc ), as we want to keep the code as consistent as possible. Thanks! |
|
Pity, I really hoped for better type hinting, but oh well 😅 |
|
@covertivy yes I understand what you mean, and I agree. But at the moment we want to minimize the amount of changes in the code base as we are approaching some stabilization phase prior to the 0.13 release. We want to have this kind of changes controlled in a very well defined scoped task, and also done in a different phase of the release process. Hope you can understand, and apologies for any inconvenience. |
|
No worries all good, thanks for the amazing work! |
|
I believe I corrected all of the undesired annotations & design changes. |
|
added some request changes. Additionally, changes in test_smb.py are run in the context of this PR, so they can be uncommented |
|
So it appears that the cookies file still appears locked. History file works in this branch. |
|
I explained all this in this comment. |
My bad! Probably should have seen that! Thanks |
|
merging now, thanks for the PR |
|
Thanks! |
|
Merging this PR seems to have broken |
|
Apparently also broke some of impacket's exec examples. |
Hello!
I did some research regarding some annoying
STATUS_SHARING_VIOLATIONandSTATUS_ACCESS_DENIEDerrors.I know for a fact that some files that cannot be read with
smbclientcan be copied aside with a command / the file explorer.This means that theoretically it should be possible to do so over SMB!
I opened up Wireshark and played around a bit - it seems this is caused by over-restrictive share access permissions on
impacket's side.I then dug deeper and saw some mismatching flag usage in the SMBv1 implementation of the protocol so I fixed those too.
To sum up, I added the ability to READ FILES WITH OPEN HANDLES WITH (ALMOST) NO RESTRICTION!!!
The only restriction is of course for some system files (eg.
SAM,SECURITY,SYSTEMand basically all files that require aShadowCopyto allow reading them).This means that files with "weak handles" can be read remotely WITH ABSOLUTELY NO LIMITATION!
The list contains:
*.evt/*.evtxGlad to suffer for all y'alls pleasure!