Skip to content

Instantly share code, notes, and snippets.

@jeremyf

jeremyf/kcpassword

Created May 19, 2010
Embed
What would you like to do?
#!/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
You can’t perform that action at this time.