#!/usr/bin/perl use strict; use GNUpod::Hash58; use constant START => '000A2700'; my $infile = shift or die "Usage: $0 iTunesDB\n"; open(ITB, "<", $infile) or die "Unable to read $infile : $!\n"; my $okhash = unpack("H*",get_string(0x58,20, *ITB)); close(ITB); print "=> Hash in iTunesDB is: $okhash\n"; warn "** This tool will MODIFY $infile while running, $infile should be in\n"; warn "** tmpfs (not on a flash device!)\n"; warn "** Hit ENTER to continue, CTRL+C aborts\n"; ; my $fwx = 0x15000000; # 0xFFFFFFFF # notdone: 0x380ba72 - 0x15000000 my $xx = 0; for(;;) { my $firewire_id = START.sprintf("%08x",$fwx); my $fwref = GNUpod::Hash58::_StringToArrayRef(pack("H16",$firewire_id)); my $ckey = GNUpod::Hash58::CreateKey($fwref); my $chash = unpack("H*",GNUpod::Hash58::CreateHash(Keyref=>$ckey, Filepath=>$infile)); if($xx++ == 500) { print "=> $firewire_id\n"; $xx = 0; } if($chash eq $okhash) { print "$firewire_id : $chash -> $okhash\n"; die "Hit!\n"; } $fwx++; } ########################################### # Reads a string sub get_string { my ($start, $anz, $fh) = @_; my($buffer) = undef; Carp::confess("No filehandle!") unless $fh; $start = int($start); $anz = int($anz); sysseek($fh, $start, 0); #start reading sysread($fh, $buffer, $anz); return $buffer; }