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).
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)
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
related: https://github.com/dbt-labs/dbt-core/issues/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)
withnow = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) + datetime.timedelta(days=1)