Skip to content

Instantly share code, notes, and snippets.

@jeremyf
Created May 19, 2010 01:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyf/405829 to your computer and use it in GitHub Desktop.
Save jeremyf/405829 to your computer and use it in GitHub Desktop.
#!/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