Busca informações sobre serviços com portas abertas

# netstat -nlpt | grep tcp > netstat.tmp ; cat netstat.tmp | awk -F ' ' '{print $4}' | cut -d : -f 2 | grep ^[0-9] > portas.tmp; netstat -nlpt | grep tcp | awk -F " " '{print $4}' | awk -F ":" '{ if ($1 == "") print $4 }' >> portas.tmp; cat netstat.tmp | awk -F ' ' '{print $7}' | cut -d '/' -f 2 | sed 's/:$//g' > servicos.tmp ; paste -d : servicos.tmp portas.tmp | uniq | sed 's/$/,/' | sed ':a;$!N;s/\n//;ta;' | sed 's/,$//g'; rm -f netstat.tmp portas.tmp servicos.tmp

Leave a Reply