-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbiterrorstat.pl
More file actions
executable file
·58 lines (52 loc) · 1.12 KB
/
biterrorstat.pl
File metadata and controls
executable file
·58 lines (52 loc) · 1.12 KB
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
#!/usr/bin/perl -w
my $pagesize=18270;
my $fn=$ARGV[0];
open IN,"<$fn";
binmode IN;
my $sector="";
my $ende=0;
my $npage=0;
my $mode=0;
my %npatterns=();
while(!$ende)
{
my $ret=read IN,$sector,$pagesize;
last if(!defined($ret) || !$ret);
if(substr($sector,0,1) eq "\x77" || substr($sector,10,1) eq "\x77")
{
print "77 Pattern detected!\n";
$mode=7;
foreach(0 .. 1023)
{
$stat{substr($sector,$_,1) eq "\x77" ? 1 : 0}++;
}
$npatterns{'77'}++;
}
elsif($substr($sector,0,6) eq "|Block")
{
$mode=1;
$npatterns{'Phi'}++;
}
elsif(substr($sector,0,1) eq "\x00" || substr($sector,10,1) eq "\x00")
{
print "00 Pattern detected!\n";
$mode=7;
foreach(0 .. 1023)
{
$stat{substr($sector,$_,1) eq "\x77" ? 1 : 0}++;
}
$npatterns{'00'}++;
}
else
{
print "Unknown pattern!\n";
}
$npage++;
}
close IN;
my $quote=$stat{1}?($stat{1}+$stat{0})/$stat{1}:"perfect";
print "Statistic for $fn:\nGood: $stat{1}\nBad: $stat{0}\nResult: $quote (higher is better)\n";
foreach(sort keys %npatterns)
{
print "Number of $_ pattern sectors: $npatterns{$_}\n";
}