<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/bin/perl
#Simple class C and D scanner in perl
#Copyright (C) 1997 gilbert@pgci.ca

#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

sub usage {
print "Syntax: scanbc [-c][-d] [a.b.c.d] or [evil.com]\n";exit(1);} 

sub flush {  
    local($old) = select(shift);
    $| = 1;
    print "";
    $| = 0;
    select($old);
}

if (@ARGV == 0) {&amp;usage;}

while (@ARGV &gt; 0) {
$switch = shift(@ARGV);
$net = shift(@ARGV);

	if ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
	($a,$b,$c,$d) = split(/\./, $net);
		 if (($c eq "") || ($c &gt; 256)) {
		 $c = 0;
		 }
		 if (($d eq "") || ($d &gt; 256)) {
   		 $d = 0;
		 }
	}
        # if host is name, not ip address
        else {
              ($host, $aliases, $type, $len, @ip) = gethostbyname($net);
              ($a,$b,$c,$d) = unpack('C4',$ip[0]);
             }

 if ($switch eq "-c") {
     	for ($classc=$c;$classc&lt;256;$classc++){
     		for ($classd=$d;$classd&lt;256;$classd++){
     		$host = "$a.$b.$classc.$classd";     
		@addr = split(/\./, $host);
     		$addr = pack(' C4', @addr[0], @addr[1], @addr[2], @addr[3]);
     		($name, $aliases, $type, $len, @addrs) = gethostbyaddr($addr, 2);
     			if ($name ne "") {
     			print STDOUT "$host \=\&gt; $name\n";
     			&amp;flush(STDOUT);
			}
		}
        }
 }
 if ($switch eq "-d") {
     for ($classd=$d;$classd&lt;256;$classd++) {
     $host = "$a.$b.$c.$classd";
     @addr = split(/\./, $host);
     $addr = pack(' C4', @addr[0], @addr[1], @addr[2], @addr[3]);
     ($name, $aliases, $type, $len, @addrs) = gethostbyaddr($addr, 2);
     	if ($name ne "") {
     	print STDOUT "$host \=\&gt; $name\n";
    	&amp;flush(STDOUT);
	}
     }
 }
}



</pre></body></html>