How do I use the $_server["php_self"] variable to implant script code?

Source: Internet
Author: User

If we are hackers, we can trick users into visiting the following links,

This is equivalent to the user entering the following address in the browser address bar:

HTTP://www.xxx.com/test_form.php/%22%3e%3cscript%3ealert (' hacked ')%3c/script%3e
The character behind the filename here is the URL encode characters, which is equivalent to
<formMethod="POST"action="test_form.php/"><script>alert( ' hacked ')</script>           

On this page we set up a form with the following settings:
<form method= "post" action= "<?< Span class= "PLN" >php Echo $_server[ "php_self" ;? >       

When a user submits a form (the form can also be empty so that it executes directly), The data is given to the file specified by the action, which is the current paging file, and executes the following JavaScript script code (performed automatically by browser)
<formMethod="POST"action="test_form.php/"><script>Alert (' hacked ')</script>

any JavaScript code behind the script can be added to the <script> tab! Hackers can use this redirect page to another Server page, the page code file can protect malicious code, the code can modify global variables or get the user's form data.

The actual hands are as follows: We numbered the form files that contain the above requirements in index.php, local access (the Apache server has been set up)
Http://localhost/phptest/index.php/%22%3E%3Cscript%3Ealert (' hacked ')%3c/script%3e

Effects in the Edge:

And then show:

Effects in Chrome

How do I use the $_server["php_self"] variable to implant script code?

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.