Skip to content

Instantly share code, notes, and snippets.

@tyage
Last active April 1, 2020 03:33
Show Gist options
  • Select an option

  • Save tyage/c19e6b766f573cd07e979a5a10997d14 to your computer and use it in GitHub Desktop.

Select an option

Save tyage/c19e6b766f573cd07e979a5a10997d14 to your computer and use it in GitHub Desktop.
<?php
$encrypted_block = 'PKklQOstCkI=';
$message = '';
$charset = '_-abcdefghijklmnopqrstuvwxyz0123456789';
$str_length = strlen($charset);
$method = 'DES-ECB';
function check($flag) {
global $message, $method, $encrypted_block;
$crypto = openssl_encrypt($message, $method, $flag);
if ($crypto == $encrypted_block) {
echo $flag;
exit;
}
}
function recurse($width, $position, $base_string) {
global $charset, $str_length;
for ($i = 0; $i < $str_length; ++$i) {
if ($position < $width - 1) {
recurse($width, $position + 1, $base_string . $charset[$i]);
}
check($base_string . $charset[$i]);
}
}
for ($i = 1; $i < 8 + 1; ++$i) {
echo "start $i";
recurse($i, 0, '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment