#!/usr/bin/perl -w # written by Schuyler Erle use IO::Socket; use strict; $ENV{PATH} = "$ENV{PATH}:/sbin:/usr/sbin"; my $ifconfig = qx{ifconfig}; my @nets = ($ifconfig =~ /\bBcast:\s*(\S+)/ios); warn "found networks: @nets\n"; my $bcast = ""; $bcast = "-b" unless system("ping -c1 -b 127.0.0.0 2>&1 >/dev/null"); my $scan = qx{ping -c2 $bcast @nets 2>&1}; my @hosts = ($scan =~ /((?:\d{1,3}\.){3}\d{1,3})/gos); warn "found ", scalar(@hosts), " hosts. scanning...\n"; for my $host (keys %{{@hosts}}) { my $sock = IO::Socket::INET->new( PeerAddr => $host, PeerPort => 9100, Timeout => 2, Proto => "tcp" ); print "$host\n" if $sock; }