forked from musalbas/heartbleed-masstest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshow_changes.pl
executable file
·97 lines (75 loc) · 2.33 KB
/
show_changes.pl
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /usr/bin/env perl
use strict;
use warnings;
use autodie;
use Data::Dumper;
use feature qw(say);
use constant
FILES => qw( top10000.txt top10000-11-Apr-14-1500UTC.txt );
use constant
HEADINGS => qw( Website 04/08/2014 04/11/2014 );
use constant {
OUTPUT_FILE => qq(changes.md),
FORMAT => qq(| %-20.20s | %-20.20s | %-20.20s | \n),
TEST_LINE => qr/^Testing\s+(\S+)\.\.\.\s+(.*)/,
};
my %websites;
my $on_first_file = 1;
for my $file ( FILES ) {
open my $file_fh, "<", $file;
while ( my $line = <$file_fh> ) {
chomp $line;
next unless $line =~ /^Testing\s+(\S+)\.\.\.\s+(.*)/;
my $website = $1;
my $status = $2;
$websites{$website}->{$file} = $status;
}
$on_first_file = 0;
close $file_fh;
}
#
# Report
#
open my $output_fh, ">", OUTPUT_FILE;
printf {$output_fh} FORMAT, HEADINGS;
say {$output_fh} ( "|" . "-" x 22 ) x HEADINGS . "-|";
WEBSITE:
for my $website ( sort keys %websites ) {
my $original_status;
my @statuses;
FILE:
for my $file ( FILES ) {
if ( not $original_status ) { # Skip site if not in first file
next WEBSITE if not exists $websites{$website}->{$file};
$original_status = $websites{$website}->{$file};
}
if ( exists $websites{$website}->{$file} ) {
push @statuses, $websites{$website}->{$file};
}
else {
push @statuses, "N/A";
}
}
next WEBSITE if $statuses[0] eq $statuses[-1];
printf {$output_fh} FORMAT, $website, @statuses;
}
=pod
=head1 NAME
show_changes.pl
=head1 SYNOPSIS
$ show_changes.pl
=head1 DESCRIPTION
This program takes the various I<reports> produced by the scans and
puts them together into one report showing the changes taking place
since the first report.
Reports are hardcoded into the program. (I'm too lazy to setup
Getopts::Long) so there is nothing to enter. Basically, only the
websites were the first report and last report have differenecs show
up in this report.
You can setup the various files and report headings by modifying the
I<constants> at the top of the program.
=head1 AUTHOR
David Weintraub <[email protected]>
=head1 LICENSE
You are not allowed to use this for evil purposes such as taking over
and ruling the world. Beyond that, feel free to use this however you want.