Skip to content

Instantly share code, notes, and snippets.

@replsv
Created December 14, 2015 12:50
Show Gist options
  • Save replsv/d0d3cd727e4ad18147ff to your computer and use it in GitHub Desktop.
Save replsv/d0d3cd727e4ad18147ff to your computer and use it in GitHub Desktop.
fix manually modified serialized string
<?php
$initialData = file_get_contents("./old.ser");
$data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $initialData);
$fp = fopen ("./new.ser", "w");
fwrite($fp, $data);
fclose($fp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment