#!/usr/bin/perl -w # # sumports # # summarize TCP ports from tethereal output # # Nick DeBaggis # use strict; my %hash; my $total = 0; while(<>){ chomp; if(m/.*(TCP\s+\d+)\s+/){ $hash{$1}++; } } print "Open Port Statistics\n\n"; foreach(sort {$hash{$b} <=> $hash{$a}} keys %hash){ printf("%-36s %8d\n", $_, $hash{$_}); $total += $hash{$_}; } printf("\n%-36s %8d\n", "Total:", $total);