Java perl脚本显示错误:找不到文件

Java perl脚本显示错误:找不到文件,java,perl,Java,Perl,我试图运行以下perl脚本,但它显示了一个错误。我将所需文件放置在脚本文件的同一目录中 #! /usr/bin/perl @attackFileList=("_perParamDefaut_URLs.txt", "_perParam_URLs.txt", "_Cartesian_URLs.txt", "_Random_URLs.txt"); @legitFileList=("_Legit_URLs.txt"); $app=$ARGV[0]; print "Testing $app\n";

我试图运行以下perl脚本,但它显示了一个错误。我将所需文件放置在脚本文件的同一目录中

#! /usr/bin/perl

@attackFileList=("_perParamDefaut_URLs.txt", "_perParam_URLs.txt", "_Cartesian_URLs.txt", "_Random_URLs.txt");
@legitFileList=("_Legit_URLs.txt");

$app=$ARGV[0];

print "Testing $app\n";
$startTime=time();
$attackCaught=$notCaught=$syntaxError=$other=$total=$error=$redirect=$success=0;
for $fileEnding (@attackFileList) {
    $fileName="$app$fileEnding";
    open(inputFile, "D:\\$app/$fileName") || die "Could not open $fileName\n";
    while ($line=<inputFile>) {
        chomp $line;
        @wget = split / /, $line;

        if ($wget[1] ne "--post-data") {
                        $wget[1] =~ s/"/\\"/g;
                $wget[1] =~ s/`/\\`/g;
                $wget[1] =~ s/_nosessions/_current/;
                $wget[1] =~ s/endeavor.cc.gt.atl.ga.us/localhost:8080/;
                $wget[1] =~ s/^\\"(.*)\\"$/"\1"/;
                $command=$wget[0]." -O - "."\"".$wget[1]."\"";
        } else {
                $wget[2] =~ s/"/\\"/g;
                $wget[2] =~ s/`/\\`/g;
                $wget[3] =~ s/_nosessions/_current/;
                $wget[3] =~ s/endeavor.cc.gt.atl.ga.us/localhost:8080/;
            $wget[2] =~ s/^\\"(.*)\\"$/"\1"/;
            $command=$wget[0]." -O - ".join(" ", $wget[1], $wget[2], $wget[3]);
        }

        $output=`$command 2>&1`;
        $retValue=$?>>8;
        if (($retValue == 0)||($output=~/302 Moved Temporarily/)) {
            if ($output=~/amnesia\.SQLIAException/) {
                    $attackCaught++;
                #print errorLog "PolicyViolationException:\n \t$wget[3]\n\t$wget[2]\n\t$command\n\n";
                } elsif ($output=~/amnesia\.UndetectedSQLIA/) {
                    $notCaught++;
                print errorLog "UndetectedSQLIA:\n \t$wget[3]\n\t$wget[2]\n\t$command\n\n";
                } elsif ($output=~/lexer\.SQLLexerException/) {
                    $syntaxError++;
                #print errorLog "SyntaxError:\n \t$wget[3]\n\t$wget[2]\n\t$command\n\n";
                } else {
                if ($output=~/302 Moved Temporarily/) {
                    $redirect++;
                }
                    $other++;
            }
            $success++;
        } else {
            $error++;
        }
        $total++;
        if (($total % 100) == 0) {print "$total, ";}
    }
    close(inputFile);
}
print "\n";
$endTime=time();

$elapsedTime=$endTime-$startTime;

print "**Testing Results: Attack**\n";
print "Total: $total\n";
print "\tValid URL requests: $success\n";
print "\t\tSQLIA detected: $attackCaught\n";
print "\t\tUndetected: $notCaught\n";
print "\t\tSyntax Errors: $syntaxError\n";
print "\t\tOther: $other\n";
print "\t\t\tRedirects: $redirect\n";
print "\tError URL requests: $error\n";
$omitted=$total-$error-$success;
print "\tOmitted: $omitted\n";
print "\nTime: $elapsedTime seconds\n";

open (outFile, ">>Effective.results") || die "Could not open Effective.results\n";
print outFile "$app-attk\t$total\t$success\t$attackCaught\t$notCaught\t$syntaxError\t$other\t$error\t$omitted\n";
close(outFile);

$startTime=time();
$attackCaught=$notCaught=$syntaxError=$other=$total=$error=$redirect=$success=0;
foreach $fileEnding (@legitFileList) {
    $fileName="$app$fileEnding";
    open(inputFile, "$app/$fileName") || die "Could not open $fileName\n";
    while ($line=<inputFile>) {
        chomp $line;
        @wget = split / /, $line;

        if ($wget[1] ne "--post-data") {
            $wget[1] =~ s/"/\\"/g;
                $wget[1] =~ s/`/\\`/g;
            $wget[1] =~ s/_nosessions/_current/;
            $wget[1] =~ s/endeavor.cc.gt.atl.ga.us/localhost:8080/;
            $wget[1] =~ s/^\\"(.*)\\"$/"\1"/;
                    $command=$wget[0]." -O - "."\"".$wget[1]."\"";
        } else {
            $wget[2] =~ s/"/\\"/g;
                        $wget[2] =~ s/`/\\`/g;
            $wget[3] =~ s/_nosessions/_current/;
            $wget[3] =~ s/endeavor.cc.gt.atl.ga.us/localhost:8080/;
            $wget[2] =~ s/^\\"(.*)\\"$/"\1"/;
            $command=$wget[0]." -O - ".join(" ", $wget[1], $wget[2], $wget[3]);
        }

        $output=`$command 2>&1`;
        $retValue=$?>>8;
        if (($retValue == 0)||($output=~/302 Moved Temporarily/)) {
            if ($output=~/amnesia\.SQLIAException/) {
                    $attackCaught++;
                print errorLog "SQLIAException:\n\t$wget[3]\n\t$wget[2]\n\t$command\n\n";
                } elsif ($output=~/amnesia\.UndetectedSQLIA/) {
                    $notCaught++;
                print errorLog "UndetectedSQLIA:\n \t$wget[3]\n\t$wget[2]\n\t$command\n\n";
                } elsif ($output=~/lexer\.SQLLexerException/) {
                    $syntaxError++;
                print errorLog "SyntaxError:\n \t$wget[3]\n\t$wget[2]\n\t$command\n\n";
                } else {
                if ($output=~/302 Moved Temporarily/) {
                    $redirect++;
                }
                    $other++;
            }
            $success++;
        } else {
            $error++;
        }

        $total++;
        if (($total % 100) == 0) {print "$total, ";}
    }
    close(inputFile);

}
print "\n";
$endTime=time();
close(errorLog);
$elapsedTime=$endTime-$startTime;

print "**Testing Results: Legit**\n";
print "Total: $total\n";
print "\tValid URL requests: $success\n";
print "\t\tSQLIA detected: $attackCaught\n";
print "\t\tUndetected: $notCaught\n";
print "\t\tSyntax Errors: $syntaxError\n";
print "\t\tOther: $other\n";
print "\t\t\tRedirects: $redirect\n";
print "\tError URL requests: $error\n";
$omitted=$total-$error-$success;
print "\tOmitted: $omitted\n";
print "\nTime: $elapsedTime seconds\n";

open (outFile, ">>Effective.results") || die "Could not open Effective.results\n";
print outFile "$app-legit\t$total\t$success\t$attackCaught\t$notCaught\t$syntaxError\t$other\t$error\t$omitted\n";
close(outFile);
#/usr/bin/perl
@attackFileList=(“\u perParamDefaut\u URLs.txt”、“\u perParam\u URLs.txt”、“\u Cartesian\u URLs.txt”、“\u Random\u URLs.txt”);
@legitFileList=(“_Legit_url.txt”);
$app=$ARGV[0];
打印“测试$app\n”;
$startTime=时间();
$attackcatch=$notcatch=$syntaxError=$other=$total=$error=$redirect=$success=0;
对于$fileEnding(@attackFileList){
$fileName=“$app$fileEnding”;
打开(inputFile,“D:\\$app/$fileName”)| | die“无法打开$fileName\n”;
而($line=){
chomp$行;
@wget=拆分/,$行;
if($wget[1]ne--post数据){
$wget[1]=~s/“/\\\”/g;
$wget[1]=~s/`/\\\`/g;
$wget[1]=~s/_nosessions/_current/;
$wget[1]=~s/envor.cc.gt.atl.ga.us/localhost:8080/;
$wget[1]=“s/^\\”(.*)\\\“$/”\1/;
$command=$wget[0]。“-O-”\。$wget[1]。“\”;
}否则{
$wget[2]=~s/“/\\\”/g;
$wget[2]=~s/`/\\\`/g;
$wget[3]=~s/_nosessions/_current/;
$wget[3]=~s/eavor.cc.gt.atl.ga.us/localhost:8080/;
$wget[2]=“s/^\\”(.*)\\\“$/”\1/;
$command=$wget[0]。“-O-”.join(“,$wget[1],$wget[2],$wget[3]);
}
$output=`$command 2>&1`;
$retValue=$?>>8;
如果($retValue==0)| |($output=~/302临时移动/){
如果($output=~/健忘症\.SQLIAException/){
$attackcatch++;
#打印错误日志“PolicyViolationException:\n\t$wget[3]\n\t$wget[2]\n\t$command\n\n”;
}elsif($output=~/健忘症\.UndectedSQLIA/){
$notcatch++;
打印错误日志“UndectedSQLIA:\n\t$wget[3]\n\t$wget[2]\n\t$command\n\n”;
}elsif($output=~/lexer\.sqllexereException/){
$syntaxError++;
#打印错误日志“语法错误:\n\t$wget[3]\n\t$wget[2]\n\t$command\n\n”;
}否则{
如果($output=~/302临时移动/){
$redirect++;
}
$other++;
}
$success++;
}否则{
$error++;
}
$total++;
如果(($total%100)=0){打印“$total,”;}
}
关闭(输入文件);
}
打印“\n”;
$endTime=time();
$elapsedTime=$endTime-$startTime;
打印“**测试结果:攻击**\n”;
打印“总计:$Total\n”;
打印“\tValid URL请求:$success\n”;
打印“\t\tSQLIA检测到:$attackcatch\n”;
打印“\t\t检测到:$notcatch\n”;
打印“\t\t语法错误:$syntaxError\n”;
打印“\t\tOther:$other\n”;
打印“\t\t\t重定向:$redirect\n”;
打印“\t错误URL请求:$error\n”;
$impled=$total-$error-$success;
打印“\t已写入:$已省略\n”;
打印“\n时间:$elapsedTime秒\n”;
打开(outFile,“>>Effective.results”)| | die“无法打开Effective.results\n”;
打印输出文件“$app attk\t$total\t$success\t$attackcatch\t$notcatch\t$syntaxError\t$other\t$error\t$省略\n”;
关闭(输出文件);
$startTime=时间();
$attackcatch=$notcatch=$syntaxError=$other=$total=$error=$redirect=$success=0;
foreach$fileEnding(@legitFileList){
$fileName=“$app$fileEnding”;
打开(inputFile,“$app/$fileName”)| | die“无法打开$fileName\n”;
而($line=){
chomp$行;
@wget=拆分/,$行;
if($wget[1]ne--post数据){
$wget[1]=~s/“/\\\”/g;
$wget[1]=~s/`/\\\`/g;
$wget[1]=~s/_nosessions/_current/;
$wget[1]=~s/envor.cc.gt.atl.ga.us/localhost:8080/;
$wget[1]=“s/^\\”(.*)\\\“$/”\1/;
$command=$wget[0]。“-O-”\。$wget[1]。“\”;
}否则{
$wget[2]=~s/“/\\\”/g;
$wget[2]=~s/`/\\\`/g;
$wget[3]=~s/_nosessions/_current/;
$wget[3]=~s/eavor.cc.gt.atl.ga.us/localhost:8080/;
$wget[2]=“s/^\\”(.*)\\\“$/”\1/;
$command=$wget[0]。“-O-”.join(“,$wget[1],$wget[2],$wget[3]);
}
$output=`$command 2>&1`;
$retValue=$?>>8;
如果($retValue==0)| |($output=~/302临时移动/){
如果($output=~/健忘症\.SQLIAException/){
$attackcatch++;
打印错误日志“SQLIAException:\n\t$wget[3]\n\t$wget[2]\n\t$command\n\n”;
}elsif($output=~/健忘症\.UndectedSQLIA/){
$notcatch++;
打印错误日志“UndectedSQLIA:\n\t$wget[3]\n\t$wget[2]\n\t$command\n\n”;
}elsif($output=~/lexer\.sqllexereException/){
$syntaxError++;
打印错误日志“语法错误:\n\t$wget[3]\n\t$wget[2]\n\t$command\n\n”;
}否则{
如果($output=~/302临时移动/){
$redirect++;
}
$other++;
}
$success++;
}否则{
$error++;
}
$total++;
如果(($total%100)=0){打印“$total,”;}
}
关闭(输入文件);
}
打印“\n”;
$endTime=time();
关闭(错误日志);
$elapsedTime=$endTime-$startTime;
打印“**测试结果:合法**\n”;
打印“总计:$Total\n”;
打印“\tValid URL请求:$success\n”;
打印“\t\tSQLIA检测到:$attackcatch\n”;
打印“\t\t检测到:$notcatch\n”;
打印“\t\t语法错误:$syntaxError\n”;
打印“\t\tOther:$other\n”;
打印“\t\t\t重定向:$redirect\n”;
打印“\t错误URL请求:$error\n”;
$impled=$total-$error-$success;
打印“\t已写入:$已省略\n”;
打印“\n时间:$elapsedTime秒\n”;
打开(outFile,“>>Effective.results”)| | die“无法打开Effective.results\n”;
打印输出文件“$app legit\t$total\t$success\t$attackcatch\t$notcatch\t$syntaxError\t$other\t$error\t$省略\n”;
克洛斯
my $full_path = File::Spec->catpath( "D", $app, $fileName )
open( inputFile, $full_path) or die $!;
open my $fh, '<', $filename or die "Unable to open '$filename': $!";