Wednesday, June 20, 2007

Blind Apple's iTunes user information ebemdded in DRM free m4a-Files

"Good programs exit with a return code, not with a shell ..."
Recently it was discovered that if you bought m4a files from iTunes Plus, which are DRM free, that Apple embedded your name and email in it. It made quite some news also here in germany. You can easily look for yourself with a few commands, as decribed: strings Song.m4a | grep apID.
Eventhough it is not hard to find, nor hard to remove like for example watermarks, it allows tracking. If you do not know how to handle big Perl libraries or dont want to install software, like Atomic Parsley that might be able to remove them you can use my simple perl script.
It shall work for most m4a Files and replaces the contents of two Atoms which usally is your eMail adress and , which stored your full name.

The perl script is under CC Share-Alike 3.0.
And of course use a BackUp and I dont warrant for anything.

#!/usr/bin/perl

############################# About The Script #########################################
# Script Name: rminfo.pl
# Creator : Vernard Luxe
# Date : 20.06.2007
# Description: Blinds apID and name Atoms in Apple m4a file with non-intrusive values.
#
# COPYRIGHT NOTICE
# (C) Copyright 2007 All Rights Reserved.
#
# LICENSING
# Creative Commons Attribution-ShareAlike 3.0 Unported
# http://creativecommons.org/licenses/by-sa/3.0/
#
# This script may be used and modified free of charge by anyone so long as
# this copyright notice and the comments above remain intact. By using this
# code you agree to indemnify the creator (identified above) from any liability that
# might arise from it's use.
#
# In all cases copyright and header must remain intact.
#
#######################################################################################
$MAIL = "steve\@peach.com";
$NAME = "Steve Works";

if(@ARGV == 0 || @ARGV > 2) {
print "usage: rminfo song.m4a [target.m4a]\n";
exit 1;
}

print "Blinding values of apID and name from '".$ARGV[0]."'\n";

$FILE = $ARGV[0];
open(FILE, "<$FILE") || die "ERROR: Could not open file '$FILE' for reading.\n"; $data = ""; while(defined($line = )) { $data .= $line; }
close FILE;

$emailPattern = "(apID.{4}data[^a-zA-Z0-9\.\-\@\_]*)([a-zA-Z0-9\.\-\@\_]*)";

$data =~ /$emailPattern/;
$email_found = $email_repl = $2;
$email_repl =~ tr/[0-9a-zA-Z\.\@\_\-]/x/;
$email_repl = substr($MAIL, 0, length($email_repl)) . substr($email_repl, length($MAIL), length($email_repl));
$data =~ s/$emailPattern/$1$email_repl/;

$data =~ /name(.*?)\x00/g;
$name_found = $name_repl = $1;
$name_repl =~ tr/[0-9a-zA-Z ]/x/;
$name_repl = substr($NAME, 0, length($name_repl)) . substr($name_repl, length($NAME), length($name_repl));
$data =~ s/name.*?\x00/name$name_repl\x00/g;

if(@ARGV == 2) {
$FILE = $ARGV[1];
} else {
$FILE = "noinfo.".$FILE;
}

open(FILE, "> $FILE") || die "ERROR: Could not open file '$FILE' for output.\n";
print FILE $data;
close FILE;

print "Successfully blinded\n";
print "\tapID: $email_found => $email_repl\n";
print "\tname: $name_found => $name_repl\n";

exit 0;






Labels: