Skip to content

Commit 835e175

Browse files
authored
Fixed warnings with Python 3.12 (fortra#1695)
* fixed SyntaxWarnings due to invalid escape sequence * fixed DeprecationWarning since datetime.datetime.utcnow() is deprecated in Python 3.12+ * fixed DeprecationWarning since datetime.datetime.utcfromtimestamp() is deprecated in Python 3.12+
1 parent db71504 commit 835e175

20 files changed

+92
-92
lines changed

examples/GetNPUsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def getTGT(self, userName, requestPAC=True):
162162

163163
reqBody['realm'] = domain
164164

165-
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
165+
now = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
166166
reqBody['till'] = KerberosTime.to_asn1(now)
167167
reqBody['rtime'] = KerberosTime.to_asn1(now)
168168
reqBody['nonce'] = random.getrandbits(31)

examples/addcomputer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def LDAP3KerberosLogin(self, connection, user, password, domain='', lmhash='', n
357357
authenticator['authenticator-vno'] = 5
358358
authenticator['crealm'] = domain
359359
seq_set(authenticator, 'cname', userName.components_to_asn1)
360-
now = datetime.datetime.utcnow()
360+
now = datetime.datetime.now(datetime.timezone.utc)
361361

362362
authenticator['cusec'] = now.microsecond
363363
authenticator['ctime'] = KerberosTime.to_asn1(now)

examples/dacledit.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
'S-1-5-64-14': 'SChannel Authentication',
9999
'S-1-5-64-21': 'Digest Authority',
100100
'S-1-5-80': 'NT Service',
101-
'S-1-5-83-0': 'NT VIRTUAL MACHINE\Virtual Machines',
101+
'S-1-5-83-0': 'NT VIRTUAL MACHINE\\Virtual Machines',
102102
'S-1-16-0': 'Untrusted Mandatory Level',
103103
'S-1-16-4096': 'Low Mandatory Level',
104104
'S-1-16-8192': 'Medium Mandatory Level',
@@ -107,24 +107,24 @@
107107
'S-1-16-16384': 'System Mandatory Level',
108108
'S-1-16-20480': 'Protected Process Mandatory Level',
109109
'S-1-16-28672': 'Secure Process Mandatory Level',
110-
'S-1-5-32-554': 'BUILTIN\Pre-Windows 2000 Compatible Access',
111-
'S-1-5-32-555': 'BUILTIN\Remote Desktop Users',
112-
'S-1-5-32-557': 'BUILTIN\Incoming Forest Trust Builders',
110+
'S-1-5-32-554': 'BUILTIN\\Pre-Windows 2000 Compatible Access',
111+
'S-1-5-32-555': 'BUILTIN\\Remote Desktop Users',
112+
'S-1-5-32-557': 'BUILTIN\\Incoming Forest Trust Builders',
113113
'S-1-5-32-556': 'BUILTIN\\Network Configuration Operators',
114-
'S-1-5-32-558': 'BUILTIN\Performance Monitor Users',
115-
'S-1-5-32-559': 'BUILTIN\Performance Log Users',
116-
'S-1-5-32-560': 'BUILTIN\Windows Authorization Access Group',
117-
'S-1-5-32-561': 'BUILTIN\Terminal Server License Servers',
118-
'S-1-5-32-562': 'BUILTIN\Distributed COM Users',
119-
'S-1-5-32-569': 'BUILTIN\Cryptographic Operators',
120-
'S-1-5-32-573': 'BUILTIN\Event Log Readers',
121-
'S-1-5-32-574': 'BUILTIN\Certificate Service DCOM Access',
122-
'S-1-5-32-575': 'BUILTIN\RDS Remote Access Servers',
123-
'S-1-5-32-576': 'BUILTIN\RDS Endpoint Servers',
124-
'S-1-5-32-577': 'BUILTIN\RDS Management Servers',
125-
'S-1-5-32-578': 'BUILTIN\Hyper-V Administrators',
126-
'S-1-5-32-579': 'BUILTIN\Access Control Assistance Operators',
127-
'S-1-5-32-580': 'BUILTIN\Remote Management Users',
114+
'S-1-5-32-558': 'BUILTIN\\Performance Monitor Users',
115+
'S-1-5-32-559': 'BUILTIN\\Performance Log Users',
116+
'S-1-5-32-560': 'BUILTIN\\Windows Authorization Access Group',
117+
'S-1-5-32-561': 'BUILTIN\\Terminal Server License Servers',
118+
'S-1-5-32-562': 'BUILTIN\\Distributed COM Users',
119+
'S-1-5-32-569': 'BUILTIN\\Cryptographic Operators',
120+
'S-1-5-32-573': 'BUILTIN\\Event Log Readers',
121+
'S-1-5-32-574': 'BUILTIN\\Certificate Service DCOM Access',
122+
'S-1-5-32-575': 'BUILTIN\\RDS Remote Access Servers',
123+
'S-1-5-32-576': 'BUILTIN\\RDS Endpoint Servers',
124+
'S-1-5-32-577': 'BUILTIN\\RDS Management Servers',
125+
'S-1-5-32-578': 'BUILTIN\\Hyper-V Administrators',
126+
'S-1-5-32-579': 'BUILTIN\\Access Control Assistance Operators',
127+
'S-1-5-32-580': 'BUILTIN\\Remote Management Users',
128128
}
129129

130130

@@ -873,7 +873,7 @@ def ldap3_kerberos_login(connection, target, user, password, domain='', lmhash='
873873
authenticator['authenticator-vno'] = 5
874874
authenticator['crealm'] = domain
875875
seq_set(authenticator, 'cname', userName.components_to_asn1)
876-
now = datetime.datetime.utcnow()
876+
now = datetime.datetime.now(datetime.timezone.utc)
877877

878878
authenticator['cusec'] = now.microsecond
879879
authenticator['ctime'] = KerberosTime.to_asn1(now)

examples/getPac.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def dump(self):
148148

149149
seq_set(authenticator, 'cname', clientName.components_to_asn1)
150150

151-
now = datetime.datetime.utcnow()
151+
now = datetime.datetime.now(datetime.timezone.utc)
152152
authenticator['cusec'] = now.microsecond
153153
authenticator['ctime'] = KerberosTime.to_asn1(now)
154154

@@ -238,7 +238,7 @@ def dump(self):
238238
seq_set(reqBody, 'sname', serverName.components_to_asn1)
239239
reqBody['realm'] = str(decodedTGT['crealm'])
240240

241-
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
241+
now = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
242242

243243
reqBody['till'] = KerberosTime.to_asn1(now)
244244
reqBody['nonce'] = random.getrandbits(31)

examples/getST.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def doS4U2ProxyWithAdditionalTicket(self, tgt, cipher, oldSessionKey, sessionKey
284284

285285
seq_set(authenticator, 'cname', clientName.components_to_asn1)
286286

287-
now = datetime.datetime.utcnow()
287+
now = datetime.datetime.now(datetime.timezone.utc)
288288
authenticator['cusec'] = now.microsecond
289289
authenticator['ctime'] = KerberosTime.to_asn1(now)
290290

@@ -336,7 +336,7 @@ def doS4U2ProxyWithAdditionalTicket(self, tgt, cipher, oldSessionKey, sessionKey
336336
myTicket = ticket.to_asn1(TicketAsn1())
337337
seq_set_iter(reqBody, 'additional-tickets', (myTicket,))
338338

339-
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
339+
now = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
340340

341341
reqBody['till'] = KerberosTime.to_asn1(now)
342342
reqBody['nonce'] = random.getrandbits(31)
@@ -377,7 +377,7 @@ def doS4U(self, tgt, cipher, oldSessionKey, sessionKey, nthash, aesKey, kdcHost)
377377

378378
seq_set(authenticator, 'cname', clientName.components_to_asn1)
379379

380-
now = datetime.datetime.utcnow()
380+
now = datetime.datetime.now(datetime.timezone.utc)
381381
authenticator['cusec'] = now.microsecond
382382
authenticator['ctime'] = KerberosTime.to_asn1(now)
383383

@@ -474,7 +474,7 @@ def doS4U(self, tgt, cipher, oldSessionKey, sessionKey, nthash, aesKey, kdcHost)
474474
seq_set(reqBody, 'sname', serverName.components_to_asn1)
475475
reqBody['realm'] = str(decodedTGT['crealm'])
476476

477-
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
477+
now = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
478478

479479
reqBody['till'] = KerberosTime.to_asn1(now)
480480
reqBody['nonce'] = random.getrandbits(31)
@@ -604,7 +604,7 @@ def doS4U(self, tgt, cipher, oldSessionKey, sessionKey, nthash, aesKey, kdcHost)
604604

605605
seq_set(authenticator, 'cname', clientName.components_to_asn1)
606606

607-
now = datetime.datetime.utcnow()
607+
now = datetime.datetime.now(datetime.timezone.utc)
608608
authenticator['cusec'] = now.microsecond
609609
authenticator['ctime'] = KerberosTime.to_asn1(now)
610610

@@ -656,7 +656,7 @@ def doS4U(self, tgt, cipher, oldSessionKey, sessionKey, nthash, aesKey, kdcHost)
656656
myTicket = ticket.to_asn1(TicketAsn1())
657657
seq_set_iter(reqBody, 'additional-tickets', (myTicket,))
658658

659-
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
659+
now = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
660660

661661
reqBody['till'] = KerberosTime.to_asn1(now)
662662
reqBody['nonce'] = random.getrandbits(31)

examples/goldenPac.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def getKerberosTGS(self, serverName, domain, kdcHost, tgt, cipher, sessionKey, a
720720
seq_set(reqBody, 'sname', serverName.components_to_asn1)
721721
reqBody['realm'] = decodedTGT['crealm'].prettyPrint()
722722

723-
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
723+
now = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
724724

725725
reqBody['till'] = KerberosTime.to_asn1(now)
726726
reqBody['nonce'] = random.SystemRandom().getrandbits(31)
@@ -746,7 +746,7 @@ def getKerberosTGS(self, serverName, domain, kdcHost, tgt, cipher, sessionKey, a
746746

747747
seq_set(authenticator, 'cname', clientName.components_to_asn1)
748748

749-
now = datetime.datetime.utcnow()
749+
now = datetime.datetime.now(datetime.timezone.utc)
750750
authenticator['cusec'] = now.microsecond
751751
authenticator['ctime'] = KerberosTime.to_asn1(now)
752752

examples/owneredit.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
'S-1-5-64-14': 'SChannel Authentication',
8585
'S-1-5-64-21': 'Digest Authority',
8686
'S-1-5-80': 'NT Service',
87-
'S-1-5-83-0': 'NT VIRTUAL MACHINE\Virtual Machines',
87+
'S-1-5-83-0': 'NT VIRTUAL MACHINE\\Virtual Machines',
8888
'S-1-16-0': 'Untrusted Mandatory Level',
8989
'S-1-16-4096': 'Low Mandatory Level',
9090
'S-1-16-8192': 'Medium Mandatory Level',
@@ -93,24 +93,24 @@
9393
'S-1-16-16384': 'System Mandatory Level',
9494
'S-1-16-20480': 'Protected Process Mandatory Level',
9595
'S-1-16-28672': 'Secure Process Mandatory Level',
96-
'S-1-5-32-554': 'BUILTIN\Pre-Windows 2000 Compatible Access',
97-
'S-1-5-32-555': 'BUILTIN\Remote Desktop Users',
98-
'S-1-5-32-557': 'BUILTIN\Incoming Forest Trust Builders',
96+
'S-1-5-32-554': 'BUILTIN\\Pre-Windows 2000 Compatible Access',
97+
'S-1-5-32-555': 'BUILTIN\\Remote Desktop Users',
98+
'S-1-5-32-557': 'BUILTIN\\Incoming Forest Trust Builders',
9999
'S-1-5-32-556': 'BUILTIN\\Network Configuration Operators',
100-
'S-1-5-32-558': 'BUILTIN\Performance Monitor Users',
101-
'S-1-5-32-559': 'BUILTIN\Performance Log Users',
102-
'S-1-5-32-560': 'BUILTIN\Windows Authorization Access Group',
103-
'S-1-5-32-561': 'BUILTIN\Terminal Server License Servers',
104-
'S-1-5-32-562': 'BUILTIN\Distributed COM Users',
105-
'S-1-5-32-569': 'BUILTIN\Cryptographic Operators',
106-
'S-1-5-32-573': 'BUILTIN\Event Log Readers',
107-
'S-1-5-32-574': 'BUILTIN\Certificate Service DCOM Access',
108-
'S-1-5-32-575': 'BUILTIN\RDS Remote Access Servers',
109-
'S-1-5-32-576': 'BUILTIN\RDS Endpoint Servers',
110-
'S-1-5-32-577': 'BUILTIN\RDS Management Servers',
111-
'S-1-5-32-578': 'BUILTIN\Hyper-V Administrators',
112-
'S-1-5-32-579': 'BUILTIN\Access Control Assistance Operators',
113-
'S-1-5-32-580': 'BUILTIN\Remote Management Users',
100+
'S-1-5-32-558': 'BUILTIN\\Performance Monitor Users',
101+
'S-1-5-32-559': 'BUILTIN\\Performance Log Users',
102+
'S-1-5-32-560': 'BUILTIN\\Windows Authorization Access Group',
103+
'S-1-5-32-561': 'BUILTIN\\Terminal Server License Servers',
104+
'S-1-5-32-562': 'BUILTIN\\Distributed COM Users',
105+
'S-1-5-32-569': 'BUILTIN\\Cryptographic Operators',
106+
'S-1-5-32-573': 'BUILTIN\\Event Log Readers',
107+
'S-1-5-32-574': 'BUILTIN\\Certificate Service DCOM Access',
108+
'S-1-5-32-575': 'BUILTIN\\RDS Remote Access Servers',
109+
'S-1-5-32-576': 'BUILTIN\\RDS Endpoint Servers',
110+
'S-1-5-32-577': 'BUILTIN\\RDS Management Servers',
111+
'S-1-5-32-578': 'BUILTIN\\Hyper-V Administrators',
112+
'S-1-5-32-579': 'BUILTIN\\Access Control Assistance Operators',
113+
'S-1-5-32-580': 'BUILTIN\\Remote Management Users',
114114
}
115115

116116
class OwnerEdit(object):
@@ -404,7 +404,7 @@ def ldap3_kerberos_login(connection, target, user, password, domain='', lmhash='
404404
authenticator['authenticator-vno'] = 5
405405
authenticator['crealm'] = domain
406406
seq_set(authenticator, 'cname', userName.components_to_asn1)
407-
now = datetime.datetime.utcnow()
407+
now = datetime.datetime.now(datetime.timezone.utc)
408408

409409
authenticator['cusec'] = now.microsecond
410410
authenticator['ctime'] = KerberosTime.to_asn1(now)

examples/raiseChild.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ def makeGolden(tgt, originalCipher, sessionKey, ntHash, aesKey, extraSid):
907907
encTicketPart = decoder.decode(plainText, asn1Spec = EncTicketPart())[0]
908908

909909
# Let's extend the ticket's validity a lil bit
910-
tenYearsFromNow = datetime.datetime.utcnow() + datetime.timedelta(days=365*10)
910+
tenYearsFromNow = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=365*10)
911911
encTicketPart['endtime'] = KerberosTime.to_asn1(tenYearsFromNow)
912912
encTicketPart['renew-till'] = KerberosTime.to_asn1(tenYearsFromNow)
913913
#print encTicketPart.prettyPrint()

examples/rbcd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def ldap3_kerberos_login(connection, target, user, password, domain='', lmhash='
142142
authenticator['authenticator-vno'] = 5
143143
authenticator['crealm'] = domain
144144
seq_set(authenticator, 'cname', userName.components_to_asn1)
145-
now = datetime.datetime.utcnow()
145+
now = datetime.datetime.now(datetime.timezone.utc)
146146

147147
authenticator['cusec'] = now.microsecond
148148
authenticator['ctime'] = KerberosTime.to_asn1(now)

examples/reg.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def run(self, remoteName, remoteHost):
192192
elif self.__action == 'SAVE':
193193
self.save(dce, self.__options.keyName)
194194
elif self.__action == 'BACKUP':
195-
for hive in ["HKLM\SAM", "HKLM\SYSTEM", "HKLM\SECURITY"]:
195+
for hive in ["HKLM\\SAM", "HKLM\\SYSTEM", "HKLM\\SECURITY"]:
196196
self.save(dce, hive)
197197
else:
198198
logging.error('Method %s not implemented yet!' % self.__action)
@@ -217,8 +217,8 @@ def triggerWinReg(self):
217217

218218
def save(self, dce, keyName):
219219
hRootKey, subKey = self.__strip_root_key(dce, keyName)
220-
outputFileName = "%s\%s.save" % (self.__options.outputPath, subKey)
221-
logging.debug("Dumping %s, be patient it can take a while for large hives (e.g. HKLM\SYSTEM)" % keyName)
220+
outputFileName = "%s\\%s.save" % (self.__options.outputPath, subKey)
221+
logging.debug("Dumping %s, be patient it can take a while for large hives (e.g. HKLM\\SYSTEM)" % keyName)
222222
try:
223223
ans2 = rrp.hBaseRegOpenKey(dce, hRootKey, subKey, dwOptions=rrp.REG_OPTION_BACKUP_RESTORE | rrp.REG_OPTION_OPEN_LINK, samDesired=rrp.KEY_READ)
224224
rrp.hBaseRegSaveKey(dce, ans2['phkResult'], outputFileName)
@@ -594,11 +594,11 @@ def __parse_lp_data(valueType, valueData):
594594
help='Specifies the full path of the subkey. The '
595595
'keyName must include a valid root key. Valid root keys for the local computer are: HKLM,'
596596
' HKU, HKCU, HKCR.')
597-
save_parser.add_argument('-o', dest='outputPath', action='store', metavar='\\\\192.168.0.2\share', required=True, help='Output UNC path the target system must export the registry saves to')
597+
save_parser.add_argument('-o', dest='outputPath', action='store', metavar='\\\\192.168.0.2\\share', required=True, help='Output UNC path the target system must export the registry saves to')
598598

599599
# A special backup command to save HKLM\SAM, HKLM\SYSTEM and HKLM\SECURITY
600-
backup_parser = subparsers.add_parser('backup', help='(special command) Backs up HKLM\SAM, HKLM\SYSTEM and HKLM\SECURITY to a specified file.')
601-
backup_parser.add_argument('-o', dest='outputPath', action='store', metavar='\\\\192.168.0.2\share', required=True,
600+
backup_parser = subparsers.add_parser('backup', help='(special command) Backs up HKLM\\SAM, HKLM\\SYSTEM and HKLM\\SECURITY to a specified file.')
601+
backup_parser.add_argument('-o', dest='outputPath', action='store', metavar='\\\\192.168.0.2\\share', required=True,
602602
help='Output UNC path the target system must export the registry saves to')
603603

604604
# A load command

examples/ticketer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def createBasicValidationInfo(self):
138138
# 1) KERB_VALIDATION_INFO
139139
kerbdata = KERB_VALIDATION_INFO()
140140

141-
aTime = timegm(datetime.datetime.utcnow().timetuple())
141+
aTime = timegm(datetime.datetime.now(datetime.timezone.utc).timetuple())
142142
unixTime = self.getFileTime(aTime)
143143

144144
kerbdata['LogonTime']['dwLowDateTime'] = unixTime & 0xffffffff
@@ -487,7 +487,7 @@ def getKerberosS4U2SelfU2U(self):
487487

488488
seq_set(authenticator, 'cname', clientName.components_to_asn1)
489489

490-
now = datetime.datetime.utcnow()
490+
now = datetime.datetime.now(datetime.timezone.utc)
491491
authenticator['cusec'] = now.microsecond
492492
authenticator['ctime'] = KerberosTime.to_asn1(now)
493493

@@ -576,7 +576,7 @@ def getKerberosS4U2SelfU2U(self):
576576
seq_set(reqBody, 'sname', serverName.components_to_asn1)
577577
reqBody['realm'] = str(decodedTGT['crealm'])
578578

579-
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
579+
now = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
580580

581581
reqBody['till'] = KerberosTime.to_asn1(now)
582582
reqBody['nonce'] = random.getrandbits(31)
@@ -597,7 +597,7 @@ def getKerberosS4U2SelfU2U(self):
597597
def customizeTicket(self, kdcRep, pacInfos):
598598
logging.info('Customizing ticket for %s/%s' % (self.__domain, self.__target))
599599

600-
ticketDuration = datetime.datetime.utcnow() + datetime.timedelta(hours=int(self.__options.duration))
600+
ticketDuration = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(hours=int(self.__options.duration))
601601

602602
if self.__options.impersonate:
603603
# Doing Sapphire Ticket
@@ -715,8 +715,8 @@ def customizeTicket(self, kdcRep, pacInfos):
715715
encTicketPart['transited'] = noValue
716716
encTicketPart['transited']['tr-type'] = 0
717717
encTicketPart['transited']['contents'] = ''
718-
encTicketPart['authtime'] = KerberosTime.to_asn1(datetime.datetime.utcnow())
719-
encTicketPart['starttime'] = KerberosTime.to_asn1(datetime.datetime.utcnow())
718+
encTicketPart['authtime'] = KerberosTime.to_asn1(datetime.datetime.now(datetime.timezone.utc))
719+
encTicketPart['starttime'] = KerberosTime.to_asn1(datetime.datetime.now(datetime.timezone.utc))
720720
# Let's extend the ticket's validity a lil bit
721721
encTicketPart['endtime'] = KerberosTime.to_asn1(ticketDuration)
722722
encTicketPart['renew-till'] = KerberosTime.to_asn1(ticketDuration)
@@ -840,7 +840,7 @@ def customizeTicket(self, kdcRep, pacInfos):
840840
encRepPart['last-req'] = noValue
841841
encRepPart['last-req'][0] = noValue
842842
encRepPart['last-req'][0]['lr-type'] = 0
843-
encRepPart['last-req'][0]['lr-value'] = KerberosTime.to_asn1(datetime.datetime.utcnow())
843+
encRepPart['last-req'][0]['lr-value'] = KerberosTime.to_asn1(datetime.datetime.now(datetime.timezone.utc))
844844
encRepPart['nonce'] = 123456789
845845
encRepPart['key-expiration'] = KerberosTime.to_asn1(ticketDuration)
846846
flags = []

impacket/dpapi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import sys
3030

3131
from struct import unpack
32-
from datetime import datetime
32+
from datetime import datetime, timezone
3333
from binascii import unhexlify, hexlify
3434
from struct import pack
3535
from hashlib import pbkdf2_hmac
@@ -779,7 +779,7 @@ def __init__(self, data = None, alignment = 0):
779779
def dump(self):
780780
print("[VCRD]")
781781
print("SchemaGuid : %s" % bin_to_string(self['SchemaGuid']))
782-
print("LastWritten : %s" % (datetime.utcfromtimestamp(getUnixTime(self['LastWritten']))))
782+
print("LastWritten : %s" % (datetime.fromtimestamp(getUnixTime(self['LastWritten']), tz=timezone.utc)))
783783
print("FriendlyName: %s" % (self['FriendlyName'].decode('utf-16le')))
784784
print()
785785
for i,entry in enumerate(self.mapEntries):
@@ -1077,7 +1077,7 @@ def __init__(self, data = None, alignment = 0):
10771077

10781078
def dump(self):
10791079
print("[CREDENTIAL]")
1080-
print("LastWritten : %s" % (datetime.utcfromtimestamp(getUnixTime(self['LastWritten']))))
1080+
print("LastWritten : %s" % (datetime.fromtimestamp(getUnixTime(self['LastWritten']), tz=timezone.utc)))
10811081
print("Flags : 0x%.8x (%s)" % (self['Flags'], getFlags(CREDENTIAL_FLAGS, self['Flags'])))
10821082
print("Persist : 0x%.8x (%s)" % (self['Persist'], CREDENTIAL_PERSIST(self['Persist']).name))
10831083
print("Type : 0x%.8x (%s)" % (self['Type'], CREDENTIAL_TYPE(self['Type']).name))

0 commit comments

Comments
 (0)