X11 - Port 6000
Become VeryLazyTech member! π
Follow us on:
β Twitter @VeryLazyTech.
πΎ Github @VeryLazyTech.
π Medium @VeryLazyTech.
πΊ YouTube @VeryLazyTech.
π© Telegram @VeryLazyTech.
π΅οΈββοΈ My Site @VeryLazyTech.
Visit our shop for e-books and courses. π
Basic info
X11 (also known as X Window System or simply X) is a network-transparent window system that was designed in the 1980s at MIT. The key architectural principle is that X11 separates the display server from the applications:
X Server: Manages the display, keyboard, and mouse (runs on the machine with the physical screen)
X Client: The application that wants to display something (can run anywhere on the network)
This client-server architecture means that applications can run on one machine while displaying their GUI on another - a powerful feature that also introduces security risks.
How X11 Works
βββββββββββββββ Network βββββββββββββββ
β X Client β βββββββββββββββββββββββ>β X Server β
β (App/Shell) β X11 Protocol (Port 6000)β (Display) β
βββββββββββββββ <ββββββββββββββββββββββββββββββββββββββ
Remote LocalThe X server listens on port 6000 + display number:
Display
:0β Port 6000Display
:1β Port 6001Display
:2β Port 6002
X11 Authentication Mechanisms
X11 supports several authentication methods:
No Authentication (xhost +) - Anyone can connect (extremely insecure)
MIT-MAGIC-COOKIE-1 - 128-bit cookie stored in
~/.XauthorityXDM-AUTHORIZATION-1 - More secure, uses DES
SUN-DES-1 - Secure RPC using DES
MIT-KERBEROS-5 - Kerberos-based authentication
Most systems use MIT-MAGIC-COOKIE-1, which stores authentication cookies in the .Xauthority file.
The .Xauthority File
This file contains authentication cookies for X11 connections:
The cookie is a 128-bit random value that both client and server must know.
Default Port Information
Default Port: 6000 (plus display number offset)
Reconnaissance & Enumeration
Port Scanning
Basic Nmap Scan
X11 Access Testing Script
Metasploit Scanner
Manual Connection Testing
Using xdpyinfo
Using xwininfo
Shodan Queries
Find exposed X11 servers on the internet:
Local Enumeration
Finding X11 Sessions
Check Active X Sessions
Identify Display Numbers
Finding .Xauthority Files
Extracting and Using Cookies
SSH X11 Forwarding Detection
Exploitation Techniques
1. Verify Anonymous Connection
Before exploitation, verify you can connect:
2. Screenshot Capture
Using xwd (X Window Dump)
Automated Screenshot Capture
Using import (ImageMagick)
3. Keylogger (Keystroke Capture)
Using xspy
Alternative: Using xinput
Using xev for Event Monitoring
Custom Python Keylogger
4. Remote Desktop Viewing
Using xrdp.py
Using xwatchwin for Live Monitoring
Manual Live Viewing with VNC
5. Command Execution
Using Metasploit
Manual Command Execution via xterm
Using xdotool for Command Simulation
Opening GUI Applications Remotely
6. Getting a Reverse Shell
Method 1: Via xrdp.py
Method 2: Via xterm
Method 3: Via Keyboard Simulation (MSF)
Method 4: X11 Forwarding Hijack
If user has SSH with X11 forwarding:
7. Clipboard Access
8. Screen Recording
Post-Exploitation
Privilege Escalation
Check for SUID Binaries in X Session
Check X11 Configuration Files
Check for Sensitive Data in X Sessions
Persistence
Add Startup Application
Modify .xinitrc or .xsession
X11 Port Forward Persistence
Lateral Movement
Enumerate Other X11 Sessions
Find .Xauthority Files of Other Users
SSH X11 Forwarding Pivot
Advanced Techniques
X11 + Docker Escape
If X11 socket is mounted in container:
X11 in Kubernetes
Wayland Security Bypass
Modern systems use Wayland instead of X11, but many still have X11 compatibility:
CVE Analysis: X11 Vulnerabilities
CVE-2020-14360 - X.Org Server Input Validation
CVE-2022-46340 - X Server DeepCopy Issues
Tools Reference
Essential X11 Pentesting Tools
xdpyinfo - Display information utility
xwininfo - Window information utility
xwd - X Window dump (screenshots)
xspy - Keystroke logger
xwatchwin - Live desktop viewer
xrdp.py - Remote desktop access
xdotool - X11 automation
xclip - Clipboard access
xinput - Input device testing
xev - Event monitor
Installation
Custom Scripts
Multi-Function X11 Exploit Script
Defense & Hardening
Disable X11 Network Listening
Method 1: Configure X Server Startup
Method 2: Firewall Rules
Method 3: X Server Configuration
Proper X11 Authentication
SSH X11 Forwarding Security
Monitor X11 Access Attempts
Using auditd
Using tcpdump
Log Analysis
Migrate to Wayland
Wayland is more secure than X11:
Security Best Practices
Detection & Incident Response
Detecting X11 Attacks
Network-Based Detection
Host-Based Detection
Signs of Compromise
Unknown xterm or GUI applications appearing
Unusual network connections to port 6000
Unexpected .Xauthority file modifications
Keyboard input lag or duplication
Screenshot files in /tmp
Unauthorized SSH X11 forwarding sessions
Incident Response Steps
Real-World Attack Scenarios
Scenario 1: Red Team Assessment
Goal: Access internal workstation via exposed X11
Scenario 2: Privilege Escalation
Goal: Escalate from low-privileged user to root via X11
Scenario 3: Persistence via X11
Goal: Maintain access after initial compromise
Scenario 4: Lateral Movement
Goal: Use X11 to move from one compromised host to another
Troubleshooting Common Issues
"No protocol specified" Error
"Connection refused" Error
Permission Issues
Display Not Found
Cheat Sheet
Quick Reference
Common Ports
6000/tcp - X11 Display :0
6001/tcp - X11 Display :1
6002/tcp - X11 Display :2
6010/tcp - SSH X11 Forwarding (typically)
Important Files
~/.Xauthority - X11 authentication cookies
~/.xinitrc - X session initialization script
~/.xsession - Alternative session script
/tmp/.X11-unix/ - X11 socket directory
/etc/X11/Xwrapper.config - X wrapper configuration
/var/log/Xorg.0.log - X server log
Conclusion
X11, while providing powerful remote display capabilities, presents significant security risks when misconfigured. As a penetration tester, X11 access can provide:
Screenshot capture for sensitive information gathering
Keystroke logging for credential harvesting
Command execution for initial access
Reverse shells for persistent access
Lateral movement opportunities in enterprise networks
Key Takeaways:
Always scan for exposed X11 services (port 6000+)
Test for anonymous access before attempting auth bypass
Screenshot capture is often the quickest win
Keylogging can reveal passwords and sensitive data
X11 can provide direct shell access on the target's display
Proper defense requires disabling network listening (-nolisten tcp)
Migrate to Wayland for better security
Monitor for unauthorized X11 connections
Restrict .Xauthority file permissions
Use SSH X11 forwarding instead of direct access when possible
Remember that X11 exploitation should only be performed during authorized security assessments. Unauthorized access to systems is illegal and unethical.
Additional Resources
Learn & practice For the Bug Bounty
Last updated