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 提供支持
在本页
  • 基本Docker引擎安全
  • 安全访问Docker引擎
  • 容器镜像的安全性
  • 镜像扫描
  • Docker镜像签名
  • 容器安全功能
  • 命名空间
  • cgroups
  • 权限提升
  • Docker中的Seccomp
  • Docker中的AppArmor
  • Docker中的SELinux
  • AuthZ & AuthN
  • 容器中的DoS
  • 有趣的Docker标志
  • --privileged标志
  • --security-opt
  • 其他安全考虑
  • 管理机密信息:最佳实践
  • gVisor
  • Kata Containers
  • 总结提示
  • Docker越狱/权限提升
  • Docker身份验证插件绕过
  • 加固Docker
  • 参考资料
  1. Linux Hardening
  2. Linux Privilege Escalation

Docker Security

上一页D-Bus Enumeration & Command Injection Privilege Escalation下一页Abusing Docker Socket for Privilege Escalation

最后更新于1年前

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

支持HackTricks的其他方式:

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

  • 获取

  • 探索,我们的独家

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

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

基本Docker引擎安全

Docker引擎利用Linux内核的命名空间和Cgroups来隔离容器,提供基本的安全层。通过Capabilities dropping、Seccomp和SELinux/AppArmor提供额外的保护,增强容器隔离性。认证插件可以进一步限制用户操作。

安全访问Docker引擎

Docker引擎可以通过Unix套接字本地访问,也可以通过HTTP远程访问。对于远程访问,必须使用HTTPS和TLS来确保机密性、完整性和身份验证。

默认情况下,Docker引擎在Unix套接字上侦听unix:///var/run/docker.sock。在Ubuntu系统上,Docker的启动选项定义在/etc/default/docker中。要启用对Docker API和客户端的远程访问,请添加以下设置以通过HTTP套接字公开Docker守护程序:

DOCKER_OPTS="-D -H unix:///var/run/docker.sock -H tcp://192.168.56.101:2376"
sudo service docker restart

然而,由于安全问题,不建议通过HTTP公开Docker守护程序。建议使用HTTPS来保护连接。保护连接的两种主要方法如下:

  1. 客户端验证服务器的身份。

  2. 客户端和服务器相互验证彼此的身份。

容器镜像的安全性

容器镜像可以存储在私有或公共存储库中。Docker为容器镜像提供了几种存储选项:

镜像扫描

容器可能存在安全漏洞,这可能是由于基础镜像或安装在基础镜像之上的软件导致的。Docker正在开发一个名为Nautilus的项目,用于对容器进行安全扫描并列出漏洞。Nautilus通过将每个容器镜像层与漏洞存储库进行比较来识别安全漏洞。

  • docker scan

**docker scan**命令允许您使用镜像名称或ID扫描现有的Docker镜像。例如,运行以下命令来扫描hello-world镜像:

docker scan hello-world

Testing hello-world...

Organization:      docker-desktop-test
Package manager:   linux
Project name:      docker-image|hello-world
Docker image:      hello-world
Licenses:          enabled

✓ Tested 0 dependencies for known issues, no vulnerable paths found.

Note that we do not currently have vulnerability data for your image.
trivy -q -f json <container_name>:<tag>
snyk container test <image> --json-file-output=<output file> --severity-threshold=high
clair-scanner -w example-alpine.yaml --ip YOUR_LOCAL_IP alpine:3.5

Docker镜像签名

Docker镜像签名确保容器中使用的镜像的安全性和完整性。以下是简要说明:

  • 要激活Docker内容信任,请设置export DOCKER_CONTENT_TRUST=1。此功能在Docker版本1.10及更高版本中默认关闭。

  • 在启用内容信任的情况下尝试拉取未签名的镜像会导致“最新版本无信任数据”错误。

  • 对于第一次之后的镜像推送,Docker会要求输入存储库密钥的密码以签署镜像。

要备份您的私钥,请使用以下命令:

tar -zcvf private_keys_backup.tar.gz ~/.docker/trust/private

在切换Docker主机时,需要移动根密钥和存储库密钥以保持运行。


容器安全功能

容器安全功能摘要

主要进程隔离功能

在容器化环境中,隔离项目及其进程对于安全性和资源管理至关重要。以下是关键概念的简化解释:

命名空间

  • 目的:确保资源(如进程、网络和文件系统)的隔离。特别是在Docker中,命名空间将容器的进程与主机和其他容器分开。

  • 使用unshare:使用unshare命令(或底层系统调用)来创建新的命名空间,提供了额外的隔离层。然而,尽管Kubernetes本身不会阻止这一点,但Docker会。

  • 限制:创建新的命名空间不允许进程恢复到主机的默认命名空间。要渗透主机命名空间,通常需要访问主机的/proc目录,并使用nsenter进行进入。

控制组(CGroups)

  • 功能:主要用于在进程之间分配资源。

  • 安全方面:CGroups本身并不提供隔离安全性,除了release_agent功能,如果配置不当,可能会被利用以获取未经授权的访问权限。

能力降权

  • 重要性:这是进程隔离的关键安全功能。

  • 功能:通过放弃某些能力,限制根进程可以执行的操作。即使进程以根权限运行,缺乏必要的能力也会阻止其执行特权操作,因为由于权限不足,系统调用将失败。

这是进程放弃其他能力后的剩余能力:

Current: cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap=ep

Seccomp

AppArmor

这将允许减少功能、系统调用、对文件和文件夹的访问...

命名空间

命名空间是Linux内核的一个功能,将内核资源分区,使得一组进程看到一组资源,而另一组进程看到不同的资源。该功能通过为一组资源和进程使用相同的命名空间,但这些命名空间指向不同的资源来实现。资源可以存在于多个空间中。

Docker利用以下Linux内核命名空间来实现容器隔离:

  • pid命名空间

  • mount命名空间

  • network命名空间

  • ipc命名空间

  • UTS命名空间

有关命名空间的更多信息,请查看以下页面:

cgroups

Linux内核功能cgroups提供了限制资源(如CPU、内存、IO、网络带宽等)的能力。Docker允许使用cgroup功能创建容器,从而实现对特定容器的资源控制。 以下是一个使用用户空间内存限制为500m、内核内存限制为50m、CPU份额为512、blkioweight为400创建的容器。CPU份额是控制容器CPU使用率的比率。它的默认值为1024,范围在0到1024之间。如果三个容器的CPU份额都是1024,则在CPU资源争用的情况下,每个容器最多可以占用33%的CPU。blkio-weight是控制容器IO的比率。它的默认值为500,范围在10到1000之间。

docker run -it -m 500M --kernel-memory 50M --cpu-shares 512 --blkio-weight 400 --name ubuntu1 ubuntu bash

要获取容器的 cgroup,您可以执行以下操作:

docker run -dt --rm denial sleep 1234 #Run a large sleep inside a Debian container
ps -ef | grep 1234 #Get info about the sleep process
ls -l /proc/<PID>/ns #Get the Group and the namespaces (some may be uniq to the hosts and some may be shred with it)

权限提升

权限提升允许对root用户可以允许的权限进行更精细的控制。Docker使用Linux内核的权限功能来限制容器内可以执行的操作,无论用户类型如何。

当运行Docker容器时,进程会放弃敏感权限,这些权限可以用来逃离隔离。这样可以确保进程无法执行敏感操作并逃脱:

Docker中的Seccomp

这是一个安全功能,允许Docker限制容器内可以使用的系统调用:

Docker中的AppArmor

AppArmor是一个内核增强功能,用于将容器限制在一组有限的资源和每个程序的配置文件中:

Docker中的SELinux

  • 标签系统:SELinux为每个进程和文件系统对象分配唯一标签。

  • 策略执行:它执行定义了进程标签在系统中可以对其他标签执行什么操作的安全策略。

  • 容器进程标签:当容器引擎启动容器进程时,它们通常被分配一个受限SELinux标签,通常是container_t。

  • 容器内的文件标签:容器内的文件通常被标记为container_file_t。

  • 策略规则:SELinux策略主要确保具有container_t标签的进程只能与标记为container_file_t的文件交互(读取、写入、执行)。

这种机制确保即使容器内的进程受到损害,也仅限于与具有相应标签的对象交互,从而显著限制了此类妥协可能造成的潜在损害。

AuthZ & AuthN

在Docker中,授权插件通过决定是否允许或阻止对Docker守护程序的请求发挥着关键作用。这一决定是通过检查两个关键上下文来做出的:

  • 认证上下文:包括有关用户的全面信息,例如他们是谁以及他们如何进行身份验证。

  • 命令上下文:包括与正在进行的请求相关的所有相关数据。

这些上下文有助于确保只有经过身份验证的用户的合法请求才会被处理,增强Docker操作的安全性。

容器中的DoS

如果您没有正确限制容器可以使用的资源,受损的容器可能会对其运行的主机进行DoS攻击。

  • CPU DoS

# stress-ng
sudo apt-get install -y stress-ng && stress-ng --vm 1 --vm-bytes 1G --verify -t 5m

# While loop
docker run -d --name malicious-container -c 512 busybox sh -c 'while true; do :; done'
  • 带宽 DoS

nc -lvp 4444 >/dev/null & while true; do cat /dev/urandom | nc <target IP> 4444; done

有趣的Docker标志

--privileged标志

在下面的页面中,您可以了解**--privileged标志意味着什么**:

--security-opt

no-new-privileges

如果您正在运行一个容器,攻击者设法以低权限用户的身份访问。如果您有一个配置错误的suid二进制文件,攻击者可能会滥用它并在容器内提升权限。这可能使他能够逃离容器。

使用启用了**no-new-privileges选项运行容器将防止这种特权升级**。

docker run -it --security-opt=no-new-privileges:true nonewpriv

其他

#You can manually add/drop capabilities with
--cap-add
--cap-drop

# You can manually disable seccomp in docker with
--security-opt seccomp=unconfined

# You can manually disable seccomp in docker with
--security-opt apparmor=unconfined

# You can manually disable selinux in docker with
--security-opt label:disable

其他安全考虑

管理机密信息:最佳实践

避免直接嵌入Docker镜像或使用环境变量存储机密信息至关重要,因为这些方法会使您的敏感信息暴露给通过诸如docker inspect或exec等命令访问容器的任何人。

Docker卷是一个更安全的替代方案,建议用于访问敏感信息。它们可以被用作内存中的临时文件系统,减轻了与docker inspect和日志记录相关的风险。但是,root用户和具有对容器的exec访问权限的用户仍然可以访问这些机密信息。

Docker机密提供了一种更安全的处理敏感信息的方法。对于在镜像构建阶段需要机密信息的情况,BuildKit提供了一个高效的解决方案,支持构建时机密信息,提高构建速度并提供额外功能。

要利用BuildKit,可以通过以下三种方式激活它:

  1. 通过环境变量:export DOCKER_BUILDKIT=1

  2. 通过命令前缀:DOCKER_BUILDKIT=1 docker build .

  3. 通过在Docker配置中默认启用它:{ "features": { "buildkit": true } },然后重新启动Docker。

BuildKit允许使用--secret选项使用构建时机密信息,确保这些机密信息不包含在镜像构建缓存或最终镜像中,使用类似以下命令:

docker build --secret my_key=my_value ,src=path/to/my_secret_file .

对于运行容器中需要的机密信息,Docker Compose 和 Kubernetes 提供了强大的解决方案。Docker Compose 利用服务定义中的 secrets 键来指定机密文件,示例在 docker-compose.yml 中展示:

version: "3.7"
services:
my_service:
image: centos:7
entrypoint: "cat /run/secrets/my_secret"
secrets:
- my_secret
secrets:
my_secret:
file: ./my_secret_file.txt

这个配置允许在使用Docker Compose启动服务时使用secrets。

gVisor

Kata Containers

Kata Containers是一个开源社区,致力于构建一个安全的容器运行时,使用轻量级虚拟机,感觉和表现类似于容器,但通过硬件虚拟化技术提供更强大的工作负载隔离作为第二层防御。

总结提示

  • 定期 重建您的镜像以应用安全补丁到主机和镜像。

  • 明智地管理您的secrets,使攻击者难以访问它们。

  • 如果暴露Docker守护程序,请使用HTTPS进行客户端和服务器身份验证。

  • 在Dockerfile中,优先使用COPY而不是ADD。ADD会自动解压缩文件并可以从URL复制文件。COPY不具备这些功能。尽量避免使用ADD,以免受到通过远程URL和Zip文件进行攻击的影响。

  • 为每个微服务使用单独的容器

  • 不要在容器内放置ssh,“docker exec”可用于ssh到容器。

  • 使用更小的容器镜像

Docker越狱/权限提升

如果您在Docker容器内或者拥有docker组中的用户访问权限,您可以尝试越狱和提升权限:

Docker身份验证插件绕过

如果您可以访问docker套接字或者拥有docker组中的用户访问权限,但您的操作受到docker身份验证插件的限制,请检查是否可以绕过它:

加固Docker

参考资料

使用可以轻松构建和自动化工作流程,使用世界上最先进的社区工具。 立即获取访问权限:

Docker安全

证书用于确认服务器的身份。有关这两种方法的详细示例,请参考。

:Docker提供的公共注册服务。

:允许用户托管自己的注册表的开源项目。

:Docker的商业注册服务,具有基于角色的用户身份验证和与LDAP目录服务集成的功能。

有关更多。

Docker内容信任利用Notary项目,基于The Update Framework (TUF),来管理镜像签名。有关更多信息,请参阅和。

启用此功能后,只能下载已签名的镜像。首次镜像推送需要为根密钥和标记密钥设置密码,Docker还支持Yubikey以提高安全性。更多详细信息可在找到。

使用轻松构建和自动化工作流,利用世界上最先进的社区工具。 立即获取访问权限:

默认情况下在Docker中启用。它有助于进一步限制进程可以调用的系统调用。 默认的Docker Seccomp配置文件可以在找到。

Docker有一个可以激活的模板:

要查看更多**--security-opt**选项,请访问:

在Kubernetes环境中,secrets得到原生支持,并可以通过诸如等工具进一步管理。Kubernetes的基于角色的访问控制(RBAC)增强了秘钥管理安全性,类似于Docker Enterprise。

gVisor是一个用Go编写的应用内核,实现了Linux系统表面的大部分功能。它包括一个名为runsc的运行时,提供了应用程序和主机内核之间的隔离边界。runsc运行时与Docker和Kubernetes集成,使得运行沙盒容器变得简单。

不要使用--privileged标志或在容器内挂载 。 Docker套接字允许生成容器,因此通过使用--privileged标志运行另一个容器是获取主机完全控制的简单方法。

不要在容器内以root身份运行。使用 和 **。**容器内的root与主机上的root相同,除非使用用户命名空间重新映射。它仅受到轻微限制,主要是由Linux命名空间、功能和cgroups限制。

(--cap-drop=all),仅启用所需功能 (--cap-add=...)。许多工作负载不需要任何功能,添加功能会增加潜在攻击的范围。

防止进程获取更多权限,例如通过suid二进制文件。

**。**资源限制可以保护机器免受拒绝服务攻击。

调整 , **(或SELinux)**配置文件,将容器可用的操作和系统调用限制为最低要求。

使用 并要求签名,或者基于它们构建自己的镜像。不要继承或使用镜像。还要将根密钥、密码存储在安全位置。Docker计划使用UCP管理密钥。

工具是一个脚本,检查在生产环境中部署Docker容器时的数十种常见最佳实践。所有测试都是自动化的,基于。 您需要从运行Docker的主机或具有足够权限的容器中运行该工具。了解如何在README中运行它:。

使用可以轻松构建和自动化工作流程,使用世界上最先进的社区工具。 立即获取访问权限:

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

支持HackTricks的其他方式:

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

获取

探索,我们的独家

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

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

🐧
Trickest
此指南
Docker Hub
Docker Registry
Docker Trusted Registry
信息,请阅读此处
trivy
snyk
clair-scanner
Notary
TUF
此处
Trickest
https://github.com/moby/moby/blob/master/profiles/seccomp/default.json
https://github.com/moby/moby/tree/master/profiles/apparmor
Namespaces
linux-capabilities.md
seccomp.md
apparmor.md
selinux.md
authz-and-authn-docker-access-authorization-plugin.md
Docker --privileged
https://docs.docker.com/engine/reference/run/#security-configuration
Helm-Secrets
Open Container Initiative (OCI)
Docker套接字
不同的用户
用户命名空间
放弃所有功能
使用“no-new-privileges”安全选项
限制容器可用的资源
seccomp
AppArmor
官方Docker镜像
后门
Docker Breakout / Privilege Escalation
AuthZ& AuthN - Docker Access Authorization Plugin
docker-bench-security
CIS Docker Benchmark v1.3.1
https://github.com/docker/docker-bench-security
https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/
https://twitter.com/_fel1x/status/1151487051986087936
https://ajxchapman.github.io/containers/2020/11/19/privileged-container-escape.html
https://sreeninet.wordpress.com/2016/03/06/docker-security-part-1overview/
https://sreeninet.wordpress.com/2016/03/06/docker-security-part-2docker-engine/
https://sreeninet.wordpress.com/2016/03/06/docker-security-part-3engine-access/
https://sreeninet.wordpress.com/2016/03/06/docker-security-part-4container-image/
https://en.wikipedia.org/wiki/Linux_namespaces
https://towardsdatascience.com/top-20-docker-security-tips-81c41dd06f57
https://www.redhat.com/sysadmin/privileged-flag-container-engines
https://docs.docker.com/engine/extend/plugins_authorization
https://towardsdatascience.com/top-20-docker-security-tips-81c41dd06f57
https://resources.experfy.com/bigdata-cloud/top-20-docker-security-tips/
Trickest
htARTE(HackTricks AWS红队专家)
订阅计划
官方PEASS & HackTricks周边产品
PEASS家族
NFTs
Discord群
电报群
@carlospolopm
HackTricks
HackTricks Cloud
htARTE(HackTricks AWS红队专家)
订阅计划
官方PEASS & HackTricks周边产品
PEASS家族
NFT收藏品
Discord群组
电报群组
@carlospolopm
HackTricks
HackTricks Cloud
Workflow-powered solution for Bug Bounty, Pentesting, SecOps | TrickestTrickest
Workflow-powered solution for Bug Bounty, Pentesting, SecOps | TrickestTrickest
Workflow-powered solution for Bug Bounty, Pentesting, SecOps | TrickestTrickest
Logo
Logo
Logo
Kata Containers - Open Source Container Runtime Softwarekatacontainers
Logo
GitHub - google/gvisor: Application Kernel for ContainersGitHub
Logo