#!/usr/bin/perl -w # # Generate nmap-like reports from siphon output # qwer7y@subterrain.net use strict; use Socket; use Getopt::Std; use vars qw/$opt_r $foundos @foundport $port $service $h $os/; getopts('r'); my $host = shift; my $file = shift || die qq{Usage: perl report.pl [-r] -r resolve host names.\n}; open F, $file or die "Cannot open '$file': $!\n"; while() { # verbose mode? ($h, $port, $os) = /O(?:N|FF)/ ? /^(\S+)\s+(\d+)\s+\d+\s+\w+\s+(.*?$)/ : split /\s+/, $_, 3; if ($h eq $host) { $foundos = $os; push @foundport, $port; } } close F; if ($foundos) { if ($opt_r) { $host = gethostbyaddr(inet_aton($host), AF_INET) || $host; } print "Host: $host\n"; print "Operating system: $foundos\n"; print "Port\t\t\tService\t\t\tProtocol\n"; for $port (sort @foundport) { $service = getservbyport($port, "tcp") || 'unknown'; print "$port\t\t\t$service\t\t\ttcp\n"; } }