4 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
sub checkips
{
foreach $line(@IPLIST)
{
$CURRENTIP = "$line";
my $ftp = "";
$ftp = Net::FTP->new("$CURRENTIP", Debug => 1);
$ftp->login("anonymous",'-anonymous@') || do {$FTPCODE = "nologin"};
foreach(@FOLDERS)
{
$CURRENTFOLDER = "$_";
print "* Now scanning $CURRENTIP with folder $CURRENTFOLDER:";
if ($FTPCODE ne 'nologin')
{
$ftp->cwd("$CURRENTFOLDER") || do {$FTPCODE = "nocwd"};
if ($FTPCODE ne 'nocwd')
{
$ftp->put("$TESTFILE") || do {$FTPCODE = "noput"};
if ($FTPCODE ne 'noput')
{
push(@OPENIPS, "IP: $CURRENTIP with Folder: $CURRENTFOLDER");
}
}
}
print "\n\n";
}
$ftp->quit();
}
}
my $var1 = $var_old;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use Net::FTP;
my $ftp_user = 'anonymous';
my $ftp_pwd = 'anonymous';
my @FOLDERS = ('folder1' , 'folder2');
my @IPLIST = ('xxx.xxx.xxx.xxx');
my $TESTFILE = 'testfile.txt';
my @open_ips = checkips(\@FOLDERS, \@IPLIST, $TESTFILE, $ftp_user, $ftp_pwd);
print join("\n", @open_ips);
sub checkips
{
my ($ref_FOLDERS, $ref_IPLIST, $TESTFILE, $user, $pwd) = @_;
my @OPENIPS;
foreach my $CURRENTIP (@{$ref_IPLIST}) {
print "Trying $CURRENTIP\n";
my $ftp = Net::FTP->new($CURRENTIP, Debug => 0) or ( print "Cannot connect to $CURRENTIP: $@" and next );
$ftp->login($user,"-$pwd\@") or ( print "Cannot login " , $ftp->message and next );
foreach my $CURRENTFOLDER (@{$ref_FOLDERS}) {
print "* Now scanning $CURRENTIP with folder $CURRENTFOLDER:\n";
$ftp->cwd("/$CURRENTFOLDER") or ( print "Cannot change working directory to $CURRENTFOLDER: ", $ftp->message and next );
#print "PWD: " . $ftp->pwd . "\n";
$ftp->put("$TESTFILE") || ( print "Cannot put $TESTFILE to $CURRENTFOLDER: ", $ftp->message and next);
push(@OPENIPS, "IP: $CURRENTIP with Folder: $CURRENTFOLDER");
print "\n\n";
}
$ftp->quit();
}
return @OPENIPS;
}
4 Einträge, 1 Seite |