Last active
January 30, 2025 16:21
-
-
Save umutbasal/b1910c6d2b3abad42ef7fc1be6362801 to your computer and use it in GitHub Desktop.
Get top n TCP/UDP ports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ports(){ | |
protocol=${1:-tcp} | |
count=${2:-65535} | |
curl -s https://svn.nmap.org/nmap/nmap-services | awk '!/^#/ && NF >= 3 && /'$protocol'/ {split($2, p, "/"); print p[1], $3}' | sort -k2,2nr | awk '{print $1}' | head -n $count | tr '\n' ',' | sed 's/,$//' | |
} | |
# Usage | |
# ports tcp 10 > ports.txt && naabu -ports-file=ports.txt -host 127.0.0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment