TacoRocket/AzureFox
GitHub: TacoRocket/AzureFox
AzureFox 是一款专注于 Azure 攻击性态势感知与管理平面侦察的 Python 命令行工具,旨在通过分析身份权限关系发现横向移动与提权路径。
Stars: 2 | Forks: 0
# AzureFox
将最强的 Azure 跳转故事置顶的分组路径视图。 | [`credential-path`](https://github.com/TacoRocket/AzureFox/wiki/Chains-Credential-Path)
将暴露的机密和 token 线索转化为最有可能扩大访问权限的下游目标。
[`deployment-path`](https://github.com/TacoRocket/AzureFox/wiki/Chains-Deployment-Path)
呈现最有可能让攻击者下一步更改 Azure 的构建、流水线和自动化路径。
[`escalation-path`](https://github.com/TacoRocket/AzureFox/wiki/Chains-Escalation-Path)
重点突出从当前据点到更强 Azure 控制权最清晰可见的路线。
[`compute-control`](https://github.com/TacoRocket/AzureFox/wiki/Chains-Compute-Control)
查找已经能够创建身份支持的访问并跳转到更广泛控制权的工作负载。 | ### 扁平命令 | 部分 | 命令 | | --- | --- | | `core` | [`inventory`](https://github.com/TacoRocket/AzureFox/wiki/Inventory) | | `identity` | [`whoami`](https://github.com/TacoRocket/AzureFox/wiki/Whoami), [`rbac`](https://github.com/TacoRocket/AzureFox/wiki/RBAC), [`principals`](https://github.com/TacoRocket/AzureFox/wiki/Principals), [`permissions`](https://github.com/TacoRocket/AzureFox/wiki/Permissions), [`privesc`](https://github.com/TacoRocket/AzureFox/wiki/Privesc), [`role-trusts`](https://github.com/TacoRocket/AzureFox/wiki/Role-Trusts), [`lighthouse`](https://github.com/TacoRocket/AzureFox/wiki/Lighthouse), [`auth-policies`](https://github.com/TacoRocket/AzureFox/wiki/Auth-Policies), [`managed-identities`](https://github.com/TacoRocket/AzureFox/wiki/Managed-Identities) | | `config` | [`arm-deployments`](https://github.com/TacoRocket/AzureFox/wiki/Arm-Deployments), [`env-vars`](https://github.com/TacoRocket/AzureFox/wiki/Env-Vars) | | `secrets` | [`keyvault`](https://github.com/TacoRocket/AzureFox/wiki/Keyvault), [`tokens-credentials`](https://github.com/TacoRocket/AzureFox/wiki/Tokens-Credentials) | | `resource` | [`automation`](https://github.com/TacoRocket/AzureFox/wiki/Automation), [`devops`](https://github.com/TacoRocket/AzureFox/wiki/Devops), [`acr`](https://github.com/TacoRocket/AzureFox/wiki/ACR), [`api-mgmt`](https://github.com/TacoRocket/AzureFox/wiki/API-Mgmt), [`databases`](https://github.com/TacoRocket/AzureFox/wiki/Databases), [`resource-trusts`](https://github.com/TacoRocket/AzureFox/wiki/Resource-Trusts) | | `storage` | [`storage`](https://github.com/TacoRocket/AzureFox/wiki/Storage) | | `network` | [`nics`](https://github.com/TacoRocket/AzureFox/wiki/Nics), [`dns`](https://github.com/TacoRocket/AzureFox/wiki/DNS), [`endpoints`](https://github.com/TacoRocket/AzureFox/wiki/Endpoints), [`network-effective`](https://github.com/TacoRocket/AzureFox/wiki/Network-Effective), [`network-ports`](https://github.com/TacoRocket/AzureFox/wiki/Network-Ports) | | `compute` | [`workloads`](https://github.com/TacoRocket/AzureFox/wiki/Workloads), [`app-services`](https://github.com/TacoRocket/AzureFox/wiki/App-Services), [`functions`](https://github.com/TacoRocket/AzureFox/wiki/Functions), [`container-apps`](https://github.com/TacoRocket/AzureFox/wiki/Container-Apps), [`container-instances`](https://github.com/TacoRocket/AzureFox/wiki/Container-Instances), [`aks`](https://github.com/TacoRocket/AzureFox/wiki/AKS), [`vms`](https://github.com/TacoRocket/AzureFox/wiki/VMs), [`vmss`](https://github.com/TacoRocket/AzureFox/wiki/VMSS), [`snapshots-disks`](https://github.com/TacoRocket/AzureFox/wiki/Snapshots-Disks) | ## 需要测试实验室? 手头没有 Azure 环境?配套仓库 [AzureFox OpenTofu Proof Lab](https://github.com/TacoRocket/terraform-labs-for-azurefox) 可以启动 一个故意设计得不安的 Azure 实验室,用于演示、验证和练习。 请使用您控制的可弃用订阅。它是有意设计为有风险的。 ## CLI 调用 `--tenant`、`--subscription`、`--output`、`--outdir` 和 `--debug` 等共享标志可以在命令之前 或之后使用。 这些形式是等效的: ``` azurefox dns --output json --outdir ./azurefox-demo azurefox --output json --outdir ./azurefox-demo dns ``` 使用 `azurefox --help` 或 `azurefox help ` 获取特定命令的帮助。
## 安装配置文件
AzureFox 默认安装实时 Azure 运行时依赖项,因此 `pip install azurefox` 准备好
执行真实的 Azure 命令。
如果您更喜欢隔离的虚拟环境:
```
python -m venv .venv
# macOS/Linux
source .venv/bin/activate
# Windows PowerShell
# .venv\Scripts\Activate.ps1
pip install azurefox
```
对于基于本地源代码的开发,请使用 `pip install -e '.[dev]'`。
AzureFox 旨在在 macOS、Linux 和 Windows 上运行。下面的命令示例使用
可移植的相对路径,如 `./azurefox-demo`;shell 语法主要区别在于 virtualenv
激活和环境变量导出。
实时的操作员指引内置于 `azurefox help` 和 `azurefox help ` 中。
- `pip install azurefox`
从 PyPI 安装正常的操作员配置文件,包括已实现的实时命令所使用的 Azure SDK 依赖项
- `pip install -e .`
从本地检出的代码安装相同的实时 Azure 命令配置文件
- `pip install -e '.[dev]'`
在默认的实时 Azure 依赖项之上安装贡献者工具;这是正常的
仓库开发配置文件
## 身份验证优先级
1. Azure CLI 凭据
2. 环境凭据
### 支持的身份验证矩阵
| 路径 | 启动方式 | 当前支持 | 元数据 `auth_mode` |
| --- | --- | --- | --- |
| 通过 Azure CLI 进行交互式用户登录 | `az login` | 支持 | `azure_cli_user` |
| 通过 Azure CLI 进行服务主体登录 | `az login --service-principal ...` | 通过 Azure CLI 支持 | `azure_cli_service_principal` |
| 通过 Azure CLI 进行托管身份登录 | `az login --identity` | 通过 Azure CLI 支持 | `azure_cli_managed_identity` |
| 通过环境客户端密钥进行服务主体登录 | `AZURE_TENANT_ID` + `AZURE_CLIENT_ID` + `AZURE_CLIENT_SECRET` | 支持 | `environment_client_secret` |
| 通过环境证书进行服务主体登录 | `AZURE_TENANT_ID` + `AZURE_CLIENT_ID` + `AZURE_CLIENT_CERTIFICATE_PATH` | 支持 | `environment_client_certificate` |
AzureFox 不会启动自己的浏览器或托管身份登录流程。它依赖 Azure Identity:
- `AzureCliCredential` 用于活动的 Azure CLI 登录状态
- `EnvironmentCredential` 用于服务主体环境变量
### 通过 Azure CLI 进行交互式用户登录
如果您希望进行基于 Web 的身份验证,请先运行 `az login`(在 AzureFox 之外),然后运行 AzureFox。
AzureFox 目前不会启动自己的浏览器身份验证流程。
Azure CLI 示例:
```
az login
az account set --subscription
azurefox inventory --subscription
```
### 通过 Azure CLI 进行服务主体登录
这对于仍然希望 Azure CLI 保存活动登录状态的无头自动化很有用。
使用客户端密钥:
```
az login --service-principal \
--username \
--password \
--tenant
az account set --subscription
azurefox whoami --subscription
```
使用证书:
```
az login --service-principal \
--username \
--certificate /path/to/certificate.pem \
--tenant
az account set --subscription
azurefox whoami --subscription
```
### 通过环境客户端密钥进行服务主体登录
如果您不想使用 Azure CLI 登录状态,请设置服务主体环境变量并
传递用于租户/订阅定位的 CLI 标志。
环境客户端密签示例:
```
# macOS/Linux
export AZURE_TENANT_ID=
export AZURE_CLIENT_ID=
export AZURE_CLIENT_SECRET=
export AZUREFOX_DEVOPS_ORG= # only needed for the devops command
azurefox whoami --tenant --subscription
```
```
# Windows PowerShell
$env:AZURE_TENANT_ID=""
$env:AZURE_CLIENT_ID=""
$env:AZURE_CLIENT_SECRET=""
$env:AZUREFOX_DEVOPS_ORG="" # only needed for the devops command
azurefox whoami --tenant --subscription
```
### 通过环境证书进行服务主体登录
```
# macOS/Linux
export AZURE_TENANT_ID=
export AZURE_CLIENT_ID=
export AZURE_CLIENT_CERTIFICATE_PATH=/path/to/certificate.pem
export AZURE_CLIENT_CERTIFICATE_PASSWORD=
azurefox whoami --tenant --subscription
```
```
# Windows PowerShell
$env:AZURE_TENANT_ID=""
$env:AZURE_CLIENT_ID=""
$env:AZURE_CLIENT_CERTIFICATE_PATH="C:\\path\\to\\certificate.pem"
$env:AZURE_CLIENT_CERTIFICATE_PASSWORD=""
azurefox whoami --tenant --subscription
```
### 通过 Azure CLI 使用 Azure 托管托管身份
当您在已附加托管身份的 Azure 资源上运行时,此方法有效。
```
az login --identity
az account set --subscription
azurefox whoami --subscription
```
对于用户分配的托管身份:
```
az login --identity --client-id
az account set --subscription
azurefox whoami --subscription
```
`AZUREFOX_DEVOPS_ORG` 仅在运行 `devops` 命令时需要。用于
`devops` 的身份仍然需要访问 Azure DevOps 组织,而不仅仅是对租户或
订阅的 ARM 访问权限。
## 输出模式
- `--output table`(默认)
- `--output json`
- `--output csv`
所有命令都在 `/` 下写入产物:
- `loot/.json`
- `json/.json`
- `table/.txt`
- `csv/.csv`
产物用途:
- `json/` 是完整的结构化命令记录。
- `loot/` 是较小的高价值交接内容,专注于排名靠前的目标,以便操作员快速
跟进和后续的链式工作流。
- `table/` 和 `csv/` 是从同一底层命令结果渲染的便捷视图。
## 部分与链
AzureFox 保留扁平的独立命令,并且还支持通过 `chains` 进行分组执行。
对于当前的狭窄工作:
- 当您已经知道想要的方向时,直接运行扁平命令
- 当您想要更高价值的分组答案,而不是每个源命令单独输出时,使用 `chains`
当前的部分映射:
- `identity`:`whoami`、`rbac`、`principals`、`permissions`、`privesc`、`role-trusts`、`lighthouse`、`auth-policies`、`managed-identities`
- `config`:`arm-deployments`、`env-vars`
- `secrets`:`keyvault`、`tokens-credentials`
- `resource`:`automation`、`devops`、`acr`、`api-mgmt`、`databases`、`resource-trusts`
- `storage`:`storage`
- `network`:`nics`、`dns`、`endpoints`、`network-effective`、`network-ports`
- `compute`:`workloads`、`app-services`、`functions`、`aks`、`vms`、`vmss`、`snapshots-disks`
- `core`:`inventory`
## 帮助
AzureFox 支持通用和范围限定帮助:
```
azurefox help
azurefox help identity
azurefox help permissions
azurefox dns --help
azurefox -h identity
azurefox -h permissions
```
命令帮助包括 ATT&CK 云线索作为调查提示,而非证明某种技术已发生。
帮助还将分组后续操作指向 `chains`(如果存在这些预设)。
对于临时演示或本地测试,请使用专用路径,如 `--outdir ./azurefox-demo`,以免
产物堆积在仓库根目录中。
## Fixture 模式
设置 `AZUREFOX_FIXTURE_DIR` 以针对本地 fixture 文件运行,而不是 Azure API。
```
# macOS/Linux
AZUREFOX_FIXTURE_DIR=tests/fixtures/lab_tenant azurefox rbac --output json
```
```
# Windows PowerShell
$env:AZUREFOX_FIXTURE_DIR="tests/fixtures/lab_tenant"
azurefox rbac --output json
```
## 开发
```
pip install -e '.[dev]'
ruff check .
pytest
```
CI 运行 lint 以及单元、契约和冒烟测试。集成测试是可选的。
## 致谢
AzureFox 的灵感来源于由 Bishop Fox 创建的 [CloudFox](https://github.com/BishopFox/cloudfox)。
## 许可证
AzureFox 在 MIT 许可证下发布。请参阅 [LICENSE](LICENSE)。
将最强的 Azure 跳转故事置顶的分组路径视图。 | [`credential-path`](https://github.com/TacoRocket/AzureFox/wiki/Chains-Credential-Path)
将暴露的机密和 token 线索转化为最有可能扩大访问权限的下游目标。
[`deployment-path`](https://github.com/TacoRocket/AzureFox/wiki/Chains-Deployment-Path)
呈现最有可能让攻击者下一步更改 Azure 的构建、流水线和自动化路径。
[`escalation-path`](https://github.com/TacoRocket/AzureFox/wiki/Chains-Escalation-Path)
重点突出从当前据点到更强 Azure 控制权最清晰可见的路线。
[`compute-control`](https://github.com/TacoRocket/AzureFox/wiki/Chains-Compute-Control)
查找已经能够创建身份支持的访问并跳转到更广泛控制权的工作负载。 | ### 扁平命令 | 部分 | 命令 | | --- | --- | | `core` | [`inventory`](https://github.com/TacoRocket/AzureFox/wiki/Inventory) | | `identity` | [`whoami`](https://github.com/TacoRocket/AzureFox/wiki/Whoami), [`rbac`](https://github.com/TacoRocket/AzureFox/wiki/RBAC), [`principals`](https://github.com/TacoRocket/AzureFox/wiki/Principals), [`permissions`](https://github.com/TacoRocket/AzureFox/wiki/Permissions), [`privesc`](https://github.com/TacoRocket/AzureFox/wiki/Privesc), [`role-trusts`](https://github.com/TacoRocket/AzureFox/wiki/Role-Trusts), [`lighthouse`](https://github.com/TacoRocket/AzureFox/wiki/Lighthouse), [`auth-policies`](https://github.com/TacoRocket/AzureFox/wiki/Auth-Policies), [`managed-identities`](https://github.com/TacoRocket/AzureFox/wiki/Managed-Identities) | | `config` | [`arm-deployments`](https://github.com/TacoRocket/AzureFox/wiki/Arm-Deployments), [`env-vars`](https://github.com/TacoRocket/AzureFox/wiki/Env-Vars) | | `secrets` | [`keyvault`](https://github.com/TacoRocket/AzureFox/wiki/Keyvault), [`tokens-credentials`](https://github.com/TacoRocket/AzureFox/wiki/Tokens-Credentials) | | `resource` | [`automation`](https://github.com/TacoRocket/AzureFox/wiki/Automation), [`devops`](https://github.com/TacoRocket/AzureFox/wiki/Devops), [`acr`](https://github.com/TacoRocket/AzureFox/wiki/ACR), [`api-mgmt`](https://github.com/TacoRocket/AzureFox/wiki/API-Mgmt), [`databases`](https://github.com/TacoRocket/AzureFox/wiki/Databases), [`resource-trusts`](https://github.com/TacoRocket/AzureFox/wiki/Resource-Trusts) | | `storage` | [`storage`](https://github.com/TacoRocket/AzureFox/wiki/Storage) | | `network` | [`nics`](https://github.com/TacoRocket/AzureFox/wiki/Nics), [`dns`](https://github.com/TacoRocket/AzureFox/wiki/DNS), [`endpoints`](https://github.com/TacoRocket/AzureFox/wiki/Endpoints), [`network-effective`](https://github.com/TacoRocket/AzureFox/wiki/Network-Effective), [`network-ports`](https://github.com/TacoRocket/AzureFox/wiki/Network-Ports) | | `compute` | [`workloads`](https://github.com/TacoRocket/AzureFox/wiki/Workloads), [`app-services`](https://github.com/TacoRocket/AzureFox/wiki/App-Services), [`functions`](https://github.com/TacoRocket/AzureFox/wiki/Functions), [`container-apps`](https://github.com/TacoRocket/AzureFox/wiki/Container-Apps), [`container-instances`](https://github.com/TacoRocket/AzureFox/wiki/Container-Instances), [`aks`](https://github.com/TacoRocket/AzureFox/wiki/AKS), [`vms`](https://github.com/TacoRocket/AzureFox/wiki/VMs), [`vmss`](https://github.com/TacoRocket/AzureFox/wiki/VMSS), [`snapshots-disks`](https://github.com/TacoRocket/AzureFox/wiki/Snapshots-Disks) | ## 需要测试实验室? 手头没有 Azure 环境?配套仓库 [AzureFox OpenTofu Proof Lab](https://github.com/TacoRocket/terraform-labs-for-azurefox) 可以启动 一个故意设计得不安的 Azure 实验室,用于演示、验证和练习。 请使用您控制的可弃用订阅。它是有意设计为有风险的。 ## CLI 调用 `--tenant`、`--subscription`、`--output`、`--outdir` 和 `--debug` 等共享标志可以在命令之前 或之后使用。 这些形式是等效的: ``` azurefox dns --output json --outdir ./azurefox-demo azurefox --output json --outdir ./azurefox-demo dns ``` 使用 `azurefox
标签:Azure, Azure AD, CLI, HTTP/HTTPS抓包, Modbus, Privilege Escalation, Python, RBAC, StruQ, TGT, WiFi技术, 凭证枚举, 协议分析, 反取证, 安全助手, 安全评估, 态势感知, 托管身份, 攻击路径发现, 攻防演练, 数据展示, 无后门, 服务主体, 权限分析, 权限提升, 横向移动, 红队, 编程规范, 网络安全, 跨租户, 逆向工具, 隐私保护