Skip to content

Instantly share code, notes, and snippets.

@gbirke
Created August 10, 2021 14:52
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 gbirke/bf8486ff7b50199242dd1d3680ce4c1a to your computer and use it in GitHub Desktop.
Save gbirke/bf8486ff7b50199242dd1d3680ce4c1a to your computer and use it in GitHub Desktop.
Decode PHP-serialized and base64 encoded data in CLI
#!/usr/bin/env php
<?php
if (!empty($argv[1])) {
$data = (string)$argv[1];
} elseif (!stream_isatty(STDIN)) {
$data = stream_get_contents(STDIN);
} else {
echo "Usage: $argv[0] <base64_encoded_serialized_data>\n";
exit(1);
}
var_dump(unserialize(base64_decode($data)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment