Skip to content

Instantly share code, notes, and snippets.

@marcinantkiewicz
Created May 16, 2022 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcinantkiewicz/434f3f3518b4090c1ef5c7fc9f87927d to your computer and use it in GitHub Desktop.
Save marcinantkiewicz/434f3f3518b4090c1ef5c7fc9f87927d to your computer and use it in GitHub Desktop.
# scan network for open ports, list IPs that have something listening on those ports
# You can list multiple ports, separate them by commas (22,80,443).
function check_port() { NETWORK="$1"; shift; PORTS="$1"; shift; [ -z "$PORTS" ] && echo "Use: check_port CIDR PORTS - scans CIDR, prints ip if it listens on comma separated PORTS." && return 1; nmap --open -p "${PORTS}" "${NETWORK}" -oG - | awk '/\/open/ {print $2 }'; }
function check_port() {
NETWORK="$1"; shift;
PORTS="$1"; shift;
[ -z "$PORTS" ] && \
echo "Use: check_port CIDR PORTS - scans CIDR, prints ip if it listens on comma separated PORTS." && \
return 1;
nmap --open -p "${PORTS}" "${NETWORK}" -oG - | awk '/\/open/ {print $2 }';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment