Skip to content

Instantly share code, notes, and snippets.

@andersevenrud
Last active September 11, 2015 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersevenrud/c14961df1c5a63b952e6 to your computer and use it in GitHub Desktop.
Save andersevenrud/c14961df1c5a63b952e6 to your computer and use it in GitHub Desktop.
win7 product key decoder
<?php
$str = <<<EOTXT
SUPER SECRET STUFF HERE
EOTXT;
$bin = Array();
$hex = Array();
$tmp = explode("\n", $str);
foreach ( $tmp as $s ) {
if ( $s = trim($s) ) {
$foo = explode(" ", $s);
for ( $i = 3; $i < 20; $i++ ) {
if ( $foo[$i] != "-" ) {
$hex[] = $foo[$i];
$bin[] = (int) hexdec($foo[$i]);
}
}
}
}
var_dump(implode("", $hex));
$keyOffset = 52;
$i = 28;
$chars = "BCDFGHJKMPQRTVWXY2346789";
$kout = "";
do {
$cur = 0;
$x = 14;
do {
$tmp = $x + $keyOffset;
$cur = $cur * 256;
$cur = $bin[$tmp] + $cur;
$bin[$tmp] = ($cur / 24) & 255;
$cur = $cur % 24;
$x--;
} while ( $x >= 0 );
$i--;
$tmp = substr($chars, $cur, 1);
$kout = "{$tmp}{$kout}";
if ( ((29 - $i) % 6 == 0) && ($i != -1) ) {
$i--;
$kout = "-{$kout}";
}
} while ( $i >= 0 );
var_dump($kout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment