PyADRecon 0.13.5__tar.gz → 0.13.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/CHANGELOG.md +10 -10
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/PKG-INFO +1 -1
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/PyADRecon.egg-info/PKG-INFO +1 -1
- pyadrecon-0.13.7/PyADRecon.egg-info/scm_version.json +8 -0
- pyadrecon-0.13.7/package.json +3 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/pyadrecon.py +367 -88
- pyadrecon-0.13.5/PyADRecon.egg-info/scm_version.json +0 -8
- pyadrecon-0.13.5/package.json +0 -3
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/.dockerignore +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/.github/FUNDING.yml +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/.github/pyadrecon.png +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/.github/workflows/conventional-commits.yml +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/.github/workflows/pypi.yml +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/.gitignore +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/Dockerfile +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/LICENSE +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/PyADRecon.egg-info/SOURCES.txt +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/PyADRecon.egg-info/dependency_links.txt +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/PyADRecon.egg-info/entry_points.txt +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/PyADRecon.egg-info/requires.txt +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/PyADRecon.egg-info/scm_file_list.json +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/PyADRecon.egg-info/top_level.txt +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/README.md +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/dashboard_generator.py +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/pyproject.toml +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/requirements.txt +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/setup.cfg +0 -0
- {pyadrecon-0.13.5 → pyadrecon-0.13.7}/windows/README.md +0 -0
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
## [0.13.
|
|
1
|
+
## [0.13.7](https://github.com/l4rm4nd/PyADRecon/compare/v0.13.6...v0.13.7) (2026-07-10)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* add eol to computers and stats ([50a4fb0](https://github.com/l4rm4nd/PyADRecon/commit/50a4fb09c48155bab03bc880cc7e93a3bdbf29bc))
|
|
7
7
|
|
|
8
|
-
## [0.13.
|
|
8
|
+
## [0.13.6](https://github.com/l4rm4nd/PyADRecon/compare/v0.13.5...v0.13.6) (2026-07-09)
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
### Bug Fixes
|
|
12
12
|
|
|
13
|
-
*
|
|
13
|
+
* improve parsing ([ae9c618](https://github.com/l4rm4nd/PyADRecon/commit/ae9c618884cca16c8b03254c49c42aa6f1866c47))
|
|
14
14
|
|
|
15
|
-
## [0.13.
|
|
15
|
+
## [0.13.5](https://github.com/l4rm4nd/PyADRecon/compare/v0.13.4...v0.13.5) (2026-07-02)
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
### Bug Fixes
|
|
19
19
|
|
|
20
|
-
*
|
|
20
|
+
* adjust dashboard generator ([8fd5a8b](https://github.com/l4rm4nd/PyADRecon/commit/8fd5a8bbc92c995cba1c49db84315974478b19c3)), closes [#6](https://github.com/l4rm4nd/PyADRecon/issues/6) [#7](https://github.com/l4rm4nd/PyADRecon/issues/7)
|
|
21
21
|
|
|
22
|
-
## [0.13.
|
|
22
|
+
## [0.13.4](https://github.com/l4rm4nd/PyADRecon/compare/v0.13.3...v0.13.4) (2026-06-30)
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
### Bug Fixes
|
|
26
26
|
|
|
27
|
-
*
|
|
27
|
+
* bump impacket ([023b941](https://github.com/l4rm4nd/PyADRecon/commit/023b9415c434a224638fa451e8404c7833148803))
|
|
28
28
|
|
|
29
|
-
## [0.13.
|
|
29
|
+
## [0.13.3](https://github.com/l4rm4nd/PyADRecon/compare/v0.13.2...v0.13.3) (2026-02-22)
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
### Bug Fixes
|
|
33
33
|
|
|
34
|
-
*
|
|
34
|
+
* add EOL systemd detection ([81bdb7f](https://github.com/l4rm4nd/PyADRecon/commit/81bdb7f516a3023af08b7cab2be3b6242d68c174))
|
|
35
35
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
#!/usr/bin/env python3
|
|
3
2
|
"""
|
|
4
3
|
PyADRecon - Python Active Directory Reconnaissance Tool
|
|
@@ -104,7 +103,7 @@ if not KERBEROS_AVAILABLE:
|
|
|
104
103
|
|
|
105
104
|
|
|
106
105
|
# Constants
|
|
107
|
-
VERSION = "v0.13.
|
|
106
|
+
VERSION = "v0.13.7" # Automatically updated by CI/CD pipeline during release
|
|
108
107
|
BANNER = f"""
|
|
109
108
|
╔═════════════════════════════════════════════════════════
|
|
110
109
|
║ PyADRecon {VERSION} - Python AD Reconnaissance Tool
|
|
@@ -572,7 +571,7 @@ def calculate_user_stats(users_data: List[Dict], password_age_days: int = 180, d
|
|
|
572
571
|
elif cat == 'Kerberos DES Only':
|
|
573
572
|
is_match = user.get('Kerberos DES Only', False) is True
|
|
574
573
|
elif cat == 'Kerberos RC4':
|
|
575
|
-
is_match =
|
|
574
|
+
is_match = user.get('Kerberos RC4', '') == 'Supported'
|
|
576
575
|
elif cat == 'Does Not Require Pre Auth':
|
|
577
576
|
is_match = user.get('Does Not Require Pre Auth', False) is True
|
|
578
577
|
elif cat.startswith('Password Age (>'):
|
|
@@ -605,6 +604,179 @@ def calculate_user_stats(users_data: List[Dict], password_age_days: int = 180, d
|
|
|
605
604
|
return stats
|
|
606
605
|
|
|
607
606
|
|
|
607
|
+
def get_os_eol_info(os_string: str) -> Dict[str, Any]:
|
|
608
|
+
"""Return EOL status, EOL date, and days until/since EOL for a given OS string.
|
|
609
|
+
|
|
610
|
+
Returns a dict with keys: 'EOL Status', 'EOL Date', 'EOL Days Until/Since'.
|
|
611
|
+
All values are empty strings when the OS is not recognized.
|
|
612
|
+
"""
|
|
613
|
+
BUILD_MAPPING = {
|
|
614
|
+
# Windows 11 builds
|
|
615
|
+
'22000': '21H2',
|
|
616
|
+
'22621': '22H2',
|
|
617
|
+
'22631': '23H2',
|
|
618
|
+
'26100': '24H2',
|
|
619
|
+
'26200': '25H2',
|
|
620
|
+
'28000': '26H1',
|
|
621
|
+
# Windows 10 builds
|
|
622
|
+
'10240': '1507',
|
|
623
|
+
'10586': '1511',
|
|
624
|
+
'14393': '1607',
|
|
625
|
+
'15063': '1703',
|
|
626
|
+
'16299': '1709',
|
|
627
|
+
'17134': '1803',
|
|
628
|
+
'17763': '1809',
|
|
629
|
+
'18362': '1903',
|
|
630
|
+
'18363': '1909',
|
|
631
|
+
'19041': '2004',
|
|
632
|
+
'19042': '20H2',
|
|
633
|
+
'19043': '21H1',
|
|
634
|
+
'19044': '21H2',
|
|
635
|
+
'19045': '22H2',
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
EOL_DATABASE = {
|
|
639
|
+
'Server 2003': {'securityEnd': '2015-07-14'},
|
|
640
|
+
'Server 2008': {'securityEnd': '2020-01-14'},
|
|
641
|
+
'Server 2008 R2': {'securityEnd': '2020-01-14'},
|
|
642
|
+
'Server 2012': {'securityEnd': '2023-10-10'},
|
|
643
|
+
'Server 2012 R2': {'securityEnd': '2023-10-10'},
|
|
644
|
+
'Server 2016': {'securityEnd': '2027-01-12'},
|
|
645
|
+
'Server 2019': {'securityEnd': '2029-01-09'},
|
|
646
|
+
'Server 2022': {'securityEnd': '2031-10-14'},
|
|
647
|
+
'Server 2025': {'securityEnd': '2034-10-10'},
|
|
648
|
+
'XP': {'securityEnd': '2014-04-08'},
|
|
649
|
+
'Vista': {'securityEnd': '2017-04-11'},
|
|
650
|
+
'7': {'securityEnd': '2020-01-14'},
|
|
651
|
+
'8': {'securityEnd': '2016-01-12'},
|
|
652
|
+
'8.1': {'securityEnd': '2023-01-10'},
|
|
653
|
+
'10-1507': {'securityEnd': '2025-10-14'},
|
|
654
|
+
'10-1507-E-LTSC': {'securityEnd': '2025-10-14'},
|
|
655
|
+
'10-1511': {'securityEnd': '2017-10-10'},
|
|
656
|
+
'10-1607': {'securityEnd': '2026-10-13'},
|
|
657
|
+
'10-1607-E-LTSC': {'securityEnd': '2026-10-13'},
|
|
658
|
+
'10-1703': {'securityEnd': '2019-10-08'},
|
|
659
|
+
'10-1709': {'securityEnd': '2020-10-13'},
|
|
660
|
+
'10-1803': {'securityEnd': '2021-05-11'},
|
|
661
|
+
'10-1809': {'securityEnd': '2021-05-11'},
|
|
662
|
+
'10-1809-E-LTSC': {'securityEnd': '2029-01-09'},
|
|
663
|
+
'10-1903': {'securityEnd': '2020-12-08'},
|
|
664
|
+
'10-1909': {'securityEnd': '2022-05-10'},
|
|
665
|
+
'10-2004': {'securityEnd': '2021-12-14'},
|
|
666
|
+
'10-20H2': {'securityEnd': '2023-05-09'},
|
|
667
|
+
'10-21H1': {'securityEnd': '2022-12-13'},
|
|
668
|
+
'10-21H2': {'securityEnd': '2024-06-11'},
|
|
669
|
+
'10-21H2-E-LTSC': {'securityEnd': '2027-01-12'},
|
|
670
|
+
'10-22H2': {'securityEnd': '2025-10-14'},
|
|
671
|
+
'11-21H2-Pro': {'securityEnd': '2023-10-10'},
|
|
672
|
+
'11-21H2-Enterprise': {'securityEnd': '2024-10-08'},
|
|
673
|
+
'11-22H2-Pro': {'securityEnd': '2024-10-08'},
|
|
674
|
+
'11-22H2-Enterprise': {'securityEnd': '2025-10-14'},
|
|
675
|
+
'11-23H2-Pro': {'securityEnd': '2025-11-11'},
|
|
676
|
+
'11-23H2-Enterprise': {'securityEnd': '2026-11-10'},
|
|
677
|
+
'11-24H2-Pro': {'securityEnd': '2026-10-13'},
|
|
678
|
+
'11-24H2-Enterprise': {'securityEnd': '2027-10-12'},
|
|
679
|
+
'11-25H2-Pro': {'securityEnd': '2027-10-12'},
|
|
680
|
+
'11-25H2-Enterprise': {'securityEnd': '2028-10-10'},
|
|
681
|
+
'Ubuntu 16.04': {'securityEnd': '2021-04-02'},
|
|
682
|
+
'Ubuntu 18.04': {'securityEnd': '2023-05-31'},
|
|
683
|
+
'Ubuntu 20.04': {'securityEnd': '2025-05-31'},
|
|
684
|
+
'Ubuntu 22.04': {'securityEnd': '2027-04-01'},
|
|
685
|
+
'Debian 9': {'securityEnd': '2020-07-18'},
|
|
686
|
+
'Debian 10': {'securityEnd': '2022-09-10'},
|
|
687
|
+
'Debian 11': {'securityEnd': '2024-08-14'},
|
|
688
|
+
'Debian 12': {'securityEnd': '2026-06-10'},
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
empty = {'EOL Status': '', 'EOL Date': '', 'EOL Days Until/Since': ''}
|
|
692
|
+
|
|
693
|
+
if not os_string:
|
|
694
|
+
return empty
|
|
695
|
+
|
|
696
|
+
build_match = re.search(r'\((\d{5})\)', os_string)
|
|
697
|
+
build_number = build_match.group(1) if build_match else None
|
|
698
|
+
version = BUILD_MAPPING.get(build_number) if build_number else None
|
|
699
|
+
|
|
700
|
+
eol_key = None
|
|
701
|
+
|
|
702
|
+
if re.search(r'Windows Server 2003', os_string, re.IGNORECASE):
|
|
703
|
+
eol_key = 'Server 2003'
|
|
704
|
+
elif re.search(r'Windows Server 2008 R2', os_string, re.IGNORECASE):
|
|
705
|
+
eol_key = 'Server 2008 R2'
|
|
706
|
+
elif re.search(r'Windows Server 2008(?! R2)', os_string, re.IGNORECASE):
|
|
707
|
+
eol_key = 'Server 2008'
|
|
708
|
+
elif re.search(r'Windows Server 2012 R2', os_string, re.IGNORECASE):
|
|
709
|
+
eol_key = 'Server 2012 R2'
|
|
710
|
+
elif re.search(r'Windows Server 2012(?! R2)', os_string, re.IGNORECASE):
|
|
711
|
+
eol_key = 'Server 2012'
|
|
712
|
+
elif re.search(r'Windows Server 2016', os_string, re.IGNORECASE):
|
|
713
|
+
eol_key = 'Server 2016'
|
|
714
|
+
elif re.search(r'Windows Server 2019', os_string, re.IGNORECASE):
|
|
715
|
+
eol_key = 'Server 2019'
|
|
716
|
+
elif re.search(r'Windows Server 2022', os_string, re.IGNORECASE):
|
|
717
|
+
eol_key = 'Server 2022'
|
|
718
|
+
elif re.search(r'Windows Server 2025', os_string, re.IGNORECASE):
|
|
719
|
+
eol_key = 'Server 2025'
|
|
720
|
+
elif re.search(r'Windows 11', os_string, re.IGNORECASE) and version:
|
|
721
|
+
is_enterprise = bool(re.search(r'Enterprise', os_string, re.IGNORECASE))
|
|
722
|
+
edition = 'Enterprise' if is_enterprise else 'Pro'
|
|
723
|
+
eol_key = f'11-{version}-{edition}'
|
|
724
|
+
elif re.search(r'Windows 10', os_string, re.IGNORECASE) and version:
|
|
725
|
+
is_enterprise = bool(re.search(r'Enterprise', os_string, re.IGNORECASE))
|
|
726
|
+
is_ltsc = bool(re.search(r'LTSC', os_string, re.IGNORECASE))
|
|
727
|
+
eol_key = f'10-{version}-E-LTSC' if (is_enterprise and is_ltsc) else f'10-{version}'
|
|
728
|
+
elif re.search(r'Windows XP', os_string, re.IGNORECASE):
|
|
729
|
+
eol_key = 'XP'
|
|
730
|
+
elif re.search(r'Windows Vista', os_string, re.IGNORECASE):
|
|
731
|
+
eol_key = 'Vista'
|
|
732
|
+
elif re.search(r'Windows 7', os_string, re.IGNORECASE):
|
|
733
|
+
eol_key = '7'
|
|
734
|
+
elif re.search(r'Windows 8\.1', os_string, re.IGNORECASE):
|
|
735
|
+
eol_key = '8.1'
|
|
736
|
+
elif re.search(r'Windows 8(?!\.1)', os_string, re.IGNORECASE):
|
|
737
|
+
eol_key = '8'
|
|
738
|
+
elif re.search(r'Ubuntu.*16\.04', os_string, re.IGNORECASE):
|
|
739
|
+
eol_key = 'Ubuntu 16.04'
|
|
740
|
+
elif re.search(r'Ubuntu.*18\.04', os_string, re.IGNORECASE):
|
|
741
|
+
eol_key = 'Ubuntu 18.04'
|
|
742
|
+
elif re.search(r'Ubuntu.*20\.04', os_string, re.IGNORECASE):
|
|
743
|
+
eol_key = 'Ubuntu 20.04'
|
|
744
|
+
elif re.search(r'Ubuntu.*22\.04', os_string, re.IGNORECASE):
|
|
745
|
+
eol_key = 'Ubuntu 22.04'
|
|
746
|
+
elif re.search(r'Debian.*9', os_string, re.IGNORECASE):
|
|
747
|
+
eol_key = 'Debian 9'
|
|
748
|
+
elif re.search(r'Debian.*10', os_string, re.IGNORECASE):
|
|
749
|
+
eol_key = 'Debian 10'
|
|
750
|
+
elif re.search(r'Debian.*11', os_string, re.IGNORECASE):
|
|
751
|
+
eol_key = 'Debian 11'
|
|
752
|
+
elif re.search(r'Debian.*12', os_string, re.IGNORECASE):
|
|
753
|
+
eol_key = 'Debian 12'
|
|
754
|
+
|
|
755
|
+
if eol_key is None or eol_key not in EOL_DATABASE:
|
|
756
|
+
return empty
|
|
757
|
+
|
|
758
|
+
security_end_str = EOL_DATABASE[eol_key]['securityEnd']
|
|
759
|
+
security_end = datetime.strptime(security_end_str, '%Y-%m-%d')
|
|
760
|
+
now = datetime.now()
|
|
761
|
+
twelve_months_from_now = now + timedelta(days=365)
|
|
762
|
+
|
|
763
|
+
if now > security_end:
|
|
764
|
+
eol_status = 'EoL'
|
|
765
|
+
days_diff = (now - security_end).days
|
|
766
|
+
elif security_end <= twelve_months_from_now:
|
|
767
|
+
eol_status = 'Soon EoL'
|
|
768
|
+
days_diff = -((security_end - now).days)
|
|
769
|
+
else:
|
|
770
|
+
eol_status = 'Supported'
|
|
771
|
+
days_diff = -((security_end - now).days)
|
|
772
|
+
|
|
773
|
+
return {
|
|
774
|
+
'EOL Status': eol_status,
|
|
775
|
+
'EOL Date': security_end_str,
|
|
776
|
+
'EOL Days Until/Since': days_diff,
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
|
|
608
780
|
def calculate_computer_stats(computers_data: List[Dict], laps_data: List[Dict] = None, password_age_days: int = 30, dormant_days: int = 90) -> Dict[str, Any]:
|
|
609
781
|
"""Calculate computer account statistics for the Computer Stats tab."""
|
|
610
782
|
if not computers_data:
|
|
@@ -2229,7 +2401,60 @@ class PyADRecon:
|
|
|
2229
2401
|
results = []
|
|
2230
2402
|
|
|
2231
2403
|
try:
|
|
2232
|
-
#
|
|
2404
|
+
# ----------------------------------------------------------------
|
|
2405
|
+
# Build an in-memory DN → {username, sid, type} cache so that we
|
|
2406
|
+
# avoid issuing one LDAP round-trip per member.
|
|
2407
|
+
#
|
|
2408
|
+
# Sources:
|
|
2409
|
+
# 1. self.results['Users'] – collected just before GroupMembers
|
|
2410
|
+
# 2. self.results['Groups'] – collected just before GroupMembers
|
|
2411
|
+
# 3. one bulk (objectCategory=computer) query done here
|
|
2412
|
+
# ----------------------------------------------------------------
|
|
2413
|
+
dn_cache = {} # normalised-lower-DN -> {'username', 'sid', 'type'}
|
|
2414
|
+
|
|
2415
|
+
for user in self.results.get('Users', []):
|
|
2416
|
+
dn = user.get('DistinguishedName', '')
|
|
2417
|
+
if dn:
|
|
2418
|
+
dn_cache[dn.lower()] = {
|
|
2419
|
+
'username': user.get('UserName', ''),
|
|
2420
|
+
'sid': user.get('SID', ''),
|
|
2421
|
+
'type': 'user',
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
for group in self.results.get('Groups', []):
|
|
2425
|
+
dn = group.get('DistinguishedName', '')
|
|
2426
|
+
if dn:
|
|
2427
|
+
dn_cache[dn.lower()] = {
|
|
2428
|
+
'username': group.get('Name', ''),
|
|
2429
|
+
'sid': group.get('SID', ''),
|
|
2430
|
+
'type': 'group',
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
# Computers are collected after GroupMembers in the pipeline,
|
|
2434
|
+
# so fetch them now in a single bulk LDAP call.
|
|
2435
|
+
try:
|
|
2436
|
+
computer_entries = self.search(
|
|
2437
|
+
self.base_dn,
|
|
2438
|
+
"(objectCategory=computer)",
|
|
2439
|
+
['sAMAccountName', 'objectSid', 'distinguishedName']
|
|
2440
|
+
)
|
|
2441
|
+
for comp_entry in computer_entries:
|
|
2442
|
+
dn = get_attr(comp_entry, 'distinguishedName', '')
|
|
2443
|
+
if dn:
|
|
2444
|
+
dn_cache[dn.lower()] = {
|
|
2445
|
+
'username': get_attr(comp_entry, 'sAMAccountName', ''),
|
|
2446
|
+
'sid': sid_to_string(get_attr(comp_entry, 'objectSid')),
|
|
2447
|
+
'type': 'computer',
|
|
2448
|
+
}
|
|
2449
|
+
logger.debug(f"Group member DN cache built: {len(dn_cache)} entries")
|
|
2450
|
+
except Exception as e:
|
|
2451
|
+
logger.debug(f"Could not pre-fetch computers for group member cache: {e}")
|
|
2452
|
+
|
|
2453
|
+
base_dc_parts = [p.lower() for p in re.findall(r'DC=([^,]+)', self.base_dn, re.IGNORECASE)]
|
|
2454
|
+
|
|
2455
|
+
# ----------------------------------------------------------------
|
|
2456
|
+
# Main enumeration: one LDAP call for all groups with members
|
|
2457
|
+
# ----------------------------------------------------------------
|
|
2233
2458
|
entries = self.search(
|
|
2234
2459
|
self.base_dn,
|
|
2235
2460
|
"(&(objectCategory=group)(member=*))",
|
|
@@ -2238,91 +2463,27 @@ class PyADRecon:
|
|
|
2238
2463
|
|
|
2239
2464
|
for entry in entries:
|
|
2240
2465
|
group_name = get_attr(entry, 'name', '')
|
|
2241
|
-
group_sam = get_attr(entry, 'sAMAccountName', '')
|
|
2242
2466
|
members = get_attr_list(entry, 'member')
|
|
2243
2467
|
|
|
2244
2468
|
for member_dn in members:
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2469
|
+
member_dn_str = str(member_dn)
|
|
2470
|
+
|
|
2471
|
+
# Handle LDAP DN escaping (e.g. "Wagner\, Klaus")
|
|
2472
|
+
match = re.search(r'CN=((?:[^,\\]|\\.)+)', member_dn_str)
|
|
2473
|
+
member_name = re.sub(r'\\(.)', r'\1', match.group(1)) if match else member_dn_str
|
|
2474
|
+
|
|
2250
2475
|
member_username = ""
|
|
2251
2476
|
member_sid = ""
|
|
2252
2477
|
account_type = ""
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
)
|
|
2263
|
-
|
|
2264
|
-
if member_entries:
|
|
2265
|
-
member_entry = member_entries[0]
|
|
2266
|
-
member_username = get_attr(member_entry, 'sAMAccountName', '')
|
|
2267
|
-
member_sid_raw = get_attr(member_entry, 'objectSid')
|
|
2268
|
-
if member_sid_raw:
|
|
2269
|
-
member_sid = sid_to_string(member_sid_raw)
|
|
2270
|
-
|
|
2271
|
-
# Determine account type from objectClass
|
|
2272
|
-
object_classes = get_attr_list(member_entry, 'objectClass')
|
|
2273
|
-
object_classes_str = [str(oc).lower() for oc in object_classes]
|
|
2274
|
-
|
|
2275
|
-
if 'user' in object_classes_str and 'computer' not in object_classes_str:
|
|
2276
|
-
account_type = "user"
|
|
2277
|
-
elif 'computer' in object_classes_str:
|
|
2278
|
-
account_type = "computer"
|
|
2279
|
-
elif 'group' in object_classes_str:
|
|
2280
|
-
account_type = "group"
|
|
2281
|
-
else:
|
|
2282
|
-
account_type = "unknown"
|
|
2283
|
-
else:
|
|
2284
|
-
# Empty results - likely a referral to another domain
|
|
2285
|
-
member_dn_str = str(member_dn)
|
|
2286
|
-
|
|
2287
|
-
# Check if this is a cross-domain member (different DC components)
|
|
2288
|
-
# Extract DC components from member DN
|
|
2289
|
-
member_dc_parts = re.findall(r'DC=([^,]+)', member_dn_str, re.IGNORECASE)
|
|
2290
|
-
base_dc_parts = re.findall(r'DC=([^,]+)', self.base_dn, re.IGNORECASE)
|
|
2291
|
-
|
|
2292
|
-
# If member has different DC components, it's from another domain
|
|
2293
|
-
if member_dc_parts and member_dc_parts != base_dc_parts:
|
|
2294
|
-
is_foreign_principal = True
|
|
2295
|
-
member_domain = '.'.join(member_dc_parts)
|
|
2296
|
-
# Mark as foreign principal by including domain info in SID field
|
|
2297
|
-
member_sid = f"ForeignSecurityPrincipal:{member_domain}"
|
|
2298
|
-
logger.debug(f"Detected foreign principal: {member_name} from domain {member_domain}")
|
|
2299
|
-
|
|
2300
|
-
# Guess account type from DN
|
|
2301
|
-
if ',CN=Users,' in member_dn_str or ',OU=Users,' in member_dn_str:
|
|
2302
|
-
account_type = "user"
|
|
2303
|
-
elif ',CN=Computers,' in member_dn_str or ',OU=Computers,' in member_dn_str:
|
|
2304
|
-
account_type = "computer"
|
|
2305
|
-
elif ',CN=Builtin,' in member_dn_str or 'CN=Groups' in member_dn_str:
|
|
2306
|
-
account_type = "group"
|
|
2307
|
-
else:
|
|
2308
|
-
account_type = "foreignSecurityPrincipal" if is_foreign_principal else "unknown"
|
|
2309
|
-
|
|
2310
|
-
except Exception as e:
|
|
2311
|
-
logger.debug(f"Error querying member {member_dn}: {e}")
|
|
2312
|
-
# If lookup fails, try to detect cross-domain member from DN
|
|
2313
|
-
member_dn_str = str(member_dn)
|
|
2314
|
-
|
|
2315
|
-
# Check if this is a cross-domain member
|
|
2316
|
-
member_dc_parts = re.findall(r'DC=([^,]+)', member_dn_str, re.IGNORECASE)
|
|
2317
|
-
base_dc_parts = re.findall(r'DC=([^,]+)', self.base_dn, re.IGNORECASE)
|
|
2318
|
-
|
|
2319
|
-
if member_dc_parts and member_dc_parts != base_dc_parts:
|
|
2320
|
-
is_foreign_principal = True
|
|
2321
|
-
member_domain = '.'.join(member_dc_parts)
|
|
2322
|
-
member_sid = f"ForeignSecurityPrincipal:{member_domain}"
|
|
2323
|
-
logger.debug(f"Detected foreign principal (exception path): {member_name} from domain {member_domain}")
|
|
2324
|
-
|
|
2325
|
-
# Guess account type from DN
|
|
2478
|
+
|
|
2479
|
+
# ----------------------------------------------------------
|
|
2480
|
+
# Cross-domain check: skip LDAP for members from other domains.
|
|
2481
|
+
# ----------------------------------------------------------
|
|
2482
|
+
member_dc_parts = [p.lower() for p in re.findall(r'DC=([^,]+)', member_dn_str, re.IGNORECASE)]
|
|
2483
|
+
|
|
2484
|
+
if member_dc_parts and member_dc_parts != base_dc_parts:
|
|
2485
|
+
member_domain = '.'.join(member_dc_parts)
|
|
2486
|
+
member_sid = f"ForeignSecurityPrincipal:{member_domain}"
|
|
2326
2487
|
if ',CN=Users,' in member_dn_str or ',OU=Users,' in member_dn_str:
|
|
2327
2488
|
account_type = "user"
|
|
2328
2489
|
elif ',CN=Computers,' in member_dn_str or ',OU=Computers,' in member_dn_str:
|
|
@@ -2330,7 +2491,61 @@ class PyADRecon:
|
|
|
2330
2491
|
elif ',CN=Builtin,' in member_dn_str or 'CN=Groups' in member_dn_str:
|
|
2331
2492
|
account_type = "group"
|
|
2332
2493
|
else:
|
|
2333
|
-
account_type = "foreignSecurityPrincipal"
|
|
2494
|
+
account_type = "foreignSecurityPrincipal"
|
|
2495
|
+
logger.debug(f"Skipping cross-domain LDAP lookup for {member_name} from {member_domain}")
|
|
2496
|
+
|
|
2497
|
+
else:
|
|
2498
|
+
# ----------------------------------------------------------
|
|
2499
|
+
# Same-domain: O(1) cache hit, no LDAP call needed.
|
|
2500
|
+
# ----------------------------------------------------------
|
|
2501
|
+
cached = dn_cache.get(member_dn_str.lower())
|
|
2502
|
+
if cached:
|
|
2503
|
+
member_username = cached['username']
|
|
2504
|
+
member_sid = cached['sid']
|
|
2505
|
+
account_type = cached['type']
|
|
2506
|
+
else:
|
|
2507
|
+
# Cache miss (deleted/phantom object, ForeignSecurityPrincipal
|
|
2508
|
+
# stub in local domain, or MSA not in the three bulk sets).
|
|
2509
|
+
# Fall back to a single LDAP BASE lookup.
|
|
2510
|
+
try:
|
|
2511
|
+
member_entries = self.search(
|
|
2512
|
+
member_dn_str,
|
|
2513
|
+
"(objectClass=*)",
|
|
2514
|
+
['sAMAccountName', 'objectSid', 'objectClass'],
|
|
2515
|
+
search_scope=BASE
|
|
2516
|
+
)
|
|
2517
|
+
if member_entries:
|
|
2518
|
+
me = member_entries[0]
|
|
2519
|
+
member_username = get_attr(me, 'sAMAccountName', '')
|
|
2520
|
+
sid_raw = get_attr(me, 'objectSid')
|
|
2521
|
+
if sid_raw:
|
|
2522
|
+
member_sid = sid_to_string(sid_raw)
|
|
2523
|
+
ocs = [str(o).lower() for o in get_attr_list(me, 'objectClass')]
|
|
2524
|
+
if 'computer' in ocs:
|
|
2525
|
+
account_type = "computer"
|
|
2526
|
+
elif 'user' in ocs:
|
|
2527
|
+
account_type = "user"
|
|
2528
|
+
elif 'group' in ocs:
|
|
2529
|
+
account_type = "group"
|
|
2530
|
+
elif 'msds-managedserviceaccount' in ocs or 'msds-groupmanagedserviceaccount' in ocs:
|
|
2531
|
+
account_type = "msa"
|
|
2532
|
+
else:
|
|
2533
|
+
account_type = "unknown"
|
|
2534
|
+
except Exception as e:
|
|
2535
|
+
logger.debug(f"Fallback lookup failed for {member_dn_str}: {e}")
|
|
2536
|
+
|
|
2537
|
+
# If still empty, guess from DN structure
|
|
2538
|
+
if not account_type:
|
|
2539
|
+
if ',CN=ForeignSecurityPrincipals,' in member_dn_str:
|
|
2540
|
+
account_type = "foreignSecurityPrincipal"
|
|
2541
|
+
elif ',CN=Users,' in member_dn_str or ',OU=Users,' in member_dn_str:
|
|
2542
|
+
account_type = "user"
|
|
2543
|
+
elif ',CN=Computers,' in member_dn_str or ',OU=Computers,' in member_dn_str:
|
|
2544
|
+
account_type = "computer"
|
|
2545
|
+
elif ',CN=Builtin,' in member_dn_str or 'CN=Groups' in member_dn_str:
|
|
2546
|
+
account_type = "group"
|
|
2547
|
+
else:
|
|
2548
|
+
account_type = "unknown"
|
|
2334
2549
|
|
|
2335
2550
|
results.append({
|
|
2336
2551
|
"Group Name": group_name,
|
|
@@ -3038,6 +3253,8 @@ class PyADRecon:
|
|
|
3038
3253
|
ipv4_address = hostname_to_ip.get(hostname_part, '')
|
|
3039
3254
|
ipv6_address = hostname_to_ipv6.get(hostname_part, '')
|
|
3040
3255
|
|
|
3256
|
+
eol_info = get_os_eol_info(os_full)
|
|
3257
|
+
|
|
3041
3258
|
results.append({
|
|
3042
3259
|
"UserName": get_attr(entry, 'sAMAccountName', ''),
|
|
3043
3260
|
"Name": get_attr(entry, 'name', ''),
|
|
@@ -3046,6 +3263,9 @@ class PyADRecon:
|
|
|
3046
3263
|
"IPv4Address": ipv4_address,
|
|
3047
3264
|
"IPv6Address": ipv6_address,
|
|
3048
3265
|
"Operating System": os_full,
|
|
3266
|
+
"EOL Status": eol_info['EOL Status'],
|
|
3267
|
+
"EOL Date": eol_info['EOL Date'],
|
|
3268
|
+
"EOL Days Until/Since": eol_info['EOL Days Until/Since'],
|
|
3049
3269
|
"Logon Age (days)": logon_age_days,
|
|
3050
3270
|
"Password Age (days)": pwd_age_days,
|
|
3051
3271
|
f"Dormant (> {self.config.dormant_days} days)": dormant,
|
|
@@ -5551,6 +5771,7 @@ class PyADRecon:
|
|
|
5551
5771
|
# Critical security issues (RED)
|
|
5552
5772
|
red_columns = {
|
|
5553
5773
|
"Delegation Type": ("Unconstrained", "Unconstrained"),
|
|
5774
|
+
"EOL Status": ("EoL", "EoL"),
|
|
5554
5775
|
}
|
|
5555
5776
|
|
|
5556
5777
|
# Medium security issues (ORANGE)
|
|
@@ -5597,6 +5818,21 @@ class PyADRecon:
|
|
|
5597
5818
|
if cell.value in [True, "TRUE"]:
|
|
5598
5819
|
cell.fill = yellow_fill
|
|
5599
5820
|
|
|
5821
|
+
# EOL Status: Soon EoL — orange if < 180 days until EoL, yellow otherwise
|
|
5822
|
+
if "EOL Status" in headers and "EOL Days Until/Since" in headers:
|
|
5823
|
+
eol_status_cell = ws.cell(row=row_idx, column=headers["EOL Status"])
|
|
5824
|
+
if eol_status_cell.value == "Soon EoL":
|
|
5825
|
+
days_cell = ws.cell(row=row_idx, column=headers["EOL Days Until/Since"])
|
|
5826
|
+
try:
|
|
5827
|
+
days_val = int(days_cell.value)
|
|
5828
|
+
except (TypeError, ValueError):
|
|
5829
|
+
days_val = None
|
|
5830
|
+
# days_val is negative (future) for Soon EoL; abs < 180 → orange
|
|
5831
|
+
if days_val is not None and abs(days_val) < 180:
|
|
5832
|
+
eol_status_cell.fill = orange_fill
|
|
5833
|
+
else:
|
|
5834
|
+
eol_status_cell.fill = yellow_fill
|
|
5835
|
+
|
|
5600
5836
|
# Special: Gray out entire row for disabled computers (after other formatting)
|
|
5601
5837
|
if is_disabled:
|
|
5602
5838
|
gray_fill = PatternFill(start_color="E0E0E0", end_color="E0E0E0", fill_type="solid")
|
|
@@ -6333,9 +6569,10 @@ class PyADRecon:
|
|
|
6333
6569
|
disabled_count = counts['disabled_count']
|
|
6334
6570
|
cat_total = counts['total_count']
|
|
6335
6571
|
|
|
6336
|
-
# Calculate percentages
|
|
6337
|
-
|
|
6338
|
-
|
|
6572
|
+
# Calculate percentages relative to the category total (how many of
|
|
6573
|
+
# the flagged users are enabled vs disabled) and relative to all users
|
|
6574
|
+
enabled_pct = f"{(enabled_count / cat_total * 100):.1f}%" if cat_total > 0 else "0.0%"
|
|
6575
|
+
disabled_pct = f"{(disabled_count / cat_total * 100):.1f}%" if cat_total > 0 else "0.0%"
|
|
6339
6576
|
total_pct = f"{(cat_total / total_count * 100):.1f}%" if total_count > 0 else "0.0%"
|
|
6340
6577
|
|
|
6341
6578
|
user_stats_ws.append([
|
|
@@ -6414,7 +6651,28 @@ class PyADRecon:
|
|
|
6414
6651
|
cat_total,
|
|
6415
6652
|
total_pct
|
|
6416
6653
|
])
|
|
6417
|
-
|
|
6654
|
+
|
|
6655
|
+
# EOL Summary section
|
|
6656
|
+
computer_stats_ws.append([])
|
|
6657
|
+
eol_heading_cell = WriteOnlyCell(computer_stats_ws, value="EOL Summary")
|
|
6658
|
+
eol_heading_cell.font = Font(bold=True, size=12)
|
|
6659
|
+
computer_stats_ws.append([eol_heading_cell])
|
|
6660
|
+
computer_stats_ws.append([])
|
|
6661
|
+
|
|
6662
|
+
eol_header_row = []
|
|
6663
|
+
for header in ["EOL Status", "Count", "Percentage"]:
|
|
6664
|
+
cell = WriteOnlyCell(computer_stats_ws, value=header)
|
|
6665
|
+
cell.font = header_font
|
|
6666
|
+
cell.fill = header_fill
|
|
6667
|
+
cell.alignment = left_alignment
|
|
6668
|
+
eol_header_row.append(cell)
|
|
6669
|
+
computer_stats_ws.append(eol_header_row)
|
|
6670
|
+
|
|
6671
|
+
eol_stats = computer_stats.get('eol_stats', {})
|
|
6672
|
+
for label, count in eol_stats.items():
|
|
6673
|
+
pct = f"{(count / total_count * 100):.1f}%" if total_count > 0 else "0.0%"
|
|
6674
|
+
computer_stats_ws.append([label, count, pct])
|
|
6675
|
+
|
|
6418
6676
|
# Order sheets according to SHEET_ORDER, then add any remaining
|
|
6419
6677
|
# (excluding AboutPyADRecon since it was already created first)
|
|
6420
6678
|
ordered_names = []
|
|
@@ -6992,6 +7250,27 @@ def generate_excel_from_csv(csv_dir: str, output_file: str = None):
|
|
|
6992
7250
|
total_pct
|
|
6993
7251
|
])
|
|
6994
7252
|
|
|
7253
|
+
# EOL Summary section
|
|
7254
|
+
computer_stats_ws.append([])
|
|
7255
|
+
eol_heading_cell = WriteOnlyCell(computer_stats_ws, value="EOL Summary")
|
|
7256
|
+
eol_heading_cell.font = Font(bold=True, size=12)
|
|
7257
|
+
computer_stats_ws.append([eol_heading_cell])
|
|
7258
|
+
computer_stats_ws.append([])
|
|
7259
|
+
|
|
7260
|
+
eol_header_row = []
|
|
7261
|
+
for header in ["EOL Status", "Count", "Percentage"]:
|
|
7262
|
+
cell = WriteOnlyCell(computer_stats_ws, value=header)
|
|
7263
|
+
cell.font = header_font
|
|
7264
|
+
cell.fill = header_fill
|
|
7265
|
+
cell.alignment = left_alignment
|
|
7266
|
+
eol_header_row.append(cell)
|
|
7267
|
+
computer_stats_ws.append(eol_header_row)
|
|
7268
|
+
|
|
7269
|
+
eol_stats = computer_stats.get('eol_stats', {})
|
|
7270
|
+
for label, count in eol_stats.items():
|
|
7271
|
+
pct = f"{(count / total_count * 100):.1f}%" if total_count > 0 else "0.0%"
|
|
7272
|
+
computer_stats_ws.append([label, count, pct])
|
|
7273
|
+
|
|
6995
7274
|
# Process each CSV file (excluding AboutPyADRecon as it was already created)
|
|
6996
7275
|
remaining_csv_files = [f for f in csv_files if f != 'AboutPyADRecon.csv']
|
|
6997
7276
|
total_files = len(remaining_csv_files)
|
pyadrecon-0.13.5/package.json
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|