File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,6 +149,10 @@ def detect_if_ip(target):
149149
150150
151151def d2b (a ):
152+ """
153+ This function is used to convert password property flags from decimal to binary
154+ format for easier interpretation of individual flag bits.
155+ """
152156 tbin = []
153157 while a :
154158 tbin .append (a % 2 )
@@ -162,6 +166,22 @@ def d2b(a):
162166
163167
164168def convert (low , high , lockout = False ):
169+ """
170+ Convert Windows FILETIME (64-bit) values to human-readable time strings.
171+
172+ Windows stores time intervals as 64-bit values representing 100-nanosecond
173+ intervals since January 1, 1601. This function converts these values to
174+ readable format like "30 days 5 hours 15 minutes".
175+
176+ Args:
177+ low (int): Low 32 bits of the FILETIME value
178+ high (int): High 32 bits of the FILETIME value
179+ lockout (bool): If True, treats the value as a lockout duration (simpler conversion)
180+
181+ Returns:
182+ str: Human-readable time string (e.g., "42 days 5 hours 30 minutes") or
183+ special values like "Not Set", "None", or "[-] Invalid TIME"
184+ """
165185 time = ""
166186 tmp = 0
167187
Original file line number Diff line number Diff line change @@ -1531,7 +1531,7 @@ def ldap_to_filetime(ldap_time):
15311531
15321532 # Convert password properties using existing d2b function
15331533 pwd_properties = policy .get ("pwdProperties" , "0" )
1534- pass_prop = d2b (int (pwd_properties )) if pwd_properties != "0" else "None "
1534+ pass_prop = d2b (int (pwd_properties )) if pwd_properties != "0" else "000000 "
15351535
15361536 # Use the same formatting and constants as SMB passpol
15371537 PASSCOMPLEX = {
Original file line number Diff line number Diff line change 22
33from impacket .dcerpc .v5 .rpcrt import DCERPC_v5
44from impacket .dcerpc .v5 import transport , samr
5- from time import strftime , gmtime
65from nxc .logger import nxc_logger
7-
8-
9- def d2b (a ):
10- tbin = []
11- while a :
12- tbin .append (a % 2 )
13- a //= 2
14-
15- t2bin = tbin [::- 1 ]
16- if len (t2bin ) != 8 :
17- for _x in range (6 - len (t2bin )):
18- t2bin .insert (0 , 0 )
19- return "" .join ([str (g ) for g in t2bin ])
20-
21-
22- def convert (low , high , lockout = False ):
23- time = ""
24- tmp = 0
25-
26- if (low == 0 and high == - 0x8000_0000 ) or (low == 0 and high == - 0x8000_0000_0000_0000 ):
27- return "Not Set"
28- if low == 0 and high == 0 :
29- return "None"
30-
31- if not lockout :
32- if low != 0 :
33- high = abs (high + 1 )
34- else :
35- high = abs (high )
36- low = abs (low )
37-
38- tmp = low + (high << 32 ) # convert to 64bit int
39- tmp *= 1e-7 # convert to seconds
40- else :
41- tmp = abs (high ) * (1e-7 )
42-
43- try :
44- minutes = int (strftime ("%M" , gmtime (tmp )))
45- hours = int (strftime ("%H" , gmtime (tmp )))
46- days = int (strftime ("%j" , gmtime (tmp ))) - 1
47- except ValueError :
48- return "[-] Invalid TIME"
49-
50- if days > 1 :
51- time += f"{ days } days "
52- elif days == 1 :
53- time += f"{ days } day "
54- if hours > 1 :
55- time += f"{ hours } hours "
56- elif hours == 1 :
57- time += f"{ hours } hour "
58- if minutes > 1 :
59- time += f"{ minutes } minutes "
60- elif minutes == 1 :
61- time += f"{ minutes } minute "
62- return time
6+ from nxc .helpers .misc import convert , d2b
637
648
659class PassPolDump :
You can’t perform that action at this time.
0 commit comments