#!/usr/bin/perl my $VERSION=0.1; my $sector_size = 2048; my $count = 1000; use strict; use autodie; my $file = shift; die "Not found: $file\n" unless (-f $file); if (-s $file < $count * $sector_size) { $count = int( (-s $file)/$sector_size ); warn "File too small. Checking $count sectors only ($file)\n"; } my $protected = 0; open my $fh, '<:raw', $file; for (my $s=0; $s<$count; $s++) { my $bytes_read = read($fh, my $sector, $sector_size); die "Got $bytes_read but expected $sector_size from $file\n" unless ($bytes_read == $sector_size); my @bytes = unpack("C*", $sector); if ( ($bytes[ ($bytes[13] & 7)+20 ] & 48) != 0 ) { $protected++; } } if ($protected) { print "CSS-protected (on $protected of $count sectors) : $file\n"; } else { print "NOT protected : $file\n"; }