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

datetime.datetime.utcnow() is deprecated in impacket-GetNPUsers #1827

Closed
CookieThump opened this issue Oct 7, 2024 · 2 comments
Closed

datetime.datetime.utcnow() is deprecated in impacket-GetNPUsers #1827

CookieThump opened this issue Oct 7, 2024 · 2 comments
Assignees
Labels
in review This issue or pull request is being analyzed

Comments

@CookieThump
Copy link

Configuration

impacket version:
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

Python version:
Python 3.12.6

Target OS:
Distributor ID: Kali
Description: Kali GNU/Linux Rolling
Release: 2024.3
Codename: kali-rolling

Issue

impacket-GetNPUsers uses datetime.datetime.utcnow() in GetNPUsers.py in line 165.
Any usage of datetime.datetime.utcnow() throws the following deprecation warning in Python 3.12

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

related: dbt-labs/dbt-core#9791

Expected Behavior
This shouldn't happen

Steps To Reproduce
Run impacket-GetNPUsers with Python 3.12

Solution

Replace line 165 in impacket-GetNPUsers
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
with
now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) + datetime.timedelta(days=1)

@exploide
Copy link
Contributor

exploide commented Oct 9, 2024

There are further places in the code invoking deprecated functions.

#1695 fixes this if it ever gets merged.

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Oct 10, 2024
@anadrianmanrique anadrianmanrique self-assigned this Oct 10, 2024
@anadrianmanrique
Copy link
Contributor

fixed in #1695, thanks

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

No branches or pull requests

3 participants