datetime.datetime.utcnow() is deprecated in impacket-GetNPUsers
CookieThump opened this issue · 2 comments
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)
There are further places in the code invoking deprecated functions.
#1695 fixes this if it ever gets merged.
fixed in #1695, thanks