Chinaunix
标题:
扫描问题求助..
[打印本页]
作者:
wyz5678
时间:
2004-04-12 15:08
标题:
扫描问题求助..
本人初学perl,想写一个能判断web目录是否能put的程序.写完后发现对单个ip的扫描没有问题,想从文件读入一个ip列表,或者扫描一个段的时候发现程序总是在扫描完第一个ip后不再执行,请问是什么原因导致程序无法进行下去.谢
以下是程序
#!c:\perl\bin\perl
use IO::Socket;
@list=('/','/scripts/','/cgi-bin/','/_mem_bin/','/msadc/','/_private/','/_vti_pvt/','/_vti_bin/','/iissamples/','/pbserver/','/cfdocs/','/iisadmin/','/iisadmpwd/','/_private/','/news/','/events/','/publications/','/exchange/');
if (@ARGV < 2) {
print "Usage: iplistfile port\n";
exit;
}
else{
$host=$ARGV[0];
$port=$ARGV[1];
}
open(IPLIST, "$host"
||die "can not open the file!";
@iplist=<IPLIST>;;
close(IPLIST);
foreach $eeee(@iplist){
chomp $eeee;
foreach(@list){
$socket= IO::Socket::INET->;new(Proto=>;"TCP",
PeerAddr=>;"$eeee",
PeerPort=>;"$port"
or die "Cant connect to $eeee: $!\n";
#print "$_\n";
print $socket "
UT ${_}123.txt HTTP/1.1\n";
print $socket "Host: $eeee\n";
print $socket "Content-Length: 10\n";
print $socket "AAAAAAAAAAA\n\n\n";
$socket->;recv($rbuf,200);
$socket->;recv($rbud,150);
#print "$rbud\n";
if($rbud=~/201/){
print "$_ OK!!\n";}
else{
print "$_ shit...\n";
}
close($socket);
sleep(3);
}
}
作者:
xiayaazinabu
时间:
2004-04-13 10:26
标题:
扫描问题求助..
@iplist=<IPLIST>;; 只会把文件的第一行输入变量
要用while循环
open(IPLIST, "$host"
||die "can not open the file!";
while(< IPLIST>
{
$iplist=< IPLIST>;;
push(@iplist, $iplist);
}
close(IPLIST);
你参照你的代码改一下把
作者:
wyz5678
时间:
2004-04-13 13:18
标题:
扫描问题求助..
@iplist=<IPLIST>;; 是把文件的每一行读入一个数组,然后foreach $eeee(@iplist)遍历数组的每一个单位放到$eeee里,这句应该没错呀.
作者:
apile
时间:
2004-04-13 13:28
标题:
扫描问题求助..
chomp $eeee;
改成
$eeee=~s/[\015\012]//g;
我猜是\r在搞鬼...
作者:
wyz5678
时间:
2004-04-13 13:57
标题:
扫描问题求助..
非常感谢你的建议,但我试过还是不行。
我在想是不是IO::Socket的问题。。。。
作者:
xiayaazinabu
时间:
2004-04-13 18:23
标题:
扫描问题求助..
不好意思,看成$了
下面这两个循环好像不太对把(摘自源码)
foreach $eeee(@iplist){
chomp $eeee;
foreach(@list){
$socket= IO::Socket::INET->;new(Proto=>;"TCP",
........................
close($socket);
sleep(3);
}
}
作者:
apile
时间:
2004-04-13 21:34
标题:
扫描问题求助..
可能有null存在$eeee或$eeee有空白....試試看..
foreach $eeee(@iplist){
$eeee=~s/[\015\012]//g;
$eeee=~s/\s//g;
next if $eeee eq "";
作者:
wyz5678
时间:
2004-04-14 04:01
标题:
扫描问题求助..
apile我爱你~.............................OK了
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2