
Ferramenta de Ataque para Gerenciamento de Código Fonte
Source Code Management Attack Toolkit - SCMKit é um kit de ferramentas que pode ser usado para atacar sistemas SCM. O SCMKit permite ao usuário especificar o sistema SCM e o módulo de ataque a ser usado, além de especificar credenciais válidas (nome de usuário/senha ou chave de API) para o respectivo sistema SCM. Atualmente, os sistemas SCM suportados pelo SCMKit são GitHub Enterprise, GitLab Enterprise e Bitbucket Server. Os módulos de ataque suportados incluem reconhecimento, escalonamento de privilégios e persistência. O SCMKit foi construído de forma modular, para que novos módulos e sistemas SCM possam ser adicionados no futuro pela comunidade de segurança da informação.
As seguintes bibliotecas de terceiros são usadas neste projeto.
Siga as etapas abaixo para configurar o Visual Studio e compilar o projeto você mesmo. Isso requer uma biblioteca .NET que pode ser instalada a partir do gerenciador de pacotes NuGet.
https://api.nuget.org/v3/index.jsonInstall-Package Costura.Fody -Version 3.3.3Install-Package OctokitInstall-Package GitLabApiClientInstall-Package Newtonsoft.JsonA tabela abaixo mostra onde cada módulo é suportado
Descobrir repositórios em uso em um sistema SCM específico
Forneça o módulo listrepo, juntamente com qualquer informação de autenticação relevante e URL. Isso exibirá o nome do repositório e a URL.
Isso listará todos os repositórios que um usuário pode ver.
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
Isso listará todos os repositórios que um usuário pode ver.
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
Isso listará todos os repositórios que um usuário pode ver.
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
### Procurar Repositórios
#### Caso de Uso
> *Pesquisar repositórios pelo nome do repositório em um sistema SCM específico*
#### Sintaxe
Forneça o módulo `searchrepo` e seus critérios de pesquisa no switch de linha de comando `-o`, juntamente com qualquer informação de autenticação relevante e URL. Isso exibirá o nome e URL do repositório correspondente.
##### GitHub Enterprise
A pesquisa de repositórios do GitHub é uma pesquisa "contém" onde a string que você insere pesquisará por repositórios com nomes que contenham seu termo de pesquisa.
`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
A pesquisa de repositórios do GitLab é uma pesquisa "contém" onde a string que você insere pesquisará por repositórios com nomes que contenham seu termo de pesquisa.
`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
A pesquisa de repositórios do Bitbucket é uma pesquisa "começa com" onde a string que você insere pesquisará por repositórios com nomes que comecem com seu termo de pesquisa.
`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"`
#### Exemplo de Saída```
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
Pesquisar código contendo uma determinada palavra-chave em um sistema SCM específico
Forneça o módulo searchcode e seus critérios de pesquisa no switch de linha de comando -o, juntamente com qualquer informação de autenticação relevante e URL. Isso gerará a URL para o arquivo de código correspondente, juntamente com a linha no código que correspondeu.
A pesquisa de código do GitHub é uma pesquisa "contém" onde a string que você insere irá pesquisar código que contenha seu termo de pesquisa em qualquer linha.
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"
A pesquisa de código do GitLab é uma pesquisa "contém" onde a string que você insere irá pesquisar código que contenha seu termo de pesquisa em qualquer linha.
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"
A pesquisa de código do Bitbucket é uma pesquisa "contém" onde a string que você insere irá pesquisar código que contenha seu termo de pesquisa em qualquer linha.
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
### Pesquisar Arquivos
#### Caso de Uso
> *Pesquisar por arquivos em repositórios que contenham uma palavra-chave específica no nome do arquivo em um determinado sistema SCM*
#### Sintaxe
Forneça o módulo `searchfile` e seus critérios de pesquisa na opção de linha de comando `-o`, juntamente com as informações de autenticação relevantes e URL. Isso irá gerar o URL para o arquivo correspondente em seu respectivo repositório.
##### GitHub Enterprise
A pesquisa de arquivos do GitLab é uma pesquisa do tipo "contém", onde a string que você inserir irá procurar por arquivos que contenham o seu termo de pesquisa no nome do arquivo.
`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
A pesquisa de arquivos do GitLab é uma pesquisa do tipo "contém", onde a string que você inserir irá procurar por arquivos que contenham o seu termo de pesquisa no nome do arquivo.
`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
A pesquisa de arquivos do Bitbucket é uma pesquisa do tipo "contém", onde a string que você inserir irá procurar por arquivos que contenham o seu termo de pesquisa no nome do arquivo.
`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"`
#### Exemplo de Saída```
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
Listar snippets de propriedade do usuário atual no GitLab
Forneça o módulo listsnippet, juntamente com qualquer informação de autenticação relevante e 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
### Listar Executores
#### Caso de Uso
> *Listar todos os executores do GitLab disponíveis para o usuário atual no GitLab*
#### Sintaxe
Forneça o módulo `listrunner`, juntamente com qualquer informação de autenticação relevante e URL. Se o usuário for um administrador, você poderá listar todos os executores na instância do GitLab Enterprise, que inclui executores compartilhados e de grupo.
##### 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`
#### Exemplo de Saída```
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
Listar gists de propriedade do usuário atual no GitHub
Forneça o módulo listgist, juntamente com quaisquer informações de autenticação e URL relevantes.
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
### Listar Organizações
#### Caso de Uso
> *Lista todas as organizações às quais o usuário atual pertence no GitHub*
#### Sintaxe
Forneça o módulo `listorg`, juntamente com qualquer informação de autenticação relevante e 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`
#### Exemplo de Saída```
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
Obter os privilégios atribuídos a um token de acesso sendo usado em um sistema SCM específico
Forneça o módulo privs, juntamente com uma chave de API e 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.
### Adicionar Administrador
#### Caso de Uso
> *Promover um usuário normal para uma função administrativa em um sistema SCM específico*
#### Sintaxe
Forneça o módulo `addadmin`, juntamente com quaisquer informações de autenticação relevantes e URL. Além disso, forneça o usuário alvo ao qual você deseja adicionar uma função administrativa.
##### 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
Apenas autenticação de nome de usuário/senha é suportada para realizar ações não relacionadas a repositórios ou projetos no Bitbucket.
`SCMKit.exe -s bitbucket -m addadmin -c userName:password -u https://bitbucket.something.local -o targetUserName`
#### Exemplo de Saída```
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.
Rebaixar um usuário administrador para uma função de usuário normal em um sistema SCM específico
Forneça o módulo removeadmin, juntamente com qualquer informação de autenticação relevante e URL. Além disso, forneça o usuário alvo do qual você deseja remover uma função administrativa.
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
Apenas a autenticação de nome de usuário/senha é suportada para realizar ações não relacionadas a repositórios ou projetos no 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.
### Criar Token de Acesso
#### Caso de Uso
> *Criar um token de acesso para ser usado em um sistema SCM específico*
#### Sintaxe
Forneça o módulo `createpat`, juntamente com quaisquer informações de autenticação relevantes e URL. Além disso, forneça o usuário alvo para o qual você deseja criar um token de acesso.
##### GitLab Enterprise
Isso só pode ser feito como administrador. Você fornecerá o nome de usuário para o qual deseja criar um 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
Cria PAT para o usuário atual que está autenticando. No Bitbucket, você não pode criar um PAT para outro usuário, mesmo como administrador. Apenas autenticação por nome de usuário/senha é suportada para realizar ações não relacionadas a repositórios ou projetos no Bitbucket. Anote o ID do PAT que é exibido após a criação. Você precisará dele quando precisar remover o PAT no futuro.
`SCMKit.exe -s bitbucket -m createpat -c userName:password -u https://bitbucket.something.local `
#### Exemplo de Saída
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.
```
### Listar Tokens de Acesso
#### Caso de Uso
> *Listar tokens de acesso de um usuário em um sistema SCM específico*
#### Sintaxe
Forneça o módulo `listpat`, juntamente com quaisquer informações de autenticação relevantes e URL.
##### GitLab Enterprise
Só requer administrador se você quiser listar os PATs de outro usuário. Um usuário comum pode listar seus próprios PATs.
`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
Listar tokens de acesso do usuário atual. Apenas a autenticação de nome de usuário/senha é suportada para realizar ações não relacionadas a repositórios ou projetos no Bitbucket.
`SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local`
Listar tokens de acesso de outro usuário (requer administrador). Apenas a autenticação de nome de usuário/senha é suportada para realizar ações não relacionadas a repositórios ou projetos no Bitbucket.
`SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local -o targetUser`
#### Exemplo de Saída```
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
```
### Remover Token de Acesso
#### Caso de Uso
> *Remover um token de acesso para um utilizador num sistema SCM específico*
#### Sintaxe
Forneça o módulo `removepat`, juntamente com qualquer informação de autenticação relevante e URL. Além disso, forneça o ID do PAT do utilizador alvo para o qual pretende remover um token de acesso.
##### GitLab Enterprise
Apenas requer administrador se quiser remover o PAT de outro utilizador. Um utilizador normal pode remover o seu próprio PAT. Tem de fornecer o ID do PAT a remover. Este ID foi mostrado sempre que criou o PAT e também quando listou o 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
Apenas a autenticação com nome de utilizador/palavra-passe é suportada para realizar ações não relacionadas com repositórios ou projetos no Bitbucket. Tem de fornecer o ID do PAT a remover. Este ID foi mostrado sempre que criou o PAT.
`SCMKit.exe -s bitbucket -m removepat -c userName:password -u https://bitbucket.something.local -o patID`
#### Exemplo de Saída```
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.
```
### Criar Chave SSH
#### Caso de Uso
> *Criar uma chave SSH para ser usada em um sistema SCM específico*
#### Sintaxe
Forneça o módulo `createsshkey`, juntamente com quaisquer informações de autenticação relevantes e URL.
##### GitHub Enterprise
Cria chave SSH para o usuário atual autenticando como.
`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
Cria chave SSH para o usuário atual autenticando como. Anote o ID da chave SSH que é mostrado após a criação. Você precisará disso quando precisar remover a chave SSH no futuro.
`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
Cria chave SSH para o usuário atual autenticando como. Apenas autenticação por nome de usuário/senha é suportada para realizar ações não relacionadas a repositórios ou projetos no Bitbucket. Anote o ID da chave SSH que é mostrado após a criação. Você precisará disso quando precisar remover a chave SSH no futuro.
`SCMKit.exe -s bitbucket -m createsshkey -c userName:password -u https://bitbucket.something.local -o "ssh public key"`
#### Exemplo de Saída```
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.
```
### Listar Chaves SSH
#### Caso de Uso
> *Listar chaves SSH para um utilizador num determinado sistema SCM*
#### Sintaxe
Forneça o módulo `listsshkey`, juntamente com qualquer informação de autenticação e URL relevantes.
##### GitHub Enterprise
Listar chaves SSH para o utilizador atual. Isto incluirá os IDs das chaves SSH, que são necessários quando se pretende remover uma chave 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
Listar chaves SSH para o utilizador atual.
`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
Listar chaves SSH para o utilizador atual. Apenas a autenticação por nome de utilizador/palavra-passe é suportada para realizar ações não relacionadas com repositórios ou projetos no Bitbucket.
`SCMKit.exe -s bitbucket -m listsshkey -c userName:password -u https://bitbucket.something.local`
#### Exemplo de Saída```
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
```
### Remover Chave SSH
#### Caso de Uso
> *Remover uma chave SSH para um usuário em um sistema SCM específico*
#### Sintaxe
Forneça o módulo `removesshkey`, juntamente com qualquer informação de autenticação relevante e URL. Além disso, forneça o ID da chave SSH do usuário alvo a ser removido.
##### GitHub Enterprise
Você deve fornecer o ID da chave SSH a ser removida. Este ID foi mostrado sempre que você lista as chaves 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
Você deve fornecer o ID da chave SSH a ser removida. Este ID foi mostrado quando você criou a chave SSH e também é mostrado ao listar as chaves 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
Apenas a autenticação com nome de usuário/senha é suportada para realizar ações não relacionadas a repositórios ou projetos no Bitbucket. Você deve fornecer o ID da chave SSH a ser removida. Este ID foi mostrado quando você criou a chave SSH e também é mostrado ao listar as chaves SSH.
`SCMKit.exe -s bitbucket -m removesshkey -c userName:password -u https://bitbucket.something.local -o sshKeyID`
#### Exemplo de Saída```
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.
```
### Listar Estatísticas de Admin
#### Caso de Uso
> *Listar estatísticas de administrador no GitHub Enterprise*
#### Sintaxe
Forneça o módulo `adminstats`, juntamente com qualquer informação de autenticação relevante e URL. É necessário acesso de administrador do site no GitHub Enterprise para usar este módulo
##### 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`
#### Exemplo de Saída```
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
```
### Listar Proteção de Ramo
#### Caso de Uso
> *Listar proteções de ramo no GitHub Enterprise*
#### Sintaxe
Forneça o módulo `protection`, juntamente com qualquer informação de autenticação relevante e URL. Opcionalmente, forneça uma string no parâmetro de opções para retornar resultados correspondentes contidos nos nomes dos repositórios.
##### 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`
#### Exemplo de Saída```
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
```
## Detecção
Abaixo estão assinaturas estáticas para o uso específico desta ferramenta em seu estado padrão:
* GUID do Projeto - `{266C644A-69B1-426B-A47C-1CF32B211F80}`
* Veja [Regra Yara do SCMKit](https://github.com/h4wkst3r/scmkit/blob/main/Detections/SCMKit.yar) neste repositório.
* String de User Agent - `SCMKIT-5dc493ada400c79dd318abbe770dac7c`
* Veja [Regra Snort do SCMKit](https://github.com/h4wkst3r/scmkit/blob/main/Detections/SCMKit.rules) neste repositório.
* Nomes de Token de Acesso e Chave SSH - Tokens de acesso e chaves SSH criados usando a ferramenta são prefixados com `SCMKIT-` no nome.
Para orientação de detecção das técnicas usadas pela ferramenta, consulte a [postagem do blog](https://securityintelligence.com/posts/abusing-source-code-management-systems) da X-Force Red.
## Referências
* Documentação da API do Bitbucket
* https://developer.atlassian.com/server/bitbucket/reference/rest-api/
* Documentação do Octokit
* https://octokitnet.readthedocs.io/en/latest/
* https://github.com/octokit/octokit.net
* Documentação da API do GitHub
* https://docs.github.com/en/rest/overview
* Documentação da API do GitLab
* https://docs.gitlab.com/ee/api/api_resources.html
* Documentação do Pacote Nuget GitLabApiClient
* https://github.com/nmklotas/GitLabApiClient
| Biblioteca | URL | Licença |
|---|
| Octokit | https://github.com/octokit/octokit.net | MIT License |
| Fody | https://github.com/Fody/Fody | MIT License |
| GitLabApiClient | https://github.com/nmklotas/GitLabApiClient | MIT License |
| Newtonsoft.Json | https://github.com/JamesNK/Newtonsoft.Json | MIT License |
| Cenário de Ataque | Módulo | Requer Admin? | GitHub Enterprise | GitLab Enterprise | Bitbucket Server |
|---|
| Reconhecimento | listrepo | Não | X | X | X |
| Reconhecimento | searchrepo | Não | X | X | X |
| Reconhecimento | searchcode | Não | X | X | X |
| Reconhecimento | searchfile | Não | X | X | X |
| Reconhecimento | listsnippet | Não | X | ||
| Reconhecimento | listrunner | Não | X | ||
| Reconhecimento | listgist | Não | X | ||
| Reconhecimento | listorg | Não | X | ||
| Reconhecimento | privs | Não | X | X | |
| Reconhecimento | protection | Não | X | ||
| Persistência | listsshkey | Não | X | X | X |
| Persistência | removesshkey | Não | X | X | X |
| Persistência | createsshkey | Não | X | X | X |
| Persistência | listpat | Não | X | X | |
| Persistência | removepat | Não | X | X | |
| Persistência | createpat | Sim (apenas GitLab Enterprise) | X | X | |
| Escalonamento de Privilégios | addadmin | Sim | X | X | X |
| Escalonamento de Privilégios | removeadmin | Sim | X | X | X |
| Reconhecimento | adminstats | Sim | X |