get-them

A simple script that shows totals connections per IP address to a TCP or UDP port.

getthem shows output in the terminal and optionally creates an HTML file with links to more information for each IP address

Example, see connections to port 80
$ getthem
TCP or UDP 80
     18 46.12.149.75
     17 204.12.219.170
     13 84.205.244.136
      8 92.118.99.42
      8 195.78.86.91
      6 79.129.116.143
      4 62.38.152.211
      2 95.92.7.178
      2 85.72.63.93
      2 150.70.173.54
      2 150.70.173.46
      2 150.70.173.44
      2 150.70.173.43
      1 72.14.199.54
      1 180.76.5.161
      1 164.61.210.150
      1 150.70.173.56
      1 150.70.173.53
      1 150.70.173.49
      1 150.70.173.45
      1 150.70.173.42
      1 150.70.173.40



Port 80 is the default port. You may set the port eg:
$ getthem 143
TCP or UDP 143
      3 79.129.59.177



The getthem script
#!/bin/bash
#g0 2012 - http://ipduh.com/contact
INFO="http://alog.ipduh.com/2013/02/get-them.html"
MID=`id -u`
TMP="/tmp/getthem.${MID}.tmp"
HTML="/home/public_html/get-them.html"
DATE=`date`

if [ -z $1 ];then
PORT="80"
else
PORT=${1}
fi

echo "TCP or UDP ${PORT}"

netstat -unta | grep ":${PORT}" | egrep -v "::${PORT}|0.0.0.0|127.0.0.1" | awk '{print $5}' | awk -F ":" '{print $1}' | sort |uniq -c|sort -nr | tee ${TMP}

echo "<html><head><title>get-them ${DATE}</title><body><br>${DATE}<br>Connection(s) on TCP or UDP port(s) ${PORT} <br><br><br>" > ${HTML}
cat ${TMP} |awk '{ print $1" <a href=http://ipduh.com/apropos/?"$2" target=blank>"$2"</a><br><br>" }' >> ${HTML}
echo "<br><br><a href=${INFO}>get_them source</a></body>" >> ${HTML}






Get them --a simple script that shows connections / IP address to an IP-TCP or IP-UDP port