Automated Network Enumeration with Python Tools
Asset inventory is the foundation of knowing what a team is responsible for. A safe first inventory workflow does not need broad active scanning: it can reconcile explicitly authorized device records from owner-approved exports, identify stale entries, and report gaps for follow-up. This makes ownership and scope visible before any network checks are considered.
An inventory might combine CMDB exports, cloud instance lists, endpoint-management reports, and DNS records. Each source has a timestamp and a limited view. A cloud resource list may omit unmanaged hardware, while DNS may contain stale names. Record the source and capture time rather than assuming every entry represents a live host.
Obtain and process only data the team is authorized to access. Avoid ingesting private discovery exports into consumer tools or unrestricted shared folders.
import csv
from io import StringIO
DATA = """asset_id,owner,environment,last_seen
svc-001,platform,prod,2026-10-24
svc-002,network,dev,2026-09-10
svc-001,platform,prod,2026-10-24
"""
records = list(csv.DictReader(StringIO(DATA)))
by_id = {}
for row in records:
asset_id = row["asset_id"].strip()
if not asset_id:
raise ValueError("missing asset ID")
if asset_id in by_id and by_id[asset_id] != row:
raise ValueError("conflicting records for " + asset_id)
by_id[asset_id] = row
assert len(by_id) == 2
for asset_id, record in sorted(by_id.items()):
print(asset_id, record["owner"], record["last_seen"])
The code only reads a made-up CSV string. There is no network probe, exploit attempt or directory enumeration. In real use, prefer durable resource IDs where possible; hostname and IP address alone can change or be reused.
A record’s last-seen timestamp is not proof that an asset is healthy or that it belongs in a specific business scope. Set a recency policy by asset class and data source. A mobile endpoint might legitimately be offline for days; a production virtual machine is expected to report more frequently. Flag the appropriate stale records and assign them to owners instead of deleting them automatically.
Resolve duplicates by authoritative owner or unique IDs, not arbitrary string matching. Two sources may describe the same service at different abstraction levels: a load balancer and its backing instances are not duplicates simply because they share a service name.
When authorized, an owner can confirm inventory discrepancies using provider consoles or a small bounded connectivity test. Do not turn missing data into permission to scan an unknown IP range. Rate, time windows, target allowlists, and expected effects must be approved. A denied connection does not establish that the asset no longer exists.
Use audit trails for any manual correction: who accepted the change, which source established the identity, and what should happen if the asset reappears.
Report total unique assets by owner and environment, missing-owner entries, duplicate/conflicting IDs, stale records, and the date of each source export. Include an exceptions table rather than a forced accuracy percentage. If the source itself is incomplete, label coverage as unknown instead of manufacturing a “100% discovered” claim.
A reconciliation process differs from live reconnaissance: its output is an accountable list of known records and specific unresolved questions.
Begin with authoritative records and ownership. Active checks, where truly needed, can be a small later step within a preapproved scope rather than the default method of building an asset inventory.