Bash public

Listening Ports Snapshot

Share this script safely, inspect its metadata, and copy the exact command you need.

Dashboard

Ready to run

One-liner

Copy the command, then review before execution.
curl -fsSL https://runny.sh/r/MY1TK236P0KN | bash

Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.152

At a glance

Script metadata

Slug
MY1TK236P0KN
Fetches
0
Size
1309 B · 55 lines
Expires
never
Last fetch
Created
2026-09-07 00:35:59.093
Description
TCP and UDP sockets currently accepting connections

Readable before runnable

Preview

#!/usr/bin/env bash
# Listening ports
# Read-only: lists TCP/UDP listeners via ss -lntup, falling back to netstat.
# Exit 0 if a listener table was printed, 1 if empty, 2 if no tool is available.
# Hosted on Runny.sh. Review the script page before you run it.

set -u

status=0
note() { printf '%s\n' "$*"; }
bump() {
  case $1 in
    crit) status=2 ;;
    warn) [ "$status" -lt 1 ] && status=1 ;;
  esac
}

note "=== Listening TCP/UDP ports ==="
note "Host:     $(hostname 2>/dev/null || printf unknown)"
note ""

table=""
if command -v ss >/dev/null 2>&1; then
  table=$(ss -lntup 2>/dev/null || true)
  note "Source:   ss -lntup"
elif command -v netstat >/dev/null 2>&1; then
  table=$(netstat -lntup 2>/dev/null || true)
  note "Source:   netstat -lntup"
else
  note "ss/netstat not found in PATH"
  note "Result: CRITICAL"
  exit 2
fi

if [ -z "${table}" ]; then
  note "No listening sockets reported (may need privileges for process names)."
  bump warn
else
  printf '%s\n' "$table"
  listeners=$(printf '%s\n' "$table" | awk 'NR > 1 && NF {n++} END {print n+0}')
  note ""
  note "Listeners: ${listeners}"
  if [ "$listeners" -eq 0 ]; then
    bump warn
  fi
fi
note ""

case $status in
  0) note "Result: HEALTHY" ;;
  1) note "Result: WARNING" ;;
  *) note "Result: CRITICAL" ;;
esac
exit "$status"

Raw endpointhttps://runny.sh/r/MY1TK236P0KN

See something unsafe?

Report this script

Tell us why it should come down. Anyone can also report a URL at /abuse.

Restore revision