impacket icon indicating copy to clipboard operation
impacket copied to clipboard

Improve file timestamp resolution

Open mgomez12 opened this issue 11 months ago • 2 comments

Currently, file timestamps returned by the SMBServer are obtained by unpacking the 10-tuple returned by os.stat(some_path). However, accessing the timestamp fields in that manner returns an integer Unix timestamp, providing 1-second resolution.

This PR changes such occurences to use named access instead (using the field st_{a/c/m}time ), which returns a float value with improved resolution.

Testing with one of my projects that uses the SMB client's listPath method:

Before

>>> c.retrieve_latest_file()
2025-01-29 09:43:25.717 | INFO     | controller:retrieve_file:39 - Retrieving latest file
2025-01-29 09:43:26.750 | INFO     | driver:retrieve_file:47 - Found new result file test.csv created at 133826174050000000

After

>>> c.retrieve_latest_file()
2025-01-29 09:44:53.474 | INFO     | controller:retrieve_file:39 - Retrieving latest file
2025-01-29 09:44:54.516 | DEBUG    | driver:retrieve_file:47 - Found new result file test.csv created at 133826174934897888

mgomez12 avatar Jan 29 '25 09:01 mgomez12

I'd love these changes as well!

zamlz avatar Jan 29 '25 20:01 zamlz

Please notice the getFileTime method was moved from smbserver.py to smb.py and was renamed as well.

covertivy avatar Sep 09 '25 05:09 covertivy