<?php $lang = array('en' => array('help' => 'Usage: %CMD% <hex numbers separated by space>. Convert hex into dec. See also dec2hex.')); $plugin = Dog::getPlugin(); if ('' === ($message = $plugin->msg())) { return $plugin->showHelp(); } $out = ''; $hex = preg_split('/ +/', strtolower($message)); foreach ($hex as $h) { if (!preg_match('/^[0-9a-f]+$/', $h)) { $out .= ' ??'; } else { $out .= ' ' . GWF_Numeric::baseConvert($h, 16, 10); } } Dog::reply(substr($out, 1));
<?php chdir('../../'); define('GWF_PAGE_TITLE', 'Fremes'); require_once 'challenge/html_head.php'; require_once GWF_CORE_PATH . 'module/WeChall/solutionbox.php'; if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) { $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 4, 'challenge/FREMES/index.php', false); } $chall->showHeader(); if (false !== ($answer = Common::getPostString('answer', false))) { if (false === ($key = GWF_Session::get('FREMEN_KEY', false))) { echo GWF_HTML::error('Fremes', $chall->lang('err_try')); } else { $solution = GWF_Numeric::baseConvert($key, 2, 16); $slen = strlen($solution); $wlen = 128 / 4; $nlen = $wlen - $slen; $solution = str_repeat('0', $nlen) . $solution; $answer = strtoupper($answer); $solution = strtoupper($solution); if ($answer === $solution || substr($answer, 2) === $solution) { $chall->onChallengeSolved(GWF_Session::getUserID()); } else { echo WC_HTML::error('err_wrong'); } } } echo GWF_Box::box($chall->lang('info', array(128, 'fremes.php')), $chall->lang('title')); echo formSolutionbox($chall); require_once 'challenge/html_foot.php';
<?php $lang = array('en' => array('help' => 'Usage: %CMD% <text>. Convert utf8 text into hexadecimal numbers.', 'err_mbl' => 'Missing function: mb_strlen!')); $plugin = Dog::getPlugin(); if ('' === ($message = $plugin->msg())) { return $plugin->showHelp(); } if (!function_exists('mb_strlen')) { return $plugin->rply('err_mbl'); } $out = ''; $len = mb_strlen($message, 'UTF8'); for ($i = 0; $i < $len; $i++) { $utf = mb_substr($message, $i, 1, 'UTF8'); $len2 = strlen($utf); $dec = '0'; for ($j = 0; $j < $len2; $j++) { $dec = bcmul($dec, '256'); $dec = bcadd($dec, ord($utf[$j])); } $out .= ' ' . GWF_Numeric::baseConvert($dec, 10, 16); } Dog::reply(substr($out, 1));
<?php $lang = array('en' => array('help' => 'Usage: %CMD% <decimal numbers separated by space>. Convert decimal numbers to utf8 text.')); $plugin = Dog::getPlugin(); if ('' === ($message = $plugin->msg())) { return $plugin->showHelp(); } $out = ''; $hex = preg_split('/ +/', strtolower($message)); foreach ($hex as $n) { if (!preg_match('/^[0-9a-f]+$/', $n)) { $out .= '?'; continue; } $c = ''; $n = GWF_Numeric::baseConvert($n, 16, 10); while ($n != 0) { $mod = bcmod($n, '256'); printf('%02X' . PHP_EOL, $mod); $c = chr($mod) . $c; $n = bcdiv($n, '256'); } $out .= $c; } Dog::reply($out);
private static function get_ip_range($ip) { $count = 3 - substr_count($ip, '.'); $ipmin = $ip . str_repeat('.0', $count); $ipmax = $ip . str_repeat('.255', $count); // echo "Crating range from shortcut. $ipmin-$ipmax<br/>"; return array(GWF_Numeric::baseConvert(GWF_IP6::getIP(GWF_IP6::HEX_128, $ipmin), 16, 10), GWF_Numeric::baseConvert(GWF_IP6::getIP(GWF_IP6::HEX_128, $ipmax), 16, 10)); }