die "expected 4096 bytes, got ",length($card), " bytes\n"
unless length $card == 4096;
+my ( $ADV, $MA, $DA );
+
foreach my $i ( 0 .. 15 ) {
my $pos = 0x40 * $i;
;
# General purpose byte (GPB)
my $gdp = ord(substr($card,0x39,1));
- printf "ADV (MAD version code): %d\n", $gdp & 0b00000011;
- printf "MA (multiapplication): %s\n", $gdp & 0b01000000 ? 'yes' : 'monoaplication';
- printf "DA (MAD available): %s\n", $gdp & 0b10000000 ? 'yes' : 'no';
+ $ADV = $gdp & 0b00000011;
+ $MA = $gdp & 0b01000000;
+ $DA = $gdp & 0b10000000;
+ printf "ADV (MAD version code): %d\n", $ADV;
+ printf "MA (multiapplication): %s\n", $MA ? 'yes' : 'monoaplication';
+ printf "DA (MAD available): %s\n", $DA ? 'yes' : 'no';
printf "Info byte (publisher sector): %x\n", ord(substr($card,0x11,1));
- } else {
+ } elsif ( $DA ) {
my $mad_offset = 0x10 + ( $i * 2 );
my $v = unpack('v',(substr($card, $mad_offset, 2)));
my $cluster_id = unpack('HH', (( $v & 0xff00 ) >> 8) );
printf "Card number: %s\n", unpack('h*',substr($card,$pos + 0x04,6));
}
+ } else {
+ printf "# sector %-2d\n", $i;
}
my $c1 = ( ord(substr($card,$pos+0x37,1)) & 0xf0 ) >> 4;
;
$cond >>= $j;
- printf "%04x %s %03b %s\n", $offset, unpack('H*',$block)
+ my $hex = unpack('H*',$block);
+ $hex =~ s/(....)/$1 /g;
+
+ if ( $ENV{SWAP} && $j < 3 ) {
+ my $hex_sw = unpack('h*',$block);
+ $hex_sw =~ s/(....)/$1 /g;
+ $hex .= " | $hex_sw";
+ }
+
+ printf "%04x %s %03b %s\n", $offset, $hex
, $cond
, $j < 3 ? $access_condition_data->{$cond} : $access_condition_trailer->{$cond}
;