사용자 도구

사이트 도구


develop:perl:portscan

Perl을 이요하여 PortScan 하기

#!/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);
    }
}
develop/perl/portscan.txt · 마지막으로 수정됨: 2007/09/24 02:26 저자 starlits