Skip to content

Packs / cybersecurity-public

localhost-open-ports

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

L2 Checks passed 3 of 3 runsv1.0.0Tech-Realm/space-cybersecurity-public

Install

logicpacks pack use cybersecurity-public/localhost-open-ports
get_pack cybersecurity-public/localhost-open-ports

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

None.

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: local-pythonlsof
  • Checks: 3 in outcome/checks.yaml
  • Code: ports.py
  • Tools: python3

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from 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.