LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 March 13 2016

Stygmata
Banned

decode base64

hello guys
my mother set a restriction passcode on her ipad and forgot the passcode .
I Was trying to help her get the passcode by following the following : https://nbalkota.wordpress.com/2014/04/ … -pin-code/

i got the plist and it is like this ( i can send you the file if you want )

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "[url]http://www.apple.com/DTDs/PropertyList-1.0.dtd[/url]">
<plist version="1.0">
<dict>
	<key>RestrictionsPasswordKey</key>
	<data>
	U1SwM62yfdFBRabksPR7wJwbVmk=
	</data>
	<key>RestrictionsPasswordSalt</key>
	<data>
	XR0lYQ==
	</data>
</dict>
</plist>

according to the link i need to use base 64 to get the hash and salt .. then using perl i can get the passcode..
i know nothing about programming and dont own a mac ( no hackintosh or virtual pc as i am stuck in the middle of congo now )

thank you

Offline

#2 March 13 2016

rolf
Member

Re: decode base64

Stygmata wrote:

according to the link i need to use base 64 to get the hash and salt .. then using perl i can get the passcode..
i know nothing about programming and dont own a mac ( no hackintosh or virtual pc as i am stuck in the middle of congo now )

Well, the linked article mentions the existence of "commercial software" to help you recover the passcode. If you don't know nothing about programming, maybe you can buy one?

In any case I cannot help because I've never done this myself, and I am not willing to help on a subject that I have no experience with without being asked a specific question.

You can probably find a website that converts from/to base64, I've used one before, if that helps. Good luck.

Last edited by rolf (March 13 2016)

Offline

#3 March 13 2016

Stygmata
Banned

Re: decode base64

rolf wrote:
Stygmata wrote:

according to the link i need to use base 64 to get the hash and salt .. then using perl i can get the passcode..
i know nothing about programming and dont own a mac ( no hackintosh or virtual pc as i am stuck in the middle of congo now )

Well, the linked article mentions the existence of "commercial software" to help you recover the passcode. If you don't know nothing about programming, maybe you can buy one?

In any case I cannot help because I've never done this myself, and I am not willing to help on a subject that I have no experience with without being asked a specific question.

You can probably find a website that converts from/to base64, I've used one before, if that helps. Good luck.

Thank you rolf..the cheapest software costs 99$ and my credit card wasnt accepted.
There is barely any programming but it just need a mac which i dont have as well

If you read the article ( last paragraphs ) you would get it

Offline

#4 March 14 2016

rolf
Member

Re: decode base64

Wow, $99 is a lot for a software that does such a specific task. I was assuming it would be much less!
Anyway, I've taken a look at the last paragraphs.

Like I said, plenty of ways to decode/encode base64 online. This one decodes to hex:
http://tomeko.net/online_tools/base64.php?lang=en

U1SwM62yfdFBRabksPR7wJwbVmk=    >>>    5354B033ADB27DD14145A6E4B0F47BC09C1B5669
XR0lYQ==     >>>     5D1D2561

Regarding the perl script, it seems to decode these into something useful.
I am assuming that you are running Windows.
You can install perl on Windows, which is probably the easiest solution. It should be OK to run the same commands in the article but without "sudo" at the beginning. Also instead of "time ios7.pl hex_hash hex_salt" you'd probably have to do something like "perl ios7.pl hex_hash hex_salt". But let's get there first.

I (we) can help you but please try yourself first, and let us know exactly where and how you are stuck.

Last edited by rolf (March 14 2016)

Offline

#5 March 14 2016

Stygmata
Banned

Re: decode base64

rolf wrote:

Wow, $99 is a lot for a software that does such a specific task. I was assuming it would be much less!
Anyway, I've taken a look at the last paragraphs.

Like I said, plenty of ways to decode/encode base64 online. This one decodes to hex:
http://tomeko.net/online_tools/base64.php?lang=en

U1SwM62yfdFBRabksPR7wJwbVmk=    >>>    5354B033ADB27DD14145A6E4B0F47BC09C1B5669
XR0lYQ==     >>>     5D1D2561

Regarding the perl script, it seems to decode these into something useful.
I am assuming that you are running Windows.
You can install perl on Windows, which is probably the easiest solution. It should be OK to run the same commands in the article but without "sudo" at the beginning. Also instead of "time ios7.pl hex_hash hex_salt" you'd probably have to do something like "perl ios7.pl hex_hash hex_salt". But let's get there first.

I (we) can help you but please try yourself first, and let us know exactly where and how you are stuck.

Thank you rolf .
I managed to get an old mac and i installed perl needed in the last part of the article using this : sudo cpan install Crypt::PBKDF2

now i just open a terminal and type the remaining :
#!/usr/bin/env perl
use Crypt::PBKDF2;

?

thank you

Offline

#6 March 14 2016

rolf
Member

Re: decode base64

Stygmata wrote:

Thank you rolf .
I managed to get an old mac and i installed perl needed in the last part of the article using this : sudo cpan install Crypt::PBKDF2

now i just open a terminal and type the remaining :
#!/usr/bin/env perl
use Crypt::PBKDF2;

?

You're welcome.
No, that's part of the file. You should create an empty text file, call it ios7.pl, and paste the code inside. I don't know what the default text editor is on OSX. You need a plain text editor, like notepad on Windows. If you can't find the default text editor then you can maybe install Sublime Text on OSX. It's great and I use it all the time for coding.

#!/usr/bin/env perl
use Crypt::PBKDF2;

if (@ARGV < 2) {   
   print "[!] Error: please specify hash (first argument) and salt (second argument)\n";
   exit (1); 
} 
my $match = pack ("H*", $ARGV[0]); # TODO: check if it is of length 40 
my $salt  = pack ("H*", $ARGV[1]); # of length 8? 
my $iter  = 1000; 
my $pbkdf2 = Crypt::PBKDF2->new (hash_class => 'HMACSHA1', iterations => $iter);
my $num;
for ($num = 0; $num < 10000; $num++) {
   my $pass = sprintf ("%04d", $num);
   my $hash = $pbkdf2->PBKDF2 ($salt, $pass);
   if ($match eq $hash) {
      printf ("%s:%s:%s:%s\n", unpack ("H*", $hash), unpack ("H*", $salt), $iter, $pass);
      exit (0);
   }
}
exit (1);

Then open a terminal window, change directory ("cd") to wherever you saved that text file. For example if it's in /home/Stygmata/Desktop/ then type these two commands in terminal (press enter at the end of each line):

cd /home/Stygmata/Desktop/
time ios7.pl hex_hash hex_salt

Make sure you replace "hex_hash" and "hex_salt" by the hex values I gave you previously. I hope they are correct.
I've gone into some details just to make sure there is no misunderstanding, since you say that you know little about programming.
Let me know how it goes!

Last edited by rolf (March 14 2016)

Offline

#7 March 14 2016

Stygmata
Banned

Re: decode base64

the mac did not work i was not able to install the library correctly ( very old mac )
I installed strawberry perl on a windows pc and using : cpan install Crypt::PBKDF2 i now have the library installed
but when i try to use the commands i always receive errors about missing commands or commands that don't exist , etc
what is the windows opposing for :
#!/usr/bin/env perl
use Crypt::PBKDF2

if i take the code in black and paste it in a notepad , i do what exactly ?

thank you rolf :)

Offline

#8 March 14 2016

Stygmata
Banned

Re: decode base64

i copied the code on notepad and ios7.pl then went into the perl command , to the ios7.pl directory , ran the command with the hash and salt you provided and i got this :
5354b033adb27dd14145a6e4b0f47bc09c1b5669:5d1d2561:1000:0770

according to the site the 0770 should be the pass ..waiting to be able to reach my mom on the phone to check :)

Offline

#9 March 14 2016

rolf
Member

Re: decode base64

Hmm, I hope it works.
Yes "sudo" and "time" don'e exist in Windows (but we don't need them). On the other hand Windows cannot understand how to execute the script (as opposed to Linux) so we need to add the "perl" command.
It's good to see that you got it working finally. Hopefully the base64 to hex translation I gave you is correct.
Fingers crossed!

Offline

#10 March 15 2016

Stygmata
Banned

Re: decode base64

Worked flawlessly .
thank you Rolf

Offline

#11 March 15 2016

rolf
Member

Re: decode base64

Wow, impressive. Good work!
That's nice to hear, thanks.
You're welcome.

Last edited by rolf (March 15 2016)

Offline

#12 March 17 2016

NuclearVision
Member

Re: decode base64

Is apple aware of this flaw?

Offline

#13 March 17 2016

Stygmata
Banned

Re: decode base64

NuclearVision wrote:

Is apple aware of this flaw?

this is only for the restriction passcode .. you would need the initial lock passcode to be able to backup but yes i think you can consider it a security risk - apple should have a forget passcode link instead of resetting your phone !

Offline

#14 March 17 2016

rolf
Member

Re: decode base64

It doesn't sound like a very serious flaw to me, as long as the master passcode is secure.

Offline

#15 March 17 2016

NuclearVision
Member

Re: decode base64

rolf wrote:

It doesn't sound like a very serious flaw to me, as long as the master passcode is secure.

Some people rely on this code to prevent their teenagers children who have main code access from purchasing music apps or whatever.
Or even access to some apps.

Offline

Board footer