Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
SCMKit — ソースコード管理攻撃ツールキット | Kitploit
ツール/GitHubGitHub/h4wkst3r/scmkit
特権昇格偵察永続化メカニズムペネトレーションテストレッドチーミング
GitHubh4wkst3r/scmkit

SCMKit

ソースコード管理攻撃ツールキット

リポジトリを見る
2295413年前Kitploit レビュー済み

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

SCMKit

説明

Source Code Management Attack Toolkit - SCMKit は、SCMシステムを攻撃するために使用できるツールキットです。SCMKit では、使用するSCMシステムと攻撃モジュールを指定し、該当するSCMシステムへの有効な認証情報(ユーザー名/パスワードまたはAPIキー)を指定できます。現在、SCMKit がサポートしているSCMシステムは、GitHub Enterprise、GitLab Enterprise、Bitbucket Server です。サポートされている攻撃モジュールには、偵察、権限昇格、永続化が含まれます。SCMKit はモジュール式で構築されているため、今後情報セキュリティコミュニティによって新しいモジュールやSCMシステムを追加できます。

リリース

  • SCMKit のバージョン 1.2 はリリースにあります。

目次

  • SCMKit
  • 目次
  • インストール/ビルド
    • 使用ライブラリ
    • プリコンパイル済み
    • 自分でビルドする
  • 使用方法
    • 引数/オプション
    • システム
    • モジュール
    • モジュール詳細表
  • 使用例
    • リポジトリの一覧表示
    • リポジトリの検索
    • コードの検索
    • ファイルの検索
    • スニペットの一覧表示
    • ランナーの一覧表示
    • Gist の一覧表示
    • 組織の一覧表示
    • APIキーの権限取得
    • 管理者の追加
    • 管理者の削除
    • アクセストークンの作成
    • アクセストークンの一覧表示
    • アクセストークンの削除
    • SSHキーの作成
    • SSHキーの一覧表示
    • SSHキーの削除
    • 管理者統計の一覧表示
    • ブランチ保護の一覧表示
  • 検出
  • 参考文献

インストール/ビルド

使用ライブラリ

このプロジェクトでは以下のサードパーティライブラリを使用しています。

プリコンパイル済み

  • リリースのプリコンパイル済みバイナリを使用してください。

自分でビルドする

以下の手順に従って Visual Studio をセットアップし、自分でプロジェクトをコンパイルしてください。これには、NuGet パッケージマネージャーからインストールできる .NET ライブラリが必要です。

  • Visual Studio プロジェクトを読み込み、「ツール」→「NuGet パッケージマネージャー」→「パッケージマネージャーの設定」に移動します。
  • 「NuGet パッケージマネージャー」→「パッケージソース」に移動します。
  • URL https://api.nuget.org/v3/index.json を使用してパッケージソースを追加します。
  • 以下の NuGet パッケージをインストールします。
    • Install-Package Costura.Fody -Version 3.3.3
    • Install-Package Octokit
    • Install-Package GitLabApiClient
    • Install-Package Newtonsoft.Json
  • これで、自分でプロジェクトをビルドできます!

使用方法

引数/オプション

  • -c, -credential - 認証用の資格情報 (username:password または apiKey)
  • -s, -system - 攻撃対象のシステム (github,gitlab,bitbucket)
  • -u, -url - GitHub Enterprise、GitLab Enterprise、または Bitbucket Server のURL
  • -m, -module - 実行するモジュール
  • -o, -option - オプション (該当する場合)

システム (-s, -system)

  • github: GitHub Enterprise
  • gitlab: GitLab Enterprise
  • bitbucket: Bitbucket Server

モジュール (-m, -module)

  • listrepo: 現在のユーザーが表示できるすべてのリポジトリを一覧表示する
  • searchrepo: 指定されたリポジトリを検索する
  • searchcode: キーワード検索語を含むコードを検索する
  • searchfile: キーワード検索語を含むファイル名を検索する
  • listsnippet: 現在のユーザーのすべてのスニペットを一覧表示する
  • listrunner: 現在のユーザーが利用可能なすべての GitLab ランナーを一覧表示する
  • listgist: 現在のユーザーのすべての Gist を一覧表示する
  • listorg: 現在のユーザーが所属するすべての組織を一覧表示する
  • privs: 現在のAPIトークンの権限を取得する
  • addadmin: 指定されたユーザーを管理者ロールに昇格させる
  • removeadmin: 指定されたユーザーを管理者ロールから降格させる
  • createpat: 対象ユーザーの個人アクセストークンを作成する
  • listpat: 対象ユーザーの個人アクセストークンを一覧表示する
  • removepat: 対象ユーザーの個人アクセストークンを削除する
  • createsshkey: 現在のユーザーのSSHキーを作成する
  • listsshkey: 現在のユーザーのSSHキーを一覧表示する
  • removesshkey: 現在のユーザーのSSHキーを削除する
  • adminstats: 管理者統計を取得する (ユーザー、リポジトリ、組織、Gist)
  • protection: ブランチ保護設定を取得する

モジュール詳細表

以下の表は、各モジュールがサポートされている場所を示しています。

使用例

リポジトリの一覧表示

使用例

特定のSCMシステムで使用されているリポジトリを発見する

構文

listrepo モジュールを、関連する認証情報およびURLとともに指定します。これにより、リポジトリ名とURLが出力されます。

GitHub Enterprise

これにより、ユーザーが表示できるすべてのリポジトリが一覧表示されます。

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

GitLab Enterprise

これにより、ユーザーが表示できるすべてのリポジトリが一覧表示されます。

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

Bitbucket Server

これにより、ユーザーが表示できるすべてのリポジトリが一覧表示されます。

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

Timestamp: 1/14/2022 8:30:47 PM

root@kitploit:~
                                Name | Visibility |                                                URL

root@kitploit:~
                        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
root@kitploit:~
### リポジトリの検索

#### ユースケース

> *特定のSCMシステム内でリポジトリ名によりリポジトリを検索します*

#### 構文

`searchrepo` モジュールと検索条件を `-o` コマンドラインスイッチで指定し、関連する認証情報とURLを付加します。これにより、一致するリポジトリ名とURLが出力されます。

##### GitHub Enterprise

GitHubのリポジトリ検索は「contains」検索であり、入力した文字列がリポジトリ名に含まれるリポジトリを検索します。

`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のリポジトリ検索は「contains」検索であり、入力した文字列がリポジトリ名に含まれるリポジトリを検索します。

`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のリポジトリ検索は「starts with」検索であり、入力した文字列で始まるリポジトリ名を持つリポジトリを検索します。

`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 Enterprise

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 Enterprise

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 Server

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"

出力例

root@kitploit:~

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

Timestamp:      1/14/2022 8:34:14 PM
==================================================


[>] URL: https://gitlab.hogwarts.local/adumbledore/secret-spells/stuff.txt
    |_ API_KEY=abc123

Total number of items matching code search: 1

```
### ファイル検索

#### ユースケース

> *特定のSCMシステムにおいて、ファイル名に特定のキーワードを含むリポジトリ内のファイルを検索する*

#### 構文

`searchfile` モジュールと検索条件を `-o` コマンドラインスイッチで指定し、関連する認証情報とURLを指定します。これにより、該当するリポジトリ内の一致するファイルのURLが出力されます。

##### GitHub Enterprise

The GitLab file search is a "contains" search where the string you enter it will search for files that contains your search term in the file name.

`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

The GitLab file search is a "contains" search where the string you enter it will search for files that contains your search term in the file name.

`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

The Bitbucket file search is a "contains" search where the string you enter it will search for files that contains your search term in the file name.

`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を指定します。

##### GitLab Enterprise

`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

Timestamp:      1/14/2022 9:17:36 PM
==================================================

               Title |                                                                Raw URL
---------------------------------------------------------------------------------------------
        spell-script |                         https://gitlab.hogwarts.local/-/snippets/2/raw
```
### ランナーの一覧表示

#### 使用例

> *GitLab内で現在のユーザーが利用可能なすべてのGitLabランナーを一覧表示します*

#### 構文

`listrunner` モジュールと、関連する認証情報およびURLを指定します。ユーザーが管理者の場合、GitLab Enterpriseインスタンス内のすべてのランナー(共有ランナーおよびグループランナーを含む)を一覧表示できます。

##### GitLab Enterprise

`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を指定します。

##### GitHub Enterprise

`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

Timestamp:      1/14/2022 9:43:23 PM
==================================================

                             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
                      
```
### APIトークンの権限を取得

#### ユースケース

> *特定のSCMシステムで使用されているアクセストークンに割り当てられた権限を取得する*

#### 構文

`privs`モジュールとAPIキー、URLを指定します。

##### GitHub Enterprise

`SCMKit.exe -s github -m privs -c apiKey -u https://github.something.local`

##### GitLab Enterprise

`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

Timestamp:      1/14/2022 9:18:27 PM
==================================================

          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とともに指定します。さらに、管理者ロールを削除したい対象ユーザーを指定します。

##### GitHub Enterprise

`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`

##### GitLab Enterprise

`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 Server

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

Timestamp:      1/14/2022 9:20:12 PM
==================================================


[+] 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を削除する必要がある場合に必要になります。

`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と共に指定します。

##### GitLab Enterprise

別のユーザーの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 Server

現在のユーザーのアクセストークンを一覧表示します。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

Timestamp:      1/20/2022 1:54:41 PM
==================================================

   ID |                 Name |    Active? |                                             Scopes
----------------------------------------------------------------------------------------------
   59 |         SCMKIT-AaCND |       True |             api, read_repository, write_repository
    
```
### アクセストークンの削除

#### ユースケース

> *特定のSCMシステムにおけるユーザーのアクセストークンを削除する*

#### 構文

`removepat` モジュールを、関連する認証情報とURLとともに指定します。さらに、アクセストークンを削除したい対象ユーザーのPAT IDを指定します。

##### GitLab Enterprise

別のユーザーの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 Server

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.

```
### SSHキーの作成

#### ユースケース

> *特定のSCMシステムで使用するSSHキーを作成します*

#### 構文

`createsshkey` モジュールを、関連する認証情報およびURLと共に指定します。

##### GitHub Enterprise

現在認証しているユーザーの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"`

##### GitLab Enterprise

現在認証しているユーザーの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"`

##### Bitbucket Server

現在認証しているユーザーのSSHキーを作成します。Bitbucketでリポジトリやプロジェクトに関係ないアクションを実行するためには、username/password認証のみがサポートされています。作成後に表示される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

Timestamp:      2/7/2022 1:02:31 PM
==================================================

  SSH Key ID
------------
          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
    
```
### SSHキーの削除

#### 使用例

> *特定のSCMシステムにおけるユーザーのSSHキーを削除する*

#### 構文

`removesshkey`モジュールと、関連する認証情報およびURLを指定します。さらに、削除するターゲットユーザーのSSHキーIDを指定します。

##### GitHub Enterprise

削除する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`

##### GitLab Enterprise

削除する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 Server

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

Timestamp:      2/7/2022 1:48:03 PM
==================================================


[+] 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 を指定します。オプションで、オプションパラメータに文字列を指定すると、リポジトリ名に含まれる一致する結果が返されます。

##### GitHub Enterprise

`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

Timestamp:      8/29/2022 2:02:42 PM
==================================================

                     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
```
## Detection

以下は、このツールがデフォルト状態で使用される場合の静的シグネチャです:

* プロジェクト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)を参照してください。

## References
* 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ライセンス
Octokithttps://github.com/octokit/octokit.netMIT License
Fodyhttps://github.com/Fody/FodyMIT License
GitLabApiClienthttps://github.com/nmklotas/GitLabApiClientMIT License
Newtonsoft.Jsonhttps://github.com/JamesNK/Newtonsoft.JsonMIT License
攻撃シナリオモジュール管理者権限が必要?GitHub EnterpriseGitLab EnterpriseBitbucket Server
偵察listrepoいいえXXX
偵察searchrepoいいえXXX
偵察searchcodeいいえXXX
偵察searchfileいいえXXX
偵察listsnippetいいえX
偵察listrunnerいいえX
偵察listgistいいえX
偵察listorgいいえX
偵察privsいいえXX
偵察protectionいいえX
永続化listsshkeyいいえXXX
永続化removesshkeyいいえXXX
永続化createsshkeyいいえXXX
永続化listpatいいえXX
永続化removepatいいえXX
永続化createpatはい (GitLab Enterprise のみ)XX
権限昇格addadminはいXXX
権限昇格removeadminはいXXX
偵察adminstatsはいX