Skip to content

Switch getUnixTimestamp to cross platform code #2014

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

Merged
merged 1 commit into from
Aug 11, 2025

Conversation

Dfte
Copy link
Contributor

@Dfte Dfte commented Aug 1, 2025

This PR switches the following line of code from the getUnixTime function:

return datetime.fromtimestamp(getUnixTime(int(str(self.fields[key]))))

To a cross platform independant oneliner:

return datetime(1601, 1, 1) + timedelta(microseconds=int(str(self.fields[key])) // 10)

It was mentionned as an issue on NetExec for people using it on Windows, which would be the same for people using Impacket on Windows:

Pennyw0rth/NetExec#827

And it mitigates it:

image

@gabrielg5 gabrielg5 self-assigned this Aug 7, 2025
@gabrielg5 gabrielg5 added the in review This issue or pull request is being analyzed label Aug 7, 2025
@gabrielg5
Copy link
Collaborator

yeah, if Data value is 0 it ends ups passing a negative value to datetime.fromtimestamp that could end up failing on windows systems.

Thinking if we should get rid of the (now) unused getUnixTime function definition in tsts.py.
But we can check it in another clean up ticket, also taking care of the many definitions of that same function all over the project

Merging, then, thanks!!

@gabrielg5 gabrielg5 added bug Unexpected problem or unintended behavior medium Medium priority item and removed in review This issue or pull request is being analyzed labels Aug 11, 2025
@gabrielg5 gabrielg5 merged commit 4e2b183 into fortra:master Aug 11, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior medium Medium priority item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants