Az - 文件共享
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
基本信息
Azure Files 是一个完全托管的云文件存储服务,提供通过标准 SMB (Server Message Block) 和 NFS (Network File System) 协议访问的共享文件存储。尽管主要使用的协议是 SMB,但 NFS Azure 文件共享不支持 Windows(根据 docs)。它允许您创建高度可用的网络文件共享,可以被多个虚拟机 (VM) 或本地系统同时访问,从而实现跨环境的无缝文件共享。
访问层级
- 事务优化:针对事务密集型操作进行了优化。
- 热存储:在事务和存储之间保持平衡。
- 冷存储:在存储上具有成本效益。
- 高级存储:针对低延迟和 IOPS 密集型工作负载进行了优化的高性能文件存储。
备份
- 每日备份:每天在指定时间(例如 UTC 19:30)创建一个备份点,并存储 1 到 200 天。
- 每周备份:每周在指定的日期和时间(星期日 19:30)创建一个备份点,并存储 1 到 200 周。
- 每月备份:每月在指定的日期和时间(例如第一个星期日 19:30)创建一个备份点,并存储 1 到 120 个月。
- 每年备份:每年在指定的日期和时间(例如一月第一个星期日 19:30)创建一个备份点,并存储 1 到 10 年。
- 也可以在任何时间执行 手动备份和快照。在此上下文中,备份和快照实际上是相同的。
通过 SMB 支持的身份验证
- 本地 AD DS 身份验证:使用与 Microsoft Entra ID 同步的本地 Active Directory 凭据进行基于身份的访问。需要与本地 AD DS 的网络连接。
- Microsoft Entra 域服务身份验证:利用 Microsoft Entra 域服务(基于云的 AD)使用 Microsoft Entra 凭据提供访问。
- 用于混合身份的 Microsoft Entra Kerberos:使 Microsoft Entra 用户能够通过互联网使用 Kerberos 进行 Azure 文件共享的身份验证。支持混合的 Microsoft Entra 加入或 Microsoft Entra 加入的 VM,而无需与本地域控制器的连接。但不支持仅云身份。
- Linux 客户端的 AD Kerberos 身份验证:允许 Linux 客户端通过本地 AD DS 或 Microsoft Entra 域服务使用 Kerberos 进行 SMB 身份验证。
枚举
# Get storage accounts
az storage account list #Get the account name from here
# List file shares
az storage share list --account-name <name>
az storage share-rm list --storage-account <name> # To see the deleted ones too --include-deleted
# Get dirs/files inside the share
az storage file list --account-name <name> --share-name <share-name>
## If type is "dir", you can continue enumerating files inside of it
az storage file list --account-name <name> --share-name <prev_dir/share-name>
# Download a complete share (with directories and files inside of them)
az storage file download-batch -d . --source <share-name> --account-name <name>
# List snapshots
az storage share snapshot --name <share-name>
# List file shares, including deleted ones
az rest --method GET \
--url "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}/fileServices/default/shares?%24skipToken=&%24maxpagesize=20&%24filter=&%24expand=deleted&api-version=2019-06-01"
# Get snapshots/backups
az storage share list --account-name <name> --include-snapshots --query "[?snapshot != null]"
# List contents of a snapshot/backup
az storage file list --account-name <name> --share-name <share-name> --snapshot <snapshot-version> #e.g. "2024-11-25T11:26:59.0000000Z"
# Download snapshot/backup
az storage file download-batch -d . --account-name <name> --source <share-name> --snapshot <snapshot-version>
Note
默认情况下,
azcli 将使用帐户密钥来签名密钥并执行操作。要使用 Entra ID 主体权限,请使用参数--auth-mode login --enable-file-backup-request-intent。
Tip
使用参数
--account-key指定要使用的帐户密钥
使用参数--sas-token通过 SAS 令牌访问
连接
这些是 Azure 在撰写时提出的连接文件共享的脚本:
您需要替换 <STORAGE-ACCOUNT>、<ACCESS-KEY> 和 <FILE-SHARE-NAME> 占位符。
$connectTestResult = Test-NetConnection -ComputerName filescontainersrdtfgvhb.file.core.windows.net -Port 445
if ($connectTestResult.TcpTestSucceeded) {
# Save the password so the drive will persist on reboot
cmd.exe /C "cmdkey /add:`"<STORAGE-ACCOUNT>.file.core.windows.net`" /user:`"localhost\<STORAGE-ACCOUNT>`" /pass:`"<ACCESS-KEY>`""
# Mount the drive
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\<STORAGE-ACCOUNT>.file.core.windows.net\<FILE-SHARE-NAME>" -Persist
} else {
Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
}
常规存储枚举(访问密钥,SAS…)
权限提升
与存储权限提升相同:
后期利用
Az - File Share Post Exploitation
持久性
与存储持久性相同:
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
HackTricks Cloud

