forked from openwall/john
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ios7tojohn.pl
executable file
·64 lines (59 loc) · 1.59 KB
/
ios7tojohn.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env perl
#
# This software is Copyright (c) 2014 magnum
# and it is hereby released to the general public under the following terms:
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.
use warnings;
use strict;
use MIME::Base64;
use File::Basename;
# Example input (from com.apple.restrictionspassword.plist):
# <key>RestrictionsPasswordKey</key>
# <data>
# J94ZcXHm1J/F9Vye8GwNh1HNclA=
# </data>
# <key>RestrictionsPasswordSalt</key>
# <data>
# /RHN4A==
# </data>
#
# Example output:
# $pbkdf2-hmac-sha1$1000.fd11cde0.27de197171e6d49fc5f55c9ef06c0d8751cd7250
die "Usage: $0 [file [file...]]\n" if ($#ARGV < 0);
my ($type, $key, $salt) = ();
while(<>) {
s/\r//g; # Drop Redmond Garbage[tm]
if (m#^\s*<key>(.*)Key</key>\s*$#) {
$type = $1;
next;
}
# Single line
if ($type && m#^\s*<data>([0-9a-zA-Z/.=]+)</data>\s*$#) {
my $data = $1;
if (!$key) {
$key = $data;
} elsif (!$salt) {
$salt = $data;
print "$type:\$pbkdf2-hmac-sha1\$1000.${salt}.${key}:::", basename($ARGV, ".plist"), "::${ARGV}\n";
$type = $key = $salt = undef;
next;
} else {
die "Error parsing file ${ARGV} line $.\n";
}
}
# Multi line (but all data on one line)
elsif ($type && m#^\s*<data>\s*$#) {
my $data = unpack("H*", decode_base64(<ARGV>));
if (!$key) {
$key = $data;
} elsif (!$salt) {
$salt = $data;
print "$type:\$pbkdf2-hmac-sha1\$1000.${salt}.${key}:::", basename($ARGV, ".plist"), "::${ARGV}\n";
$type = $key = $salt = undef;
next;
} else {
die "Error parsing file ${ARGV} line $.\n";
}
}
}