Loopus

Pro Content

This lesson requires Loopus Pro access. Upgrade to unlock all courses, labs, and challenges.

Web Application HackingServer-Side Vulnerabilities

File Inclusion (LFI/RFI)

25 min
lab
+60 XP

Learning Objectives

  • Understand Local and Remote File Inclusion vulnerabilities
  • Learn to exploit LFI for information disclosure
  • Master RFI for remote code execution

File Inclusion Vulnerabilities (LFI/RFI)

File inclusion vulnerabilities occur when applications dynamically include files based on user input without proper validation. These powerful vulnerabilities can lead to information disclosure, source code exposure, and even remote code execution.

Understanding File Inclusion

Web applications often need to include files dynamically. PHP include and require functions load external files at runtime. When the filename comes from user input without sanitization, attackers gain control over which files get loaded.

Local File Inclusion (LFI)

LFI allows reading files from the server filesystem. The classic example exploits path traversal to escape the intended directory. Common targets for LFI exploitation include:

Linux Systems:

  • /etc/passwd - User enumeration

  • /etc/shadow - Password hashes (if readable)

  • /var/log/apache2/access.log - Log poisoning

  • /proc/self/environ - Environment variables


Windows Systems:
  • Windows hosts file

  • Windows configuration files

  • IIS log files


LFI to RCE Techniques

Log Poisoning


Inject PHP code into log files, then include them. The User-Agent header is written to access logs, which can be included via LFI.

PHP Wrappers


Use PHP stream wrappers for various attacks. The filter wrapper reads source code, while the input wrapper executes code from POST data.

Remote File Inclusion (RFI)

RFI is more dangerous as it allows including files from external servers. For RFI to work, PHP settings must allow remote includes.

Prevention

Applications should never use user input directly in file operations. Proper defenses include whitelisting allowed files, using parameterized includes, and disabling remote file inclusion.

Answer the Questions0 / 4 completed

📚 KnowledgeQuestion 1

What vulnerability reads local server files?

Format: ***(3 chars)
Exact match required
⌨️ Hands-OnQuestion 2

What file lists Linux users?

Format: ******(6 chars)
Exact match required
📚 KnowledgeQuestion 3

What vulnerability executes remote scripts?

Format: ***(3 chars)
Exact match required
⌨️ Hands-OnQuestion 4

What PHP feature enables protocol exploitation?

Format: ********(8 chars)
Exact match required
Answer all questions correctly to unlock the next lesson

Interactive Sandbox

Loading sandbox...

Submit Flag

Found the flag? Submit it below to complete this lesson.
Format: LOOPUS{...}

Previous
Answer all questions to continue