源代码管理攻击工具包 – SCMKit 是一个可用于攻击 SCM 系统的工具包。SCMKIT 允许用户指定要使用的 SCM 系统和攻击模块,以及提供对应 SCM 系统的有效凭证(用户名/密码或 API 密钥)。目前 SCMKit 支持的 SCM 系统包括 GitHub Enterprise、GitLab Enterprise 和 Bitbucket Server。支持的攻击模块包括侦察、权限提升和持久化。SCMKIT 采用模块化方式构建,以便信息安全社区将来可以添加新的模块和 SCM 系统。
本项目使用了以下第三方库。
按照以下步骤设置 Visual Studio,以便自行编译项目。这需要 .NET 库,可从 NuGet 包管理器安装。
https://api.nuget.org/v3/index.jsonInstall-Package Costura.Fody -Version 3.3.3Install-Package OctokitInstall-Package GitLabApiClientInstall-Package Newtonsoft.Json下表显示了每个模块在哪些系统中受支持
发现特定 SCM 系统中使用的仓库
提供 listrepo 模块,以及相关的认证信息和 URL。这将输出仓库名称和 URL。
这将列出用户能看见的所有仓库。
SCMKit.exe -s github -m listrepo -c userName:password -u https://github.something.local
SCMKit.exe -s github -m listrepo -c apiKey -u https://github.something.local
这将列出用户能看见的所有仓库。
SCMKit.exe -s gitlab -m listrepo -c userName:password -u https://gitlab.something.local
SCMKit.exe -s gitlab -m listrepo -c apiKey -u https://gitlab.something.local
这将列出用户能看见的所有仓库。
SCMKit.exe -s bitbucket -m listrepo -c userName:password -u https://bitbucket.something.local
SCMKit.exe -s bitbucket -m listrepo -c apiKey -u https://bitbucket.something.local
C:>SCMKit.exe -s gitlab -m listrepo -c username:password -u https://gitlab.hogwarts.local
================================================== Module: listrepo System: gitlab Auth Type: Username/Password Options: Target URL: https://gitlab.hogwarts.local
Name | Visibility | URL
MaraudersMap | Private | https://gitlab.hogwarts.local/hpotter/maraudersmap
testingStuff | Internal | https://gitlab.hogwarts.local/adumbledore/testingstuff
Spellbook | Internal | https://gitlab.hogwarts.local/hpotter/spellbook
findShortestPathToGryffindorSword | Internal | https://gitlab.hogwarts.local/hpotter/findShortestPathToGryffindorSword
charms | Public | https://gitlab.hogwarts.local/hgranger/charms
Secret-Spells | Internal | https://gitlab.hogwarts.local/adumbledore/secret-spells
Monitoring | Internal | https://gitlab.hogwarts.local/gitlab-instance-10590c85/Monitoring
### 搜索仓库
#### 使用场景
> *在特定的 SCM 系统中按仓库名称搜索仓库*
#### 语法
提供 `searchrepo` 模块以及 `-o` 命令行开关中的搜索条件,并附上相关的身份验证信息和 URL。这将输出匹配的仓库名称和 URL。
##### GitHub Enterprise
GitHub 仓库搜索是一种“包含”搜索,您输入的字符串将搜索名称包含搜索条件的仓库。
`SCMKit.exe -s github -m searchrepo -c userName:password -u https://github.something.local -o "some search term"`
`SCMKit.exe -s github -m searchrepo -c apikey -u https://github.something.local -o "some search term"`
##### GitLab Enterprise
GitLab 仓库搜索是一种“包含”搜索,您输入的字符串将搜索名称包含搜索条件的仓库。
`SCMKit.exe -s gitlab -m searchrepo -c userName:password -u https://gitlab.something.local -o "some search term"`
`SCMKit.exe -s gitlab -m searchrepo -c apikey -u https://gitlab.something.local -o "some search term"`
##### Bitbucket Server
Bitbucket 仓库搜索是一种“开头匹配”搜索,您输入的字符串将搜索名称以搜索条件开头的仓库。
`SCMKit.exe -s bitbucket -m searchrepo -c userName:password -u https://bitbucket.something.local -o "some search term"`
`SCMKit.exe -s bitbucket -m searchrepo -c apikey -u https://bitbucket.something.local -o "some search term"`
#### 示例输出```
C:\>SCMKit.exe -s gitlab -m searchrepo -c apiKey -u https://gitlab.hogwarts.local -o "spell"
==================================================
Module: searchrepo
System: gitlab
Auth Type: API Key
Options: spell
Target URL: https://gitlab.hogwarts.local
Timestamp: 1/14/2022 8:32:30 PM
==================================================
Name | Visibility | URL
----------------------------------------------------------------------------------------------------------
Spellbook | Internal | https://gitlab.hogwarts.local/hpotter/spellbook
Secret-Spells | Internal | https://gitlab.hogwarts.local/adumbledore/secret-spells
在特定的SCM系统中搜索包含给定关键词的代码
在-o命令行开关中提供searchcode模块和搜索条件,以及相关的认证信息和URL。这将输出匹配代码文件的URL以及代码中匹配的行。
GitHub代码搜索是一种"包含"搜索,您输入的字符串将搜索包含搜索词的所有行中的代码。
SCMKit.exe -s github -m searchcode -c userName:password -u https://github.something.local -o "some search term"
SCMKit.exe -s github -m searchcode -c apikey -u https://github.something.local -o "some search term"
GitLab代码搜索是一种"包含"搜索,您输入的字符串将搜索包含搜索词的所有行中的代码。
SCMKit.exe -s gitlab -m searchcode -c userName:password -u https://gitlab.something.local -o "some search term"
SCMKit.exe -s gitlab -m searchcode -c apikey -u https://gitlab.something.local -o "some search term"
Bitbucket代码搜索是一种"包含"搜索,您输入的字符串将搜索包含搜索词的所有行中的代码。
SCMKit.exe -s bitbucket -m searchcode -c userName:password -u https://bitbucket.something.local -o "some search term"
SCMKit.exe -s bitbucket -m searchcode -c apikey -u https://bitbucket.something.local -o "some search term"
C:>SCMKit.exe -s gitlab -m searchcode -c username:password -u https://gitlab.hogwarts.local -o "api_key"
================================================== Module: searchcode System: gitlab Auth Type: Username/Password Options: api_key Target URL: https://gitlab.hogwarts.local
[>] URL: https://gitlab.hogwarts.local/adumbledore/secret-spells/stuff.txt |_ API_KEY=abc123
Total number of items matching code search: 1
### 搜索文件
#### 使用场景
> *在特定 SCM 系统的仓库中,根据文件名中包含的关键字搜索文件*
#### 语法
在 `-o` 命令行开关中提供 `searchfile` 模块和搜索条件,以及相关的认证信息和 URL。这将输出匹配文件在其各自仓库中的 URL。
##### GitHub Enterprise
GitLab 文件搜索是“包含”搜索,您输入的字符串将搜索文件名中包含该搜索词的文件。
`SCMKit.exe -s github -m searchfile -c userName:password -u https://github.something.local -o "some search term"`
`SCMKit.exe -s github -m searchfile -c apikey -u https://github.something.local -o "some search term"`
##### GitLab Enterprise
GitLab 文件搜索是“包含”搜索,您输入的字符串将搜索文件名中包含该搜索词的文件。
`SCMKit.exe -s gitlab -m searchfile -c userName:password -u https://gitlab.something.local -o "some search term"`
`SCMKit.exe -s gitlab -m searchfile -c apikey -u https://gitlab.something.local -o "some search term"`
##### Bitbucket Server
Bitbucket 文件搜索是“包含”搜索,您输入的字符串将搜索文件名中包含该搜索词的文件。
`SCMKit.exe -s bitbucket -m searchfile -c userName:password -u https://bitbucket.something.local -o "some search term"`
`SCMKit.exe -s bitbucket -m searchfile -c apikey -u https://bitbucket.something.local -o "some search term"`
#### 示例输出```
C:\source\SCMKit\SCMKit\bin\Release>SCMKit.exe -s bitbucket -m searchfile -c apikey -u http://bitbucket.hogwarts.local:7990 -o jenkinsfile
==================================================
Module: searchfile
System: bitbucket
Auth Type: API Key
Options: jenkinsfile
Target URL: http://bitbucket.hogwarts.local:7990
Timestamp: 1/14/2022 10:17:59 PM
==================================================
[>] REPO: http://bitbucket.hogwarts.local:7990/scm/~HPOTTER/hpotter
[>] FILE: Jenkinsfile
[>] REPO: http://bitbucket.hogwarts.local:7990/scm/STUD/cred-decryption
[>] FILE: subDir/Jenkinsfile
Total matching results: 2
列出当前用户在GitLab中拥有的代码片段
提供listsnippet模块,以及任何相关的认证信息和URL。
SCMKit.exe -s gitlab -m listsnippet -c userName:password -u https://gitlab.something.local
SCMKit.exe -s gitlab -m listsnippet -c apikey -u https://gitlab.something.local
C:>SCMKit.exe -s gitlab -m listsnippet -c username:password -u https://gitlab.hogwarts.local
================================================== Module: listsnippet System: gitlab Auth Type: Username/Password Options: Target URL: https://gitlab.hogwarts.local
Title | Raw URL
spell-script | https://gitlab.hogwarts.local/-/snippets/2/raw
### 列出运行器
#### 使用场景
> *列出当前用户在 GitLab 中可用的所有 GitLab 运行器*
#### 语法
提供 `listrunner` 模块,以及任何相关的身份验证信息和 URL。如果用户是管理员,则可以列出 GitLab 企业实例中的所有运行器,包括共享运行器和组运行器。
##### GitLab 企业版
`SCMKit.exe -s gitlab -m listrunner -c userName:password -u https://gitlab.something.local`
`SCMKit.exe -s gitlab -m listrunner -c apikey -u https://gitlab.something.local`
#### 示例输出```
C:\>SCMKit.exe -s gitlab -m listrunner -c username:password -u https://gitlab.hogwarts.local
==================================================
Module: listrunner
System: gitlab
Auth Type: Username/Password
Options:
Target URL: https://gitlab.hogwarts.local
Timestamp: 1/25/2022 11:40:08 AM
==================================================
ID | Name | Repo Assigned
---------------------------------------------------------------------------------
2 | gitlab-runner | https://gitlab.hogwarts.local/hpotter/spellbook.git
3 | gitlab-runner | https://gitlab.hogwarts.local/hpotter/maraudersmap.git
列出当前用户在 GitHub 上拥有的 Gist
提供 listgist 模块,以及相关的身份验证信息和 URL。
SCMKit.exe -s github -m listgist -c userName:password -u https://github.something.local
SCMKit.exe -s github -m listgist -c apikey -u https://github.something.local
C:>SCMKit.exe -s github -m listgist -c username:password -u https://github-enterprise.hogwarts.local
================================================== Module: listgist System: github Auth Type: Username/Password Options: Target URL: https://github-enterprise.hogwarts.local
Description | Visibility | URL
Shell Script to Decode Spell | public | https://github-enterprise.hogwarts.local/gist/c11c6bb3f47fe67183d5bc9f048412a1
### 列出组织
#### 用例
> 列出当前用户在 GitHub 中所属的所有组织
#### 语法
提供 `listorg` 模块,以及相关的认证信息和 URL。
##### GitHub Enterprise
`SCMKit.exe -s github -m listorg -c userName:password -u https://github.something.local`
`SCMKit.exe -s github -m listorg -c apiKey -u https://github.something.local`
#### 示例输出```
C:\>SCMKit.exe -s github -m listorg -c username:password -u https://github-enterprise.hogwarts.local
==================================================
Module: listorg
System: github
Auth Type: Username/Password
Options:
Target URL: https://github-enterprise.hogwarts.local
Timestamp: 1/14/2022 9:44:48 PM
==================================================
Name | URL
-----------------------------------------------------------------------------------
Hogwarts | https://github-enterprise.hogwarts.local/api/v3/orgs/Hogwarts/repos
获取在特定 SCM 系统中使用的访问令牌所分配的权限
提供 privs 模块,以及 API 密钥和 URL。
SCMKit.exe -s github -m privs -c apiKey -u https://github.something.local
SCMKit.exe -s gitlab -m privs -c apiKey -u https://gitlab.something.local
C:>SCMKit.exe -s gitlab -m privs -c apikey -u https://gitlab.hogwarts.local
================================================== Module: privs System: gitlab Auth Type: API Key Options: Target URL: https://gitlab.hogwarts.local
Token Name | Active? | Privilege | Description
hgranger-api-token | True | api | Read-write for the complete API, including all groups and projects, the Container Registry, and the Package Registry. hgranger-api-token | True | read_user | Read-only for endpoints under /users. Essentially, access to any of the GET requests in the Users API. hgranger-api-token | True | read_api | Read-only for the complete API, including all groups and projects, the Container Registry, and the Package Registry. hgranger-api-token | True | read_repository | Read-only (pull) for the repository through git clone. hgranger-api-token | True | write_repository | Read-write (pull, push) for the repository through git clone. Required for accessing Git repositories over HTTP when 2FA is enabled.
### 添加管理员
#### 使用场景
> *将普通用户提升为特定SCM系统中的管理角色*
#### 语法
提供 `addadmin` 模块,以及相关的认证信息和URL。此外,提供您希望添加管理角色的目标用户。
##### GitHub Enterprise
`SCMKit.exe -s github -m addadmin -c userName:password -u https://github.something.local -o targetUserName`
`SCMKit.exe -s github -m addadmin -c apikey -u https://github.something.local -o targetUserName`
##### GitLab Enterprise
`SCMKit.exe -s gitlab -m addadmin -c userName:password -u https://gitlab.something.local -o targetUserName`
`SCMKit.exe -s gitlab -m addadmin -c apikey -u https://gitlab.something.local -o targetUserName`
##### Bitbucket Server
仅支持用户名/密码认证来执行与 Bitbucket 仓库或项目无关的操作。
`SCMKit.exe -s bitbucket -m addadmin -c userName:password -u https://bitbucket.something.local -o targetUserName`
#### 示例输出```
C:\>SCMKit.exe -s gitlab -m addadmin -c apikey -u https://gitlab.hogwarts.local -o hgranger
==================================================
Module: addadmin
System: gitlab
Auth Type: API Key
Options: hgranger
Target URL: https://gitlab.hogwarts.local
Timestamp: 1/14/2022 9:19:32 PM
==================================================
[+] SUCCESS: The hgranger user was successfully added to the admin role.
将某个管理员用户降级为特定 SCM 系统中的普通用户角色
提供 removeadmin 模块,以及相关的身份验证信息和 URL。此外,提供你想要移除管理员角色的目标用户。
SCMKit.exe -s github -m removeadmin -c userName:password -u https://github.something.local -o targetUserName
SCMKit.exe -s github -m removeadmin -c apikey -u https://github.something.local -o targetUserName
SCMKit.exe -s gitlab -m removeadmin -c userName:password -u https://gitlab.something.local -o targetUserName
SCMKit.exe -s gitlab -m removeadmin -c apikey -u https://gitlab.something.local -o targetUserName
在 Bitbucket 中,执行与仓库或项目无关的操作仅支持用户名/密码认证。
SCMKit.exe -s bitbucket -m removeadmin -c userName:password -u https://bitbucket.something.local -o targetUserName
C:>SCMKit.exe -s gitlab -m removeadmin -c username:password -u https://gitlab.hogwarts.local -o hgranger
================================================== Module: removeadmin System: gitlab Auth Type: Username/Password Options: hgranger Target URL: https://gitlab.hogwarts.local
[+] SUCCESS: The hgranger user was successfully removed from the admin role.
### 创建访问令牌
#### 用例
> *创建一个用于特定SCM系统的访问令牌*
#### 语法
提供 `createpat` 模块,以及任何相关的身份验证信息和URL。此外,提供您要为其创建访问令牌的目标用户。
##### GitLab Enterprise
此操作只能由管理员执行。您需要提供要为其创建PAT的用户名。
`SCMKit.exe -s gitlab -m createpat -c userName:password -u https://gitlab.something.local -o targetUserName`
`SCMKit.exe -s gitlab -m createpat -c apikey -u https://gitlab.something.local -o targetUserName`
##### Bitbucket Server
为当前正在认证的用户创建PAT。在Bitbucket中,即使作为管理员,也不能为其他用户创建PAT。只有用户名/密码认证被支持,用于执行与Bitbucket仓库或项目无关的操作。请注意创建后显示的PAT ID。将来需要删除PAT时,将需要这个ID。
`SCMKit.exe -s bitbucket -m createpat -c userName:password -u https://bitbucket.something.local `
#### 示例输出```
C:\>SCMKit.exe -s gitlab -m createpat -c username:password -u https://gitlab.hogwarts.local -o hgranger
==================================================
Module: createpat
System: gitlab
Auth Type: Username/Password
Options: hgranger
Target URL: https://gitlab.hogwarts.local
Timestamp: 1/20/2022 1:51:23 PM
==================================================
ID | Name | Token
-----------------------------------------------------
59 | SCMKIT-AaCND | R3ySx_8HUn6UQ_6onETx
[+] SUCCESS: The hgranger user personal access token was successfully added.
列出特定 SCM 系统上用户的访问令牌
提供 listpat 模块以及相关的认证信息和 URL。
仅当您想列出其他用户的 PAT 时才需要管理员权限。普通用户可以列出自己的 PAT。
SCMKit.exe -s gitlab -m listpat -c userName:password -u https://gitlab.something.local -o targetUser
SCMKit.exe -s gitlab -m listpat -c apikey -u https://gitlab.something.local -o targetUser
列出当前用户的访问令牌。仅支持用户名/密码认证来执行与 Bitbucket 仓库或项目无关的操作。
SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local
列出其他用户的访问令牌(需要管理员权限)。仅支持用户名/密码认证来执行与 Bitbucket 仓库或项目无关的操作。
SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local -o targetUser
C:>SCMKit.exe -s gitlab -m listpat -c username:password -u https://gitlab.hogwarts.local -o hgranger
================================================== Module: listpat System: gitlab Auth Type: Username/Password Options: hgranger Target URL: https://gitlab.hogwarts.local
59 | SCMKIT-AaCND | True | api, read_repository, write_repository
### 移除访问令牌
#### 用例
> *移除用户在特定 SCM 系统中的访问令牌*
#### 语法
提供 `removepat` 模块,以及任何相关的身份验证信息和 URL。此外,提供你想要移除访问令牌的目标用户 PAT ID。
##### GitLab 企业版
如果要移除其他用户的 PAT,仅需管理员权限。普通用户可以移除自己的 PAT。你必须提供要移除的 PAT ID。该 ID 在你创建 PAT 时显示,也在你列出 PAT 时显示。
`SCMKit.exe -s gitlab -m removepat -c userName:password -u https://gitlab.something.local -o patID`
`SCMKit.exe -s gitlab -m removepat -c apikey -u https://gitlab.something.local -o patID`
##### Bitbucket 服务器
仅支持用户名/密码身份验证来执行 Bitbucket 中与仓库或项目无关的操作。你必须提供要移除的 PAT ID。该 ID 在你创建 PAT 时显示。
`SCMKit.exe -s bitbucket -m removepat -c userName:password -u https://bitbucket.something.local -o patID`
#### 示例输出```
C:\>SCMKit.exe -s gitlab -m removepat -c apikey -u https://gitlab.hogwarts.local -o 58
==================================================
Module: removepat
System: gitlab
Auth Type: API Key
Options: 59
Target URL: https://gitlab.hogwarts.local
Timestamp: 1/20/2022 1:56:47 PM
==================================================
[*] INFO: Revoking personal access token of ID: 59
[+] SUCCESS: The personal access token of ID 59 was successfully revoked.
为特定 SCM 系统创建 SSH 密钥
提供 createsshkey 模块及相关认证信息和 URL.
为当前认证用户创建 SSH 密钥。
SCMKit.exe -s github -m createsshkey -c userName:password -u https://github.something.local -o "ssh public key"
SCMKit.exe -s github -m createsshkey -c apiToken -u https://github.something.local -o "ssh public key"
为当前认证用户创建 SSH 密钥。请注意创建后显示的 SSH 密钥 ID。将来需要移除该 SSH 密钥时,你将需要这个 ID。
SCMKit.exe -s gitlab -m createsshkey -c userName:password -u https://gitlab.something.local -o "ssh public key"
SCMKit.exe -s gitlab -m createsshkey -c apiToken -u https://gitlab.something.local -o "ssh public key"
为当前认证用户创建 SSH 密钥。在 Bitbucket 中,只有用户名/密码认证支持执行与仓库或项目无关的操作。请注意创建后显示的 SSH 密钥 ID。将来需要移除该 SSH 密钥时,你将需要这个 ID。
SCMKit.exe -s bitbucket -m createsshkey -c userName:password -u https://bitbucket.something.local -o "ssh public key"
C:>SCMKit.exe -s bitbucket -m createsshkey -c username:password -u https://bitbucket.hogwarts.local -o "ssh-rsa..."
================================================== Module: createsshkey System: bitbucket Auth Type: Username/Password Options: ssh-rsa ... Target URL: http://bitbucket.hogwarts.local:7990
16
[+] SUCCESS: The hpotter user SSH key was successfully added.
### 列出 SSH 密钥
#### 使用场景
> *列出特定 SCM 系统上某个用户的 SSH 密钥*
#### 语法
提供 `listsshkey` 模块,以及任何相关的认证信息和 URL。
##### GitHub Enterprise
列出当前用户的 SSH 密钥。这将包括 SSH 密钥的 ID,当您想要移除 SSH 密钥时需要用到。
`SCMKit.exe -s github -m listsshkey -c userName:password -u https://github.something.local`
`SCMKit.exe -s github -m listsshkey -c apiToken -u https://github.something.local`
##### GitLab Enterprise
列出当前用户的 SSH 密钥。
`SCMKit.exe -s gitlab -m listsshkey -c userName:password -u https://gitlab.something.local`
`SCMKit.exe -s gitlab -m listsshkey -c apiToken -u https://gitlab.something.local`
##### Bitbucket Server
列出当前用户的 SSH 密钥。Bitbucket 中仅支持用户名/密码认证来执行与仓库或项目无关的操作。
`SCMKit.exe -s bitbucket -m listsshkey -c userName:password -u https://bitbucket.something.local`
#### 示例输出```
C:\>SCMKit.exe -s gitlab -m listsshkey -u http://gitlab.hogwarts.local -c apiToken
==================================================
Module: listsshkey
System: gitlab
Auth Type: API Key
Options:
Target URL: https://gitlab.hogwarts.local
Timestamp: 2/7/2022 4:09:40 PM
==================================================
SSH Key ID | SSH Key Value | Title
---------------------------------------------------------------
9 | .....p50edigBAF4lipVZkAM= | SCMKIT-RLzie
10 | .....vGJLPGHiTwIxW9i+xAs= | SCMKIT-muFGU
为某个 SCM 系统中的用户移除 SSH 密钥
提供 removesshkey 模块,以及相关的认证信息和 URL。此外,还需要提供要移除的目标用户 SSH 密钥 ID。
你必须提供要移除的 SSH 密钥 ID。该 ID 在列出 SSH 密钥时会显示。
SCMKit.exe -s github -m removesshkey -c userName:password -u https://github.something.local -o sshKeyID
SCMKit.exe -s github -m removesshkey -c apiToken -u https://github.something.local -o sshKeyID
你必须提供要移除的 SSH 密钥 ID。该 ID 在创建 SSH 密钥时显示,并且在列出 SSH 密钥时也会显示。
SCMKit.exe -s gitlab -m removesshkey -c userName:password -u https://gitlab.something.local -o sshKeyID
SCMKit.exe -s gitlab -m removesshkey -c apiToken -u https://gitlab.something.local -o sshKeyID
在 Bitbucket 中执行与仓库或项目无关的操作时,仅支持用户名/密码认证。你必须提供要移除的 SSH 密钥 ID。该 ID 在创建 SSH 密钥时显示,并且在列出 SSH 密钥时也会显示。
SCMKit.exe -s bitbucket -m removesshkey -c userName:password -u https://bitbucket.something.local -o sshKeyID
C:>SCMKit.exe -s bitbucket -m removesshkey -u http://bitbucket.hogwarts.local:7990 -c username:password -o 16
================================================== Module: removesshkey System: bitbucket Auth Type: Username/Password Options: 16 Target URL: http://bitbucket.hogwarts.local:7990
[+] SUCCESS: The SSH key of ID 16 was successfully revoked.
### 列出管理员统计信息
#### 用例
> *在 GitHub Enterprise 中列出管理员统计信息*
#### 语法
提供 `adminstats` 模块,以及任何相关的认证信息和 URL。使用此模块需要在 GitHub Enterprise 中具有站点管理员权限。
##### GitHub Enterprise
`SCMKit.exe -s github -m adminstats -c userName:password -u https://github.something.local`
`SCMKit.exe -s github -m adminstats -c apikey -u https://github.something.local`
#### 示例输出```
C:\>SCMKit.exe -s github -m adminstats -c username:password -u https://github-enterprise.hogwarts.local
==================================================
Module: adminstats
System: github
Auth Type: Username/Password
Options:
Target URL: https://github-enterprise.hogwarts.local
Timestamp: 1/14/2022 9:45:50 PM
==================================================
Admin Users | Suspended Users | Total Users
------------------------------------------------------
1 | 0 | 5
Total Repos | Total Wikis
-----------------------------------
4 | 0
Total Orgs | Total Team Members | Total Teams
----------------------------------------------------------
1 | 0 | 0
Private Gists | Public Gists
-----------------------------------
0 | 1
列出 GitHub Enterprise 中的分支保护
提供 protection 模块,以及相关的认证信息和 URL。可选地,在参数中提供一个字符串,以返回包含该字符串的仓库名称中的匹配结果。
SCMKit.exe -s github -m protection -c userName:password -u https://github.something.local
SCMKit.exe -s github -m protection -c apikey -u https://github.something.local
SCMKit.exe -s github -m protection -c apikey -u https://github.something.local -o reponame
C:>.\SCMKit.exe -u http://github.hogwarts.local -s github -c apiToken -m protection -o public-r
================================================== Module: protection System: github Auth Type: API Key Options: public-r Target URL: http://github.hogwarts.local
Repo | Branch | Protection
public-repo | dev | Protected: True
Status checks must pass before merge:
Branch must be up-to-date before merge: True
Owner review required before merge: True
Approvals required before merge: 2
Protections apply to repo admins: True
public-repo | main | Protected: False
## 检测
以下是该工具在默认状态下具体使用的静态签名:
* 项目GUID - `{266C644A-69B1-426B-A47C-1CF32B211F80}`
* 请参见本仓库中的[SCMKit Yara规则](https://github.com/h4wkst3r/scmkit/blob/main/Detections/SCMKit.yar)。
* 用户代理字符串 - `SCMKIT-5dc493ada400c79dd318abbe770dac7c`
* 请参见本仓库中的[SCMKit Snort规则](https://github.com/h4wkst3r/scmkit/blob/main/Detections/SCMKit.rules)。
* 访问令牌和SSH密钥名称 - 使用该工具创建的访问令牌和SSH密钥,其名称均以`SCMKIT-`为前缀。
有关该工具所用技术的检测指导,请参见X-Force Red的[博客文章](https://securityintelligence.com/posts/abusing-source-code-management-systems)。
## 参考文献
* Bitbucket API 文档
* https://developer.atlassian.com/server/bitbucket/reference/rest-api/
* Octokit 文档
* https://octokitnet.readthedocs.io/en/latest/
* https://github.com/octokit/octokit.net
* GitHub API 文档
* https://docs.github.com/en/rest/overview
* GitLab API 文档
* https://docs.gitlab.com/ee/api/api_resources.html
* GitLabApiClient Nuget 包文档
* https://github.com/nmklotas/GitLabApiClient
| 库 | URL | 许可证 |
|---|
| Octokit | https://github.com/octokit/octokit.net | MIT 许可证 |
| Fody | https://github.com/Fody/Fody | MIT 许可证 |
| GitLabApiClient | https://github.com/nmklotas/GitLabApiClient | MIT 许可证 |
| Newtonsoft.Json | https://github.com/JamesNK/Newtonsoft.Json | MIT 许可证 |
| 攻击场景 | 模块 | 需要管理员? | GitHub Enterprise | GitLab Enterprise | Bitbucket Server |
|---|
| 侦察 | listrepo | 否 | X | X | X |
| 侦察 | searchrepo | 否 | X | X | X |
| 侦察 | searchcode | 否 | X | X | X |
| 侦察 | searchfile | 否 | X | X | X |
| 侦察 | listsnippet | 否 | X | ||
| 侦察 | listrunner | 否 | X | ||
| 侦察 | listgist | 否 | X | ||
| 侦察 | listorg | 否 | X | ||
| 侦察 | privs | 否 | X | X | |
| 侦察 | protection | 否 | X | ||
| 持久化 | listsshkey | 否 | X | X | X |
| 持久化 | removesshkey | 否 | X | X | X |
| 持久化 | createsshkey | 否 | X | X | X |
| 持久化 | listpat | 否 | X | X | |
| 持久化 | removepat | 否 | X | X | |
| 持久化 | createpat | 是(仅 GitLab Enterprise) | X | X | |
| 权限提升 | addadmin | 是 | X | X | X |
| 权限提升 | removeadmin | 是 | X | X | X |
| 侦察 | adminstats | 是 | X |