# 内部服务访问

我们在域内可以访问的其他服务也不可忽视，因为企业的域环境同时也是个内部网络。我们在一般内部网络渗透中会遇到的应用以及对应的攻击手法，在企业的域环境中依旧适用。诸如 FTP，SSH，HTTP(S) 等普通内网中就很常见的网络服务不再赘述，我们来讲在 AD 中更应当注意的内部服务，例如 **SMB** 与 **MSSQL**。

### **SMB**

如果拿下的的用户可以访问其他主机的 **C$** 或 **ADMIN$**，意味着该用户拥有对该计算机的本地管理员权限。除了 C$ 和 ADMIN$，还要注意任何**可读/可写**的共享目录，例如某个服务器开放 **dev** 共享目录，它可能存储着应用程序的源代码。

我们依旧可以用 PowerView 枚举域内所有 SMB 目录。我们既可以查看所有的共享目录，也可以查看对自己来说可以访问的。先来查看 white-bird 域内所有的 SMB 目录：

```powershell
Find-DomainShare
```

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/hasp6oaBmWDcGcUZ-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/hasp6oaBmWDcGcUZ-image.png)

枚举当前用户可以访问的共享目录，我们发现当前用户可以访问 WEB02 的 C$ 和 ADMIN$，这是理所当然的，因为 serveradm 对 WEB02 具有本地管理员特权。

```powershell
Find-DomainShare -CheckShareAccess
```

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/erJLRsMXmOht9nhV-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/erJLRsMXmOht9nhV-image.png)

我们来分别查看一下 PROD 域的：

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/g8Yfz8Szt2RIo11Q-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/g8Yfz8Szt2RIo11Q-image.png)

其中，file01 的 **Tools** 共享目录是自定义的，看看这些共享目录中有哪些是可以直接访问的

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/sLeMi7Nkq1WhZWUF-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/sLeMi7Nkq1WhZWUF-image.png)

很棒，该目录对于 **serveradm** 这样的域外用户都是可以访问的，看起来存储了一些工具。更令人惊喜的是，该共享目录还可写，那么显然是多了一条利用的道路。至于如何利用，我们会在后续章节讲解。

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/cwE4X7MjlMQibA1y-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/cwE4X7MjlMQibA1y-image.png)

###   
**MSSQL 服务器**

对于 MSSQL，只要我们具有特定权限，就能在其他主机上执行命令。关于 SQL Server 的利用，我们会在下一章做具体阐述。

我们需要先扫描内网段主机的 **1433** 端口，这是 MSSQL 的常用端口：

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/uhoGH7mtiAB0IjeD-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/uhoGH7mtiAB0IjeD-image.png)

一共有 3 个 MSSQL 实例，分别在 **172.16.1.14**，**172.16.1.42**，以及 **172.16.1.52** 主机上。

接下来，我们可以用 PowerUpSql 脚本枚举域内的 SQL 服务器，当前域有 1 台 SQL 服务器，即 Web02。

```powershell
Get-SQLInstanceDomain
```

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/SR8K6zjQ7QAMZSZx-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/SR8K6zjQ7QAMZSZx-image.png)

测试对特定实例，即 Web02 上 SQL03 的访问，我们发现可以访问。

```powershell
Get-SQLConnectionTest -Instance [实例名]
```

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/bYX2E9a0lvFExE2h-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/bYX2E9a0lvFExE2h-image.png)

获取 SQL 数据库实例信息，我们当前并不是 **Sysadmin** 权限。此外，还可以看到一些有关操作系统、SQL 版本、SPN 相关的信息。

```powershell
Get-SQLServerInfo -Instance [实例名]
```

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/C9crKDeKn6G5CsIT-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/C9crKDeKn6G5CsIT-image.png)

获取 SQL 数据库实例的链接，我们发现 SQL03 实例与 SRV02 上的 SQL02 实例互相连接

```powershell
Get-SQLServerLinkCrawl -Instance [实例名] 
```

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-03/scaled-1680-/34I9Yk8LTGPTLdgp-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-03/34I9Yk8LTGPTLdgp-image.png)

###   


### **其他**

实际上，还有其他一些的内网服务可以与 AD 进行无缝交互，例如 **IIS 服务器**、**Exchange**、**Jenkins** 等。在教材未来的更新中，我们争取加入更多这样的案例。