Skip to content

Repository files navigation

ADMappingToolkit

Active Directory machine inventory and network recon - enumerate domain computers, probe reachability, scan ports, detect unconstrained delegation, flag end-of-support OS, and export results to CSV from the command line.

CIPowerShellLicense

Site · Documentation


Table of Contents


Overview

ADMappingToolkit is a hybrid SI mapping toolkit - it combines Active Directory inventory with active network scanning to give a unified view of everything on the network, whether it appears in AD or not.

Classic AD-based inventory tools only see machines they already know. In any real enterprise network, AD is structurally incomplete: unmanaged devices, IoT equipment, printers, Linux servers, NAS, network appliances, and shadow IT never register in AD. ADMappingToolkit closes this visibility gap by combining AD queries with active network probes in a single report.

Three runner scripts cover the three most common scopes: all machines, servers only, or clients only. Each is a thin wrapper around the module functions and exposes the full parameter set directly from the command line. No installation required beyond the RSAT ActiveDirectory module.


MITRE ATT&CK

TechniqueIDFeature
Remote System DiscoveryT1018AD enumeration, subnet/range scan via -Targets
Network Service ScanningT1046-TcpCheck, -CheckLDAP, -CheckWinRM, -CheckPSSession
System Network Configuration DiscoveryT1016-ResolveDns, IPv4Address / DNSHostName collection
Account Discovery: Domain AccountT1087.002AD computer account enumeration via Get-ADComputer
Domain Trust DiscoveryT1482-CheckUnconstrained (TrustedForDelegation attribute)
Steal or Forge Kerberos TicketsT1558Unconstrained delegation detection context

Features

CapabilityDescription
AD enumerationQuery all domain computers, filter by OS family, scope to OU
ICMP pingParallel or sequential, configurable count and timeout
TCP port scanCustom port list or Top5/Top10/Top20/Top50/Top100 keywords
WinRM / PSSessionConnectivity check via Test-WSMan and New-PSSession
LDAP checkProbe TCP 389 and 636
Unconstrained delegationFlag computers with TrustedForDelegation = True
End-of-support OSDetect Windows XP, 7, 2003, 2008, Vista, 8, 8.1
Stealth modeSequential scan with random delay between probes
Turbo modeParallel scan via ForEach-Object -Parallel (PS7+)
Target flexibilityMix AD names, wildcards, IPs, CIDR, and IP ranges
Built-in reportsInactive machines, open RDP exposure
CSV exportAuto-timestamped or explicit path

Quick Start

# Clone
git clone https://github.com/franckferman/ADMappingToolkit.git
cd ADMappingToolkit
# Discover all reachable machines
.\scripts\Check-All.ps1 -OnlyReachable -Stats
# Probe servers for SMB, RDP, WinRM
.\scripts\Check-Servers.ps1 -TcpCheck -Ports 445,3389,5985-OnlyReachable
# Flag end-of-support workstations and export
.\scripts\Check-Clients.ps1 -CheckEOS -ShowOU -AutoCsv
# Find computers with unconstrained delegation
.\scripts\Check-All.ps1 -ADOnly -CheckUnconstrained -ShowOU
# Stealth sweep with random 5-15 s delay
.\scripts\Check-All.ps1 -Stealth -StealthDelay 5,15-OnlyReachable

Project Structure

ADMappingToolkit.psm1 # Module - all inventory functions
scripts/
Check-All.ps1 # Get-MachineInventory (all OS)
Check-Servers.ps1 # Get-ServerInventory (Server OS)
Check-Clients.ps1 # Get-ClientInventory (Client OS)
tools/
Invoke-PSEncoder.py # Base64 UTF-16LE encoder for -EncodedCommand
Sign-Scripts.ps1 # Authenticode signing + RFC 3161 timestamp
docs/
index.html # Landing page
doc.html # Full documentation

Installation

Prerequisites: PowerShell 5.1+ and the RSAT ActiveDirectory module.

# Clone
git clone https://github.com/franckferman/ADMappingToolkit.git
# Unblock if downloaded from the internetGet-ChildItem-Recurse *.ps1,*.psm1 |Unblock-File# Optional: import the module directly for use in your own scriptsImport-Module .\ADMappingToolkit.psm1 -Force

The runner scripts import the module automatically from their parent directory. No manual import needed when using the scripts.


Scripts

Check-All.ps1

Wrapper for Get-MachineInventory. Queries all AD computer accounts regardless of OS.

.\scripts\Check-All.ps1 [parameters...]

Check-Servers.ps1

Wrapper for Get-ServerInventory. Pre-filters to Windows Server OS accounts before scanning.

.\scripts\Check-Servers.ps1 [parameters...]

Check-Clients.ps1

Wrapper for Get-ClientInventory. Pre-filters to Windows client OS (Windows 10/11/7/XP) accounts before scanning.

.\scripts\Check-Clients.ps1 [parameters...]

All three scripts accept the same parameter set described below.


Parameters

AD Query

ParameterDefaultDescription
-SearchBase""LDAP OU/DN to scope the AD query. Empty = entire domain.
-IncludeDisabledoffInclude disabled computer accounts.
-OnlyDisabledoffReturn only disabled accounts.
-MinDaysInactive0Filter to machines inactive for N+ days (0 = no filter).
-Targets-Override AD query: hostnames, IPs, CIDR, ranges, or wildcards.

Network Probing

ParameterDefaultDescription
-NoIcmpoffSkip ICMP ping entirely.
-PingCount1Number of ICMP echo requests per host.
-TimeoutMs1200TCP connect timeout in milliseconds.
-TcpCheckoffProbe TCP ports defined by -Ports.
-Ports445,3389,5985Comma-separated ports or Top5/Top10/Top20/Top50/Top100.
-CheckLDAPoffProbe TCP 389 and 636.
-CheckWinRMoffTest WinRM via Test-WSMan.
-CheckPSSessionoffAttempt New-PSSession for remote PS access check.
-ResolveDnsoffReverse-resolve IPs to hostnames for AD correlation.
-ADOnlyoffSkip all network probes, return AD attributes only.

Filtering

ParameterDefaultDescription
-OnlyReachableoffReturn only responsive hosts.
-OnlyUnreachableoffReturn only non-responsive hosts.

Performance

ParameterDefaultDescription
-TurbooffParallel scan via ForEach-Object -Parallel. Requires PS7+. Mutually exclusive with -Stealth.
-Threads50Thread count for Turbo mode (capped at 1000).
-StealthoffSequential scan with random delay. Disables Turbo automatically.
-StealthDelay2,10Min/max random delay in seconds for Stealth mode.

AD Enrichment

ParameterDefaultDescription
-CheckUnconstrainedoffFlag machines with TrustedForDelegation = True.
-CheckEOSoffFlag end-of-support OS versions.
-ShowOUoffInclude OU path in output.
-ShowDescriptionoffInclude AD computer description.
-ShowEnabledoffInclude Enabled column.
-Credential-PSCredential for AD and WinRM queries.

Output

ParameterDefaultDescription
-Properties*Select specific output columns.
-RawOutputoffReturn raw PSObject array, skip table formatting.
-StatsoffPrint total/reachable/unreachable summary.
-AutoCsvoffAuto-generate a timestamped CSV file.
-OutCsv""Export to specified CSV path.

Reports

ParameterDefaultDescription
-Report-Named report: Inactive or OpenRDP.
-ReportDays30Lookback window in days for the Inactive report.

Port Keywords

Pass a keyword to -Ports instead of a manual list. Setting a Top keyword automatically enables -TcpCheck.

KeywordPorts
Top521, 22, 80, 443, 3389
Top10Top5 + 25, 53, 135, 139, 445
Top20Top10 + 110, 143, 389, 1433, 3306, 5900, 5985, 8080, 8443
Top50Top20 + 23, 69, 88, 111, 119, 161, 162, 179, 199, ...
Top100Top50 + 1025, 1194, 1521, 1723, 2000, 2049, 4444, 5432, ...

Target Formats

The -Targets parameter accepts mixed input and bypasses the AD query for the specified entries:

FormatExampleBehavior
Hostname / AD nameDC01Direct AD lookup by name.
WildcardSRV-*AD filter: Name -like 'SRV-*'.
Single IP192.168.1.10Probed directly; optional PTR lookup with -ResolveDns.
CIDR192.168.1.0/24All host IPs in subnet (capped at 65536).
Short range192.168.1.1-50IPs from .1 through .50.
Full range10.0.0.1-10.0.0.100All IPs between the two addresses.
# Mixed: wildcard + CIDR
.\scripts\Check-All.ps1 -Targets SRV-*,192.168.10.0/24-TcpCheck -Ports 445,3389# IP range with DNS reverse lookup
.\scripts\Check-All.ps1 -Targets 10.0.0.1-50-ResolveDns -TcpCheck

Reports

Inactive

Returns machines whose last logon is older than -ReportDays days (default 30).

.\scripts\Check-All.ps1 -Report Inactive -ReportDays 90-ADOnly

OpenRDP

Returns machines with TCP 3389 open. Automatically enables -TcpCheck and adds port 3389 to the probe list.

.\scripts\Check-Clients.ps1 -Report OpenRDP
.\scripts\Check-Servers.ps1 -Report OpenRDP -OnlyReachable

Examples

# Full domain inventory, AD only
.\scripts\Check-All.ps1 -ADOnly -ShowOU -ShowDescription -ShowEnabled
# Top 20 port scan with Turbo (PS7+)
.\scripts\Check-All.ps1 -TcpCheck -Ports Top20 -Turbo -OnlyReachable -Stats
# Scope to a specific OU
.\scripts\Check-Servers.ps1 -SearchBase "OU=Servers,DC=corp,DC=local"-ADOnly
# WinRM + PSSession check on servers
.\scripts\Check-Servers.ps1 -CheckWinRM -CheckPSSession -OnlyReachable
# LDAP availability on all servers
.\scripts\Check-Servers.ps1 -CheckLDAP -OnlyReachable
# Stealth ping sweep
.\scripts\Check-All.ps1 -Stealth -StealthDelay 5,15-OnlyReachable
# Export reachable servers to CSV
.\scripts\Check-Servers.ps1 -OnlyReachable -OutCsv C:\Audit\servers.csv
# Pipeline: filter by open RDP and export$r= .\scripts\Check-All.ps1 -RawOutput -TcpCheck -Ports 3389$r|Where-Object { $_.TCP_3389 } |Export-Csv rdp-exposed.csv -NoTypeInformation
# Use alternate credentials$cred=Get-Credential
.\scripts\Check-All.ps1 -ADOnly -Credential $cred-CheckUnconstrained -ShowOU

Tools

tools/Invoke-PSEncoder.py

Generates powershell.exe -EncodedCommand oneliners from PS1 files or raw strings. Bypasses Restricted and AllSigned execution policies.

# Encode a script
python3 tools/Invoke-PSEncoder.py scripts/Check-All.ps1
# Encode a raw command
python3 tools/Invoke-PSEncoder.py -c ".\scripts\Check-All.ps1 -OnlyReachable -Stats"# Add flags
python3 tools/Invoke-PSEncoder.py scripts/Check-All.ps1 --hidden --bypass
# Quiet mode (oneliner only)
python3 tools/Invoke-PSEncoder.py -q scripts/Check-All.ps1

tools/Sign-Scripts.ps1

Signs all scripts in scripts/ and ADMappingToolkit.psm1 with Authenticode + RFC 3161 timestamp. The countersignature keeps signatures valid after certificate expiry.

Authenticode signing reduces detection surface: signed scripts bypass AllSigned execution policy without -ExecutionPolicy Bypass, and a valid signature lowers static heuristic scores in some EDRs and AV engines that weigh unsigned scripts more aggressively.

# Auto-generate temporary self-signed cert, sign, then remove cert
.\tools\Sign-Scripts.ps1
# Use an existing cert by thumbprint
.\tools\Sign-Scripts.ps1 -CertThumbprint "AB12CD..."# Use a different timestamp server
.\tools\Sign-Scripts.ps1 -TimestampServer "http://timestamp.sectigo.com"

Self-signed vs production:

Cert typeExecution policy bypassSmartScreenEDR static score
NoneRequires -ExecutionPolicy BypassFlaggedHigher risk weight
Self-signedPasses AllSigned if cert is trusted locallyStill flaggedSlight improvement
OV code-signingPasses AllSignedReduced warningsLower risk weight
EV code-signingPasses AllSignedInstant reputationBest reduction

For meaningful evasion improvement, use an OV or EV certificate (DigiCert, Sectigo, GlobalSign). EV certs provide instant SmartScreen reputation and the strongest reduction in static detection.


Use Cases

For security teams / RSSI

NeedHow
How many machines are actually on our network?Subnet scan with -Targets 10.0.0.0/24 -ResolveDns -Turbo
Do we have end-of-support OS?-CheckEOS flags Windows XP, 7, Vista, 2003, 2008, 2012
Which servers have RDP exposed?-Report OpenRDP
Ghost machines inactive for 90+ days?-MinDaysInactive 90 -ADOnly
Can we remotely administer a host?-CheckWinRM -CheckPSSession
Kerberos unconstrained delegation risk?-CheckUnconstrained
ISO 27001 / ANSSI asset inventory?Full subnet scan + -AutoCsv for timestamped evidence
Shadow IT / unmanaged devices?Scan returns non-AD objects as synthetic entries

AD correlation chain

When scanning a raw IP, the tool does not just report "this IP responded". It runs a full correlation chain:

  1. Reverse DNS lookup (Resolve-DnsName -Type PTR) to get the FQDN
  2. AD lookup by DNSHostName or Name to find a match
  3. If found: the entry is enriched with OS, OU, LastLogon, and all AD metadata
  4. If not found: a synthetic object is created — the machine is flagged as non-AD

This means a single subnet scan returns both your managed Windows fleet and every unmanaged device on the same network.

Real-World Results

Scan of a /24 subnet (254 hosts) in a production environment:

CategoryCountDetails
Total responding hosts126Out of 254 scanned
Windows machines (AD-matched)~50Workstations and servers enriched with OS, OU, LastLogon
Non-AD devices~76Printers, Raspberry Pi, NAS, Linux servers, IoT, appliances, smartphones
EOS servers detected2Windows Server 2012 R2, Windows Server 2008 R2

In one command: a complete 360-degree view of the network — managed and unmanaged alike.


License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

Any use, modification, or distribution - including over a network - requires the full source code to remain open under the same license.

Used by

Contributors

Languages