Skip to content

Instantly share code, notes, and snippets.

@rgranadino
Created August 23, 2012 04:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgranadino/3432496 to your computer and use it in GitHub Desktop.
Save rgranadino/3432496 to your computer and use it in GitHub Desktop.
D-Link gws file decoder
#/usb/bin/php
<?php
//author rgranadino aug 22 2012
//tested on a D-Link DIR-615 B2 v2.25 firmware.
//this is a php translation of:
// http://www.shulerent.com/2009/08/21/cracking-the-d-link-settings-file/
$file = $argv[1];
if (!is_readable($file)) {
echo "Cannot read file: $file\n";
exit(1);
}
$handle = fopen($file, 'r');
$size = filesize($file);
$out = array();
for ($i=0; $i <$size; $i++) {
$char = ord(fread($handle,1)) - ($i%256);
if ($char < 0) {
$char += 256;
}
$out[] = chr($char);
}
fclose($handle);
echo implode('', $out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment