Created
May 19, 2010 01:23
-
-
Save jeremyf/405829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Thank you Gavin Brock (http://brock-family.org/gavin/perl) - June 2007 | |
#==============================================================================# | |
use strict; | |
use warnings; | |
use Foundation; | |
#==============================================================================# | |
sub kcpassword_xor { | |
my ($pass) = @_; | |
### The magic 11 bytes - these are just repeated | |
# 0x7D 0x89 0x52 0x23 0xD2 0xBC 0xDD 0xEA 0xA3 0xB9 0x1F | |
my @key = qw( 125 137 82 35 210 188 221 234 163 185 31 ); | |
my $key = pack "C*", @key; | |
my $key_len = length $key; | |
for (my $n=0; $n<length($pass); $n+=$key_len) { | |
substr($pass,$n,$key_len) ^= $key; | |
} | |
return $pass; | |
} | |
#==============================================================================# | |
open(my $fh, '<', '/Users/jeremyf/kcpassword') || die; | |
my $encoded = ''; | |
while (<$fh>) { | |
$encoded = $_; | |
} | |
print kcpassword_xor($encoded); | |
exit 0; | |
#==============================================================================# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment