|
| 1 | +from enum import Enum |
1 | 2 | import random |
2 | 3 | import string |
3 | 4 | import re |
4 | 5 | import inspect |
5 | 6 | import os |
6 | | - |
| 7 | +from termcolor import colored |
7 | 8 | from ipaddress import ip_address |
| 9 | +from nxc.logger import nxc_logger |
| 10 | +from time import strftime, gmtime |
8 | 11 |
|
9 | 12 |
|
10 | 13 | def identify_target_file(target_file): |
@@ -145,3 +148,97 @@ def detect_if_ip(target): |
145 | 148 | return True |
146 | 149 | except Exception: |
147 | 150 | return False |
| 151 | + |
| 152 | + |
| 153 | +def d2b(a): |
| 154 | + """ |
| 155 | + Function used to convert password property flags from decimal to binary |
| 156 | + format for easier interpretation of individual flag bits. |
| 157 | + """ |
| 158 | + tbin = [] |
| 159 | + while a: |
| 160 | + tbin.append(a % 2) |
| 161 | + a //= 2 |
| 162 | + |
| 163 | + t2bin = tbin[::-1] |
| 164 | + if len(t2bin) != 8: |
| 165 | + for _x in range(6 - len(t2bin)): |
| 166 | + t2bin.insert(0, 0) |
| 167 | + return "".join([str(g) for g in t2bin]) |
| 168 | + |
| 169 | + |
| 170 | +def convert(low, high, lockout=False): |
| 171 | + """ |
| 172 | + Convert Windows FILETIME (64-bit) values to human-readable time strings. |
| 173 | +
|
| 174 | + Windows stores time intervals as 64-bit values representing 100-nanosecond |
| 175 | + intervals since January 1, 1601. This function converts these values to |
| 176 | + readable format like "30 days 5 hours 15 minutes". |
| 177 | +
|
| 178 | + Args: |
| 179 | + low (int): Low 32 bits of the FILETIME value |
| 180 | + high (int): High 32 bits of the FILETIME value |
| 181 | + lockout (bool): If True, treats the value as a lockout duration (simpler conversion) |
| 182 | +
|
| 183 | + Returns: |
| 184 | + str: Human-readable time string (e.g., "42 days 5 hours 30 minutes") or |
| 185 | + special values like "Not Set", "None", or "[-] Invalid TIME" |
| 186 | + """ |
| 187 | + time = "" |
| 188 | + tmp = 0 |
| 189 | + |
| 190 | + if (low == 0 and high == -0x8000_0000) or (low == 0 and high == -0x8000_0000_0000_0000): |
| 191 | + return "Not Set" |
| 192 | + if low == 0 and high == 0: |
| 193 | + return "None" |
| 194 | + |
| 195 | + if not lockout: |
| 196 | + if low != 0: |
| 197 | + high = abs(high + 1) |
| 198 | + else: |
| 199 | + high = abs(high) |
| 200 | + low = abs(low) |
| 201 | + |
| 202 | + tmp = low + (high << 32) # convert to 64bit int |
| 203 | + tmp *= 1e-7 # convert to seconds |
| 204 | + else: |
| 205 | + tmp = abs(high) * (1e-7) |
| 206 | + |
| 207 | + try: |
| 208 | + minutes = int(strftime("%M", gmtime(tmp))) |
| 209 | + hours = int(strftime("%H", gmtime(tmp))) |
| 210 | + days = int(strftime("%j", gmtime(tmp))) - 1 |
| 211 | + except ValueError: |
| 212 | + return "[-] Invalid TIME" |
| 213 | + |
| 214 | + if days > 1: |
| 215 | + time += f"{days} days " |
| 216 | + elif days == 1: |
| 217 | + time += f"{days} day " |
| 218 | + if hours > 1: |
| 219 | + time += f"{hours} hours " |
| 220 | + elif hours == 1: |
| 221 | + time += f"{hours} hour " |
| 222 | + if minutes > 1: |
| 223 | + time += f"{minutes} minutes " |
| 224 | + elif minutes == 1: |
| 225 | + time += f"{minutes} minute " |
| 226 | + return time |
| 227 | + |
| 228 | + |
| 229 | +def display_modules(args, modules): |
| 230 | + for category, color in {CATEGORY.ENUMERATION: "green", CATEGORY.CREDENTIAL_DUMPING: "cyan", CATEGORY.PRIVILEGE_ESCALATION: "magenta"}.items(): |
| 231 | + # Add category filter for module listing |
| 232 | + if args.list_modules and args.list_modules.lower() != category.name.lower(): |
| 233 | + continue |
| 234 | + if len([module for module in modules.values() if module["category"] == category]) > 0: |
| 235 | + nxc_logger.highlight(colored(f"{category.name}", color, attrs=["bold"])) |
| 236 | + for name, props in sorted(modules.items()): |
| 237 | + if props["category"] == category: |
| 238 | + nxc_logger.display(f"{name:<25} {props['description']}") |
| 239 | + |
| 240 | + |
| 241 | +class CATEGORY(Enum): |
| 242 | + ENUMERATION = "Enumeration" |
| 243 | + CREDENTIAL_DUMPING = "Credential Dumping" |
| 244 | + PRIVILEGE_ESCALATION = "Privilege Escalation" |
0 commit comments