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?