zoukankan      html  css  js  c++  java
  • 实验吧--web--你真的会php吗

    ---恢复内容开始---

    实验吧的一道题php审计题。拉下来写一写。 

    http://ctf5.shiyanbar.com/web/PHP/index.php

    打开之后说have fun

    那就抓包来看看吧

      

    嗯...没啥收获,放在repeater里面看看

    是这样的,根据response反馈的信息,我们可以看见 hint(提示)

    那就打开它看看吧

     代码审计走一波。

    <?php
    
    $info = ""; 
    $req = [];
    $flag="xxxxxxxxxx";
    
    ini_set("display_error", false); 
    error_reporting(0); 
    
    
    if(!isset($_POST['number'])){ //注意这里post请求  1.不能为空
       header("hint:6c525af4059b4fe7d8c33a.txt");  //文件头添加hint提示。
    
       die("have a fun!!"); // 直接就die了
    }
    foreach([$_POST] as $global_var) { //遍历数组
        foreach($global_var as $key => $value) { 
            $value = trim($value); //trim() 函数移除字符串两侧的空白字符或其他预定义字符。
            is_string($value) && $req[$key] = addslashes($value); 
        } 
    } 
    //global $var是外部$var的同名引用或者指针。
    //函数
    function is_palindrome_number($number) { 
        $number = strval($number); //本函数可将数组及类之外的变量类型转换成字符串类型。
        $i = 0; 
        $j = strlen($number) - 1;//strlen() 函数返回字符串的长度 
        while($i < $j) { 
            if($number[$i] !== $number[$j]) { 
                return false; 
            } 
            $i++; 
            $j--; 
        } 
        return true; 
    } 
    
    //判断是否为数值型
    if(is_numeric($_REQUEST['number'])){
    
       $info="sorry, you cann't input a number!";
    
    }elseif($req['number']!=strval(intval($req['number']))){
    
         $info = "number must be equal to it's integer!! ";  
    
    }else{
    
         $value1 = intval($req["number"]);
         $value2 = intval(strrev($req["number"])); //strrev() 函数反转字符串。 
    
         if($value1!=$value2){
              $info="no, this is not a palindrome number!";
         }else{
              //判断回文数
              if(is_palindrome_number($req["number"])){
                  $info = "nice! {$value1} is a palindrome number!"; 
              }else{
                 $info=$flag;
              }
         }
    
    }
    
    echo $info;

    如果要拿flag,需要满足以下条件:
    1.不为空,且不能是一个数值型数字,包括小数。(由is_numeric函数判断)
    2.不能是一个回文数。(is_palindrome_number判断)
    3.该数的反转的整数值应该和它本身的整数值相等。即:
    4.post个number.

  • 相关阅读:
    url编码
    客户端安全-xss-1类型介绍
    阿里云扩容教程
    jquery获取和设置表单数据
    uMlet建模工具
    phpstorm的调试工具xdebug
    服务器如何处理http请求
    http基础实战
    协程
    Goroutine(协程)为何能处理大并发?
  • 原文地址:https://www.cnblogs.com/EEEE1/p/8074574.html
Copyright © 2011-2022 走看看