# localhost-open-ports

List which TCP ports are listening on this machine's loopback and flag ones not on an allow-list

- **Space:** cybersecurity-public (https://github.com/Tech-Realm/space-cybersecurity-public/tree/main/localhost-open-ports)
- **Level:** L2 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3
- **Routes:** local-python, lsof; checks: 3
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use cybersecurity-public/localhost-open-ports` or MCP `get_pack cybersecurity-public/localhost-open-ports`
- **Files:** CHANGELOG.md, code/ports.py, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/results.json, pack.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

## Goal

A list of listening TCP ports on 127.0.0.1 (connect test, loopback only) compared with an allow-list, so unexpected local services are noticed.

Verified by: Self-test opens a listener on an ephemeral loopback port and the scanner finds it and flags it as unexpected.

## Steps

1. Run `python3 code/ports.py --range 1-10000 --allow 22,5432`.
2. For each unexpected port run `lsof -nP -iTCP:<port> -sTCP:LISTEN` to see the process.
3. Stop or bind the service to loopback/firewall it if it should not be there.

## Edge cases

- Services bound only to a LAN IP (not 127.0.0.1) are not seen by a loopback scan; use lsof for the full list.
- Large ranges take a few seconds; timeouts are short because loopback is fast.

## Don'ts

- The script refuses any host other than 127.0.0.1/::1; do not modify it to scan other hosts.
- Don't kill processes from this report without knowing what they are.



---

Canonical URL: https://logicpacks.io/packs/cybersecurity-public/localhost-open-ports

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
