精品推荐
用Perl写出自己的安全工具--初级
日期:2007年5月10日 作者: 查看:[大字体
中字体 小字体 ]
{
print "正在扫描 $netaddress.$count.$host n" ;
$ftp = Net::FTP->new("$netaddress.$count.$host", Debug => 0);
if ( $ftp ) #如果连接为空执行检验密码跳过,直接运行else中内容
{
$a=$ftp->login('oracle','oracle'); #校验密码 用户名为oracle 密码为 oracle
$ftp->quit; #ftp命令 quit
if ( $a == 1 ) #如果校验通过执行
{
open(OUTFILE, ">>host.txt"); #打开文件host.txt
print OUTFILE ("$netaddress.$count.$host n"); #向里面写入一行当前检验通过的ip地址
print "发现目标 $netaddress.$count.$host n" ;
}
}
else
{
print "连接 $netaddress.$count.$host 失败! n" ;
}
$host++;
}
$count++;
}
##############################################################################
telnetscaner.pl
###########################################################################
#!/usr/bin/perl
use Socket;
use Net::Telnet ();
# timeouts in seconds for creating a socket and connecting
my $MAX_SOCKET_TIME = 2;
my $MAX_CONNECT_TIME = 3;
my $HELP=qq{Usage: telnetdcheck [-h --help] [-p processes] [-d --debug] hostn};
my @hosts;
# how many simultaneous processes are we allowed to use?
my $MAX_PROCESSES=10;
my $DEBUG=0;
while($_=shift){
if(/^--(.*)/){
$_=$1;
if(/help/){
print $HELP;
exit(0);
}
if(/debug/){
$DEBUG=1;
}
}
elsif(/^-(.*)/){
$_=$1;
if(/^h/ or /^?/){
print $HELP;
exit(0);
}
if(/^p/){
$MAX_PROCESSES=shift;
}
if(/^d/){
$DEBUG=1;
}
}else{
push @hosts,$_;
}
}
if(!$hosts[0]){
print $HELP;
exit(-1);
}
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){
复制本页网址和标题,发送给你QQ/Msn的好友一起分享
上一篇:功能丰富的Perl:遗传算法仿真多细胞机体
下一篇:简单的PERL-ADO例子
用Perl写出自己的安全工具--初级 相关文章:
用Perl写出自己的安全工具--初级 相关软件: