Skip to content

Instantly share code, notes, and snippets.

@HiddenKn
Last active Aug 29, 2015
Embed
What would you like to do?
Quick way to decrypt/encrypt escapists files in php
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
/* Data */
$key = 'mothking';
$filename = 'items.dat';
$file = file_get_contents($filename);
//var_dump($file);
/* Open module, and create IV */
$td = mcrypt_module_open('blowfish-compat', '', 'ecb', '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv_size = mcrypt_enc_get_iv_size($td);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
/* Initialize encryption handle */
if (mcrypt_generic_init($td, $key, $iv) != -1) {
/* Decrypt data */
$ct = mdecrypt_generic($td, $file);
mcrypt_generic_deinit($td);
/* Reinitialize buffers for encryption */
mcrypt_generic_init($td, $key, $iv);
$pt = mcrypt_generic($td, $ct);
/* Clean up */
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
}
if (strncmp($pt, $file, strlen($file)) == 0) {
file_put_contents($filename, $ct);
echo($ct);
} else {
echo "error while checking results, WRONG KEY or not encrypted\n";
}
?>
@rahlzel

This comment has been minimized.

Copy link

@rahlzel rahlzel commented Nov 17, 2014

Not completely sure how to run this. I put the decrypt.php and items.dat files in a folder in my WAMP installation and opened decrypt.php in a browser, but I just see a bunch of encrypted characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment