> 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/reconnaissance/subdomains.md).

# 子域名

子域枚举通过发现公开主机、DNS 记录、虚拟主机、证书透明度条目和已索引基础设施来扩大目标攻击面。

{% hint style="info" %}
发现与网站相关的子域有多种技术。这些技术可以使用在线工具执行，也可以直接在控制台中执行，并且会根据目标和可用资源而有所不同。以下是你可以用于此任务的几个工具，以及详细示例命令。
{% endhint %}

## Gobuster：

> Gobuster 是一款非常流行的工具，可通过对网站执行 DNS 查询来快速发现子域。它使用词表测试不同的子域组合。以下是在命令行中使用它的示例：

```bash
gobuster vhost -u https://website.com --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100
```

* **-u**: 指定目标网站的 URL。
* **-w**: 设置用于测试子域的字典文件路径。
* **-t**: 设置线程数（此处为 100），以提高搜索速度。
* /| grep -v "403": 忽略 HTTP 403 响应。

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

## Wfuzz：

> Wfuzz 是另一款模糊测试工具，它允许你通过利用 HTTP 响应来测试不同的子域。要搜索子域，请使用以下命令：

```bash
wfuzz -c -t 100 -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt -H "Host: FUZZ.website.com" https://website.com
```

* **-c**: 启用彩色模式，以提高结果的可读性。
* **-t 20**: 设置并发线程数（这里为 20），以加快过程。
* **-H "Host: FUZZ.website.com"**: 用列表中的每个值替换 "FUZZ"，以测试可能的子域。
* **--hc=404**: 忽略 HTTP 404 响应。

<figure><img src="/files/2084049df0afa61dafd3cf988977e10e59d2cdb7" alt=""><figcaption></figcaption></figure>

## **Sublist3r**

> Sublist3r 是一个 Python 工具，旨在使用 OSINT 枚举网站子域。它使用 Google、Yahoo、Bing、百度和 Ask 等多个搜索引擎，以及 Netcraft、Virustotal、ThreatCrowd、DNSdumpster 和 ReverseDNS1 等其他来源。

* **Sublist3r**: 子域枚举工具，例如：/ `sublist3r -d website.com`

<figure><img src="/files/c48120bfdb24158a0ae03baafa503be3d5fbf654" alt="" width="518"><figcaption></figcaption></figure>

## Google Dorks：

> Google Dorks 是一种特殊查询，允许你使用 Google 查找特定信息。要发现网站的子域，可以使用以下查询：

```makefile
site:*.website.com
```

此命令将显示所有已索引的 **website.com** 子域，使用的是 Google 的索引。此技术尤其适合快速获取一份可公开访问的子域列表。

<figure><img src="/files/671a227dd0fb065f1d19670212c4a6f37e54505d" alt=""><figcaption></figcaption></figure>

## DNSDumpster：

> [DNSDumpster ](https://dnsdumpster.com/)是一款免费的在线工具，用于收集有关网站域名系统（DNS）的信息。它在渗透测试（pentesting）中尤其有用，可获取组织网络基础设施的信息。使用 DNSDumpster，你可以访问某个域名公开 DNS 记录的详细信息，并发现诸如以下关键基础设施组件：

* 服务器。
* 子域。
* 关联的 IP 地址。
* 其他网络服务。

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

## 被动域枚举

首先使用被动来源收集候选子域，而不直接接触目标基础设施。将 `target.com` 替换为授权域名。

```bash
export TARGET="target.com"
```

### 证书透明度

查询 `crt.sh` 并查看原始 JSON 输出：

```bash
curl -s "https://crt.sh/?q=${TARGET}&output=json" | jq .
```

从证书透明度结果中提取唯一主机名：

```bash
curl -s "https://crt.sh/?q=${TARGET}&output=json" \
  | jq -r '.[] | .name_value, .common_name' \
  | sed 's/\*\.//g' \
  | sort -u
```

### Sonar 项目

从公开的 Project Sonar 风格数据集中收集子域、相关 TLD 和反向 DNS 结果：

```bash
curl -s "https://sonar.omnisint.io/subdomains/${TARGET}" | jq -r '.[]' | sort -u
curl -s "https://sonar.omnisint.io/tlds/${TARGET}" | jq -r '.[]' | sort -u
curl -s "https://sonar.omnisint.io/all/${TARGET}" | jq -r '.[]' | sort -u
```

单个 IP 或 CIDR 范围的反向 DNS 查询：

```bash
curl -s "https://sonar.omnisint.io/reverse/192.0.2.10" | jq -r '.[]' | sort -u
curl -s "https://sonar.omnisint.io/reverse/192.0.2.0/24" | jq -r '.[]' | sort -u
```

### 多源收集

运行 `theHarvester` 针对多个已配置来源：

```bash
while read -r source; do
  theHarvester -d "${TARGET}" -b "$source" -f "${source}-${TARGET}"
done < sources.txt
```

### 将子域解析为 IP

将已确认的子域转换为唯一的 IP 列表：

```bash
while read -r subdomain; do
  host "$subdomain" | awk '/has address/ {print $4}'
done < subdomains.txt | sort -u > ip-addresses.txt
```

### 使用 Shodan 补充 IP 信息

使用 Shodan 查看每个已解析 IP 地址暴露的服务：

```bash
while read -r ip; do
  shodan host "$ip"
done < ip-addresses.txt
```

## 其他 OSINT 资源

Phonebook 和其他公开 OSINT 资源集中在 [人员与泄露研究](/zh/hacking-tools/osint/people-and-breach-research.md)。网站基础设施、Shodan 和存档 URL 资源集中在 [网站与基础设施](/zh/hacking-tools/osint/websites-and-infrastructure.md).


---

# 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/reconnaissance/subdomains.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.
