#!/usr/bin/perl -w # portscan.pl -- Version 07-Dec-2001 # Copyright (c) 2001 Jochen Kupperschmidt <jochen@kupperschmidt.de> # Released under the terms of the GNU General Public License # _ _ # | |_ ___ _____ ___ _ _ _ ___ ___| |_ # | | . | | ._| | | | . | _| . / # |_|_|___|_|_|_|___|_____|___|_| |_|_\ # http://homework.nwsnet.de/ use IO::Socket; my ($host, $from, $to, $port, $socket); ($host = $ARGV[0]) or die "Usage: $0 <host> [start port] [end port]\n"; $from = ($ARGV[1] || 1); $to = ($ARGV[2] || 1024); printf("Scanning host '%s'\n", $host); for ($port = $from; $port <= $to; $port++) { $socket = IO::Socket::INET->new( PeerAddr => $host, PeerPort => $port, Proto => 'tcp' ); if ($socket) { printf(" Found port %" . length($to) . "d open\n", $port); } }