Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bad format for SMB ShadowCopy access #1718

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

PeterGabaldon
Copy link
Contributor

When accessing Shadow Copies via the SMB protocol, the following format is typically utilized: '@GMT-%Y.%d.%m-%H.%M.%S'.

Impacket incorrectly implements this format by using %Y.%m.%d instead of %Y.%d.%m (noting the day before the month).

Here's a simple example:

Take note of the date in this example Shadow Snapshot:

image

Now, access it via SMB using the correct format:

image

Reference: https://www.4n6k.com/2017/02/forensics-quickie-accessing-copying.html

@enj5oy
Copy link

enj5oy commented Mar 24, 2024

@PeterGabaldon
I'm attempting to replicate your example. When I accessed the 'shadow copy' through Explorer, it reflects my current system state. Within it, you can observe a file named 'test', which bears a timestamp indicating it was created after the shadow copy was generated
2024-03-24_13-42

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Apr 11, 2024
@PeterGabaldon
Copy link
Contributor Author

PeterGabaldon commented Apr 28, 2024

Hi,

Just to clarify something after reveiwing it.

As pointed in #1719 (comment), there is no problem in order to access the Shadow Snapshot through Impacket. The format is not correct, but it is working fine. Snapshots are listed using the IOCTL FSCTL_SRV_ENUMERATE_SNAPSHOTS (https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb/5a43eb29-50c8-46b6-8319-e793a11f6226).

def listSnapshots(self, tid, path):

I am pointing this out because maybe we could close the PR, changing the format in timestampForSnapshot may result in errors when validating timestamps at some points because Impacket may use the "bad" format and then the validation with the format fail.

For example, when using smbconecction listSnapshots (

def listSnapshots(self, tid, path):
). After retreiving snapshots using this method a format error will be raised if listing/retriving files from it using smb3.py methods because the format returned by listSnapshots is the "bad" format, and after changing timestampForSnapshot with the "good" format a mismatch will occur.

@PeterGabaldon
Copy link
Contributor Author

@PeterGabaldon I'm attempting to replicate your example. When I accessed the 'shadow copy' through Explorer, it reflects my current system state. Within it, you can observe a file named 'test', which bears a timestamp indicating it was created after the shadow copy was generated 2024-03-24_13-42

Hi @enj5oy,

This ShadowSnapthot is (among other) of Differential type.

image

So, this SS should be using COW or Redirect on Write. https://learn.microsoft.com/en-us/windows-server/storage/file-server/volume-shadow-copy-service#how-the-provider-creates-a-shadow-copy.

Have you compared the contents of the file after modification in the live volume with the SS?

@anadrianmanrique anadrianmanrique added medium Medium priority item in review This issue or pull request is being analyzed and removed in review This issue or pull request is being analyzed medium Medium priority item labels May 2, 2024
@enj5oy
Copy link

enj5oy commented May 3, 2024

@PeterGabaldon I encountered an issue on my end, but after testing everything, it works fine. I had a mistake because of the wrong UTC time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review This issue or pull request is being analyzed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants