PHP Vulnerability Detailed _php tutorial

Source: Internet
Author: User
A few important php.ini options

Register Globals

The default value of the Register_globals option for Php>=4.2.0,php.ini is preset to off, and when Register_globals is set to ON, the program can receive various environment variables from the server, including the variables submitted by the form. And because PHP does not have to initialize the value of the variable beforehand, which leads to a large security risk.

Example 1:

Check_admin () is used to check the current user permissions, and if the admin setting is $is_admin the variable is true, then the following determines whether this variable is true and then performs some management actions

ex1.php

  

if (Check_admin ())

{

$is _admin = true;

}

if ($is _admin)

{

Do_something ();

}

?>

This section of code does not initialize $is_admin to Flase, if Register_globals is on, then we submit http://www.sectop.com/ex1.php?is_admin=true directly, You can bypass the validation of Check_admin ()

Example 2:

ex2.php

  

if (Isset ($_session["username"))

{

Do_something ();

}

Else

{

echo "You are not logged in!";

}

?>

ex1.php

  

$dir = $_get["dir"];

if (Isset ($dir))

{

echo "

";

System ("Ls-al". $dir);

echo "

";

}

?>

  

Mixed eval (string code_str)//eval injection typically occurs when an attacker can control the input string

ex2.php

  

$var = "Var";

if (Isset ($_get["Arg"]))

{

$arg = $_get["arg"];

Eval ("$var = $arg;");

echo "$var =". $var;

}

?>

  

http://www.bkjia.com/PHPjc/486002.html www.bkjia.com true http://www.bkjia.com/PHPjc/486002.html techarticle several important php.ini options Register Globals Php=4.2.0,php.ini The default value of the Register_globals option is preset to OFF, when the Register_globals setting is on, Program can receive from server ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.