分类: 网络与安全
2008-10-11 12:15:07
The information within this database may change without notice/) {$flag = 0}; /\n/g; /\n/g;
if ($flag) {
$page[$i] = removeHtmltag ("$page[$i]");
if($page[$i] eq "") {
if(!$last) { $section_con .= "\n"; $last = 1;}
} else {
$section_con .= "$page[$i]\n";
$last = 0;
}
}
if ($page[$i] =~ m/X-Force Database Results/) {$flag = 1};
}
return $section_con;
}
sub getPage {
my ($url_section,$page_con) = @_;
open (EXECFILE, "$program '$url_section' |");
@{$page_con} =
close (EXECFILE);
}
sub removeHtmltag {
my ($string)=@_;
$string =~ s/\t//g;
$string =~ s/\n//g;
$string =~ s/ / /g;
$string =~ s/"/"/g;
$string =~ s/
/\n/g;
$string =~ s/
/\n/g;
$string =~ s/
/\n/g;
$string =~ s/
$string =~ s/
$string =~ s/<\/P>/\n/g;
$string =~ s/<\/p>/\n/g;
$string =~ s/
$string =~ s/
$string =~ s/—/-/g;
$string =~ s/<\/OPTION>/\n/g;
$string =~ s/<[^<]*>//g;
$string =~ s/</ $string =~ s/>/>/g;
$string =~ s/&/&/g;
$string =~ s/"/"/g;
$string =~ s/\015//g;
$string =~ s/^\s*\n*//;
# $string =~ s/\s*\n*$//;
return $string;
}
sub readDBcontent {
my ($table,$dbcon)=@_;
my $count=0;
open(TBL,"<$table")||die($table);
@{$dbcon}=
close(TBL);
for(my $i=0;$i<@{$dbcon};$i++) {
chomp(${$dbcon}[$i]);
if(${$dbcon}[$i] ne "") { $count++; }
}
return ($count);
}
--------------------------------- 8< --------------------------------------
extract-iss-cve.pl
--------------------------------- 8< --------------------------------------
#!/usr/bin/perl
#
my @issues = ("");
readDBcontent($ARGV[0],\@issues);
for (my $i=0;$i<@issues;$i++) {
my $issuetext = $issues[$i];
my ($aa,$bb,$cc,$vul_id) = split (',',$issuetext);
if ($vul_id =~ m/^\d+/) {
my $iss_vuln = "$vul_id.txt";
if ((-e $iss_vuln) && !(-z $iss_vuln)) {
my @contents = ("");
readDBcontent($iss_vuln,\@contents);
for (my $j=0;$j<@contents;$j++) {
if ($contents[$j] =~ m/^---(CVE-\d{4}-\d{4})/) {
print $1."\n";
}
}
}
}
}
sub readDBcontent {
my ($table,$dbcon)=@_;
my $count=0;
open(TBL,"<$table")||die($table);
@{$dbcon}=
close(TBL);
for(my $i=0;$i<@{$dbcon};$i++) {
chomp(${$dbcon}[$i]);
if(${$dbcon}[$i] ne "") { $count++; }
}
return ($count);
}
--------------------------------- 8< --------------------------------------
extract-idp-cve.pl
--------------------------------- 8< --------------------------------------
#!/usr/bin/perl
#
my @issues = ("");
readDBcontent($ARGV[0],\@issues);
for (my $i=0;$i<@issues;$i++) {
my $issuetext = $issues[$i];
if ($issuetext =~ m/:cve \((CVE-\d{4}-\d{4})\)/) {
print $1."\n";
}
}
sub readDBcontent {
my ($table,$dbcon)=@_;
my $count=0;
open(TBL,"<$table")||die($table);
@{$dbcon}=
close(TBL);
for(my $i=0;$i<@{$dbcon};$i++) {
chomp(${$dbcon}[$i]);
if(${$dbcon}[$i] ne "") { $count++; }
}
return ($count);
}
--------------------------------- 8< --------------------------------------
caculate-score.pl
--------------------------------- 8< --------------------------------------
#!/usr/bin/perl
if(scalar(@ARGV) < 2){
print "Usage: $0 CVES-LIST-FILE CVE-SCORE-PAIR-LIST-FILE\n";
exit 1;
}
my %cve_name_score = ();
my @score_data = ("");
readDBcontent($ARGV[1],\@score_data);
my $cur_name = "";
my $cur_score = 0.0;
foreach (@score_data) {
$_ =~ m/(.+)\t(.+)/;
$cur_name = $1;
$cur_score = $2;
$cve_name_score{$cur_name} = $cur_score;
}
my @cves = ("");
readDBcontent($ARGV[0],\@cves);
my $score = 0.0;
my $score1 = 0.0;
my $cve_count = 0;
my $year = 0;
my $score_modified = 0;
foreach (@cves) {
if ($_ ne "") {
if (defined($cve_name_score{$_})) {
$score += $cve_name_score{$_};
$cve_count++;
$_ =~ m/(\d\d\d\d)-\d\d\d\d/;
$year = $1;
$score_modified = $cve_name_score{$_} * ((8-(2006-$year))/8);
$score1 += $score_modified;
}
}
}
my $average = $score/$cve_count;
printf "%d\t%.1f\t%.1f\t%.1f", $cve_count,$score,$average,$score1;
sub readDBcontent {
my ($table,$dbcon)= @_;
my $count= 0;
open(TBL,"<$table")||die($table);
@{$dbcon}=
close(TBL);
for(my $i=0;$i<@{$dbcon};$i++) {
chomp(${$dbcon}[$i]);
if(${$dbcon}[$i] ne "") { $count++; }
}
return ($count);
}
--------------------------------- 8< --------------------------------------
资源链接:
通用弱点评价体系(CVSS)简介
http://www.xfocus.net/releases/200602/a850.html
NVD/CVE XML Data Files
CVSS Draft
RealSecure Network Sensor XPUs
Snort Rules
IDP Rule