This Python script is designed as a diagnostic and compliance tool for establishments operating
under Texas DPS and TABC oversight. It performs a targeted port scan on the loopback range
127.0.0.1–127.0.0.254 to verify that specific systems critical to public safety and financial
integrity are reachable and correctly configured.
The script does not attempt exploitation or unauthorized access. It only checks whether designated TCP and UDP ports are open, for systems that the operator owns or administers:
The goal is to provide a repeatable, auditable method to confirm that these services are listening on expected ports, supporting investigations, compliance checks, and incident response.
The script:
127.0.0.1 to 127.0.0.254.socket.connect_ex() to determine if a port is open.NVR_RTSP, StateID_API).This allows DPS and TABC to verify that:
Below is the exact script used for targeted scanning. It is intentionally simple, deterministic, and suitable for forensic and compliance documentation.
#!/usr/bin/env python3
import socket
import time
TIMEOUT = 0.4
# ============================
# Targeted Industry Port List
# ============================
TARGETED_PORTS = {
# -------------------------
# NVR / CCTV Systems
# -------------------------
"NVR_RTSP": 554,
"NVR_HTTP": 80,
"NVR_HTTPS": 443,
"NVR_ONVIF": 3702,
"NVR_SMB": 445,
"NVR_UPNP": 1900,
# -------------------------
# pcAmerica POS Systems
# -------------------------
"POS_SQL": 1433,
"POS_HTTP": 8080,
"POS_LICENSE": 11600,
"POS_BACKOFFICE": 11700,
# -------------------------
# Heartland Payments
# -------------------------
"Heartland_API": 443,
"Heartland_Terminal": 8443,
"Heartland_Gateway": 2099,
# -------------------------
# Lone Star National Bank Submission
# -------------------------
"LSNB_SFTP": 22,
"LSNB_FTP": 21,
"LSNB_TLS": 990,
"LSNB_API": 443,
# -------------------------
# State ID Scanning Systems
# -------------------------
"StateID_HTTP": 8081, # Web interface for ID scanning
"StateID_HTTPS": 8443, # Secure ID scan submission
"StateID_API": 5000, # REST API for ID validation
"StateID_DB": 3306, # MySQL / MariaDB backend
"StateID_Auth": 1812, # RADIUS authentication
"StateID_SMB": 445, # Shared storage for scanned IDs
}
def scan_tcp(target, port):
"""TCP connect scan."""
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(TIMEOUT)
return s.connect_ex((target, port)) == 0
except Exception:
return False
def scan_udp(target, port):
"""UDP best-effort scan."""
try:
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.settimeout(TIMEOUT)
s.sendto(b"", (target, port))
try:
s.recvfrom(1024)
return True
except socket.timeout:
return False
except Exception:
return False
def main():
print("Targeted Port Scan for 127.0.0.1–254\\n")
start = time.time()
for last_octet in range(1, 255):
target = f"127.0.0.{last_octet}"
print(f"\\n=== Scanning {target} ===")
for name, port in TARGETED_PORTS.items():
tcp_status = scan_tcp(target, port)
udp_status = scan_udp(target, port)
if tcp_status:
print(f"[TCP OPEN] {target:<15} {port:<5} {name}")
if udp_status:
print(f"[UDP OPEN] {target:<15} {port:<5} {name}")
print(f"\\nScan complete. Elapsed: {time.time() - start:.2f} seconds")
if __name__ == "__main__":
main()
Note: This script is intended for use only on systems and networks where the operator has authorization. It is a diagnostic tool, not an intrusion tool.
For Texas DPS and TABC, the presence and correct configuration of these services directly impacts:
This targeted port scan provides a technical snapshot of those services, supporting audits, investigations, and compliance reviews in a structured, reproducible way.