SHARE
TWEET

Untitled

a guest Apr 20th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. error_reporting(0);
  3. //听说你很喜欢数学,不知道你是否爱它胜过爱flag
  4. if(!isset($_GET['c'])){
  5.     show_source(__FILE__);
  6. }else{
  7.     //例子 c=20-1
  8.     $content = $_GET['c'];
  9.     if (strlen($content) >= 80) {
  10.         die("太长了不会算");
  11.     }
  12.     $blacklist = [' ', '\t', '\r', '\n','\'', '"', '`', '\[', '\]'];
  13.     foreach ($blacklist as $blackitem) {
  14.         if (preg_match('/' . $blackitem . '/m', $content)) {
  15.             die("请不要输入奇奇怪怪的字符");
  16.         }
  17.     }
  18.     //常用数学函数http://www.w3school.com.cn/php/php_ref_math.asp
  19.     $whitelist = ['abs', 'acos', 'acosh', 'asin', 'asinh', 'atan2', 'atan', 'atanh', 'base_convert', 'bindec', 'ceil', 'cos', 'cosh', 'decbin', 'dechex', 'decoct', 'deg2rad', 'exp', 'expm1', 'floor', 'fmod', 'getrandmax', 'hexdec', 'hypot', 'is_finite', 'is_infinite', 'is_nan', 'lcg_value', 'log10', 'log1p', 'log', 'max', 'min', 'mt_getrandmax', 'mt_rand', 'mt_srand', 'octdec', 'pi', 'pow', 'rad2deg', 'rand', 'round', 'sin', 'sinh', 'sqrt', 'srand', 'tan', 'tanh'];
  20.     preg_match_all('/[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*/', $content, $used_funcs);
  21.     foreach ($used_funcs[0] as $func) {
  22.         if (!in_array($func, $whitelist)) {
  23.             die("请不要输入奇奇怪怪的函数");
  24.         }
  25.     }
  26.     //帮你算出答案
  27.     eval('echo '.$content.';');
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top