
Kit de herramientas de ataque para la gestión de código fuente
Source Code Management Attack Toolkit - SCMKit es un kit de herramientas que se puede utilizar para atacar sistemas SCM. SCMKit permite al usuario especificar el sistema SCM y el módulo de ataque a utilizar, junto con credenciales válidas (usuario/contraseña o clave de API) para el sistema SCM correspondiente. Actualmente, los sistemas SCM compatibles con SCMKit son GitHub Enterprise, GitLab Enterprise y Bitbucket Server. Los módulos de ataque compatibles incluyen reconocimiento, escalada de privilegios y persistencia. SCMKit se construyó con un enfoque modular, de modo que la comunidad de seguridad de la información pueda añadir nuevos módulos y sistemas SCM en el futuro.
Las siguientes bibliotecas de terceros se utilizan en este proyecto.
Sigue los pasos a continuación para configurar Visual Studio y compilar el proyecto tú mismo. Esto requiere una biblioteca .NET que se puede instalar desde el administrador de paquetes NuGet.
https://api.nuget.org/v3/index.jsonInstall-Package Costura.Fody -Version 3.3.3Install-Package OctokitInstall-Package GitLabApiClientInstall-Package Newtonsoft.JsonLa siguiente tabla muestra en qué sistemas es compatible cada módulo
Descubrir los repositorios utilizados en un sistema SCM concreto
Proporciona el módulo listrepo, junto con cualquier información de autenticación y URL relevante. Esto generará el nombre del repositorio y su URL.
Esto listará todos los repositorios que un usuario puede 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
Esto listará todos los repositorios que un usuario puede 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
Esto listará todos los repositorios que un usuario puede 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
### Buscar repos
#### Caso de uso
> *Buscar repositorios por nombre de repositorio en un sistema SCM específico*
#### Sintaxis
Proporcione el módulo `searchrepo` y sus criterios de búsqueda en la opción de línea de comandos `-o`, junto con cualquier información de autenticación relevante y la URL. Esto mostrará el nombre y la URL del repositorio coincidente.
##### GitHub Enterprise
La búsqueda de repos en GitHub es una búsqueda de "contiene" en la que la cadena que ingrese buscará repos con nombres que contengan su término de búsqueda.
`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 búsqueda de repos en GitLab es una búsqueda de "contiene" en la que la cadena que ingrese buscará repos con nombres que contengan su término de búsqueda.
`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 búsqueda de repos en Bitbucket es una búsqueda de "comienza con" en la que la cadena que ingrese buscará repos con nombres que comiencen con su término de búsqueda.
`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"`
#### Ejemplo de salida```
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
Busque código que contenga una palabra clave determinada en un sistema SCM específico
Proporcione el módulo searchcode y sus criterios de búsqueda en el interruptor de línea de comandos -o, junto con cualquier información de autenticación relevante y la URL. Esto generará la URL del archivo de código coincidente, junto con la línea del código que coincidió.
La búsqueda de código de GitHub es una búsqueda de tipo "contiene" en la que la cadena que introduzca buscará código que contenga su término de búsqueda en cualquier línea.
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 búsqueda de código de GitLab es una búsqueda de tipo "contiene" en la que la cadena que introduzca buscará código que contenga su término de búsqueda en cualquier línea.
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 búsqueda de código de Bitbucket es una búsqueda de tipo "contiene" en la que la cadena que introduzca buscará código que contenga su término de búsqueda en cualquier línea.
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
### Buscar Archivos
#### Caso de Uso
> *Buscar archivos en repositorios que contengan una palabra clave determinada en el nombre del archivo en un sistema SCM concreto*
#### Sintaxis
Proporcione el módulo `searchfile` y sus criterios de búsqueda en la opción de línea de comandos `-o`, junto con cualquier información de autenticación relevante y la URL. Esto mostrará la URL del archivo coincidente en su repositorio respectivo.
##### GitHub Enterprise
La búsqueda de archivos de GitLab es una búsqueda de tipo "contiene" en la que la cadena que introduzca buscará archivos que contengan su término de búsqueda en el nombre del archivo.
`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 búsqueda de archivos de GitLab es una búsqueda de tipo "contiene" en la que la cadena que introduzca buscará archivos que contengan su término de búsqueda en el nombre del archivo.
`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 búsqueda de archivos de Bitbucket es una búsqueda de tipo "contiene" en la que la cadena que introduzca buscará archivos que contengan su término de búsqueda en el nombre del archivo.
`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"`
#### Ejemplo de Salida```
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 los snippets que pertenecen al usuario actual en GitLab
Proporcione el módulo listsnippet, junto con cualquier información de autenticación relevante y la 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 Runners
#### Caso de uso
> *Listar todos los runners de GitLab disponibles para el usuario actual en GitLab*
#### Sintaxis
Proporcione el módulo `listrunner`, junto con cualquier información de autenticación relevante y la URL. Si el usuario es administrador, podrá listar todos los runners dentro de la instancia de GitLab Enterprise, lo que incluye runners compartidos y 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`
#### Ejemplo de salida```
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 los gists propiedad del usuario actual en GitHub
Proporcione el módulo listgist, junto con cualquier información de autenticación relevante y 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
### List Orgs
#### Caso de uso
> *Listar todas las organizaciones a las que pertenece el usuario actual en GitHub*
#### Sintaxis
Proporcione el módulo `listorg`, junto con cualquier información de autenticación relevante y la 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`
#### Ejemplo de salida```
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
Obtener los privilegios asignados a un token de acceso que se utiliza en un sistema SCM específico
Proporcione el módulo privs, junto con una clave de API y una 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.
### Agregar administrador
#### Caso de uso
> *Promover a un usuario normal a un rol administrativo en un sistema SCM en particular*
#### Sintaxis
Proporcione el módulo `addadmin`, junto con cualquier información de autenticación relevante y la URL. Además, proporcione el usuario objetivo al que desea agregar un rol administrativo.
##### 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
Solo se admite autenticación de nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en Bitbucket.
`SCMKit.exe -s bitbucket -m addadmin -c userName:password -u https://bitbucket.something.local -o targetUserName`
#### Salida de ejemplo```
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.
Degradar a un usuario administrativo a un rol de usuario normal en un sistema SCM particular
Proporcione el módulo removeadmin, junto con la información de autenticación relevante y la URL. Adicionalmente, proporcione el usuario objetivo del que desea eliminar un rol administrativo.
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
Solo se admite autenticación por nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en 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.
### Crear token de acceso
#### Caso de uso
> *Cree un token de acceso para usarlo en un sistema SCM concreto.*
#### Sintaxis
Proporcione el módulo `createpat`, junto con cualquier información de autenticación relevante y la URL. Además, proporcione el usuario de destino para el que desea crear un token de acceso.
##### GitLab Enterprise
Esta operación solo puede realizarse como administrador. Deberá proporcionar el nombre de usuario para el que desea crear 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
Crea un PAT para el usuario que se autentica actualmente. En Bitbucket no puede crear un PAT para otro usuario, ni siquiera como administrador. Solo se admite la autenticación con nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en Bitbucket. Tome nota del ID del PAT que se muestra después de crearlo. Lo necesitará cuando tenga que eliminar el PAT en el futuro.
`SCMKit.exe -s bitbucket -m createpat -c userName:password -u https://bitbucket.something.local `
#### Salida de ejemplo```
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 acceso para un usuario en un sistema SCM específico
Proporcione el módulo listpat, junto con cualquier información de autenticación relevante y la URL.
Solo requiere administrador si desea listar los PAT de otro usuario. Un usuario normal puede listar sus propios 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
Lista los tokens de acceso para el usuario actual. Solo se admite la autenticación con nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en Bitbucket.
SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local
Lista los tokens de acceso para otro usuario (requiere administrador). Solo se admite la autenticación con nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en 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
### Eliminar token de acceso
#### Caso de uso
> *Eliminar un token de acceso para un usuario en un sistema SCM concreto*
#### Sintaxis
Proporcione el módulo `removepat`, junto con la información de autenticación relevante y la URL. Además, proporcione el ID del PAT del usuario objetivo para el que desea eliminar un token de acceso.
##### GitLab Enterprise
Solo se requiere ser administrador si desea eliminar el PAT de otro usuario. Un usuario normal puede eliminar su propio PAT. Debe proporcionar el ID del PAT a eliminar. Este ID se mostraba cada vez que creaba el PAT y también cuando listaba los 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
Solo se admite autenticación con nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en Bitbucket. Debe proporcionar el ID del PAT a eliminar. Este ID se mostraba cada vez que creaba el PAT.
`SCMKit.exe -s bitbucket -m removepat -c userName:password -u https://bitbucket.something.local -o patID`
#### Ejemplo de salida```
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.
Crear una clave SSH para usar en un sistema SCM específico
Proporcione el módulo createsshkey, junto con la información de autenticación y la URL correspondientes.
Crea una clave SSH para el usuario actual con el que se está autenticando.
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"
Crea una clave SSH para el usuario actual con el que se está autenticando. Tome nota del ID de la clave SSH que se muestra después de crearse. Lo necesitará cuando deba eliminar la clave SSH en el 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"
Crea una clave SSH para el usuario actual con el que se está autenticando. Solo se admite autenticación mediante nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en Bitbucket. Tome nota del ID de la clave SSH que se muestra después de crearse. Lo necesitará cuando deba eliminar la clave SSH en el futuro.
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.
### Listar claves SSH
#### Caso de uso
> *Lista las claves SSH de un usuario en un sistema SCM concreto*
#### Sintaxis
Proporcione el módulo `listsshkey`, junto con cualquier información de autenticación relevante y la URL.
##### GitHub Enterprise
Lista las claves SSH del usuario actual. Esto incluirá los ID de las claves SSH, que son necesarios cuando se desea eliminar una clave 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
Lista las claves SSH del usuario actual.
`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
Lista las claves SSH del usuario actual. Solo se admite la autenticación con nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en Bitbucket.
`SCMKit.exe -s bitbucket -m listsshkey -c userName:password -u https://bitbucket.something.local`
#### Salida de ejemplo```
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
Eliminar una clave SSH para un usuario en un sistema SCM específico
Proporcione el módulo removesshkey, junto con cualquier información de autenticación relevante y la URL. Además, proporcione el ID de la clave SSH del usuario objetivo que se va a eliminar.
Debe proporcionar el ID de la clave SSH a eliminar. Este ID se muestra cada vez que enumera las claves 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
Debe proporcionar el ID de la clave SSH a eliminar. Este ID se muestra al crear la clave SSH y también se muestra al enumerar las claves 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
Solo se admite autenticación de nombre de usuario/contraseña para realizar acciones no relacionadas con repositorios o proyectos en Bitbucket. Debe proporcionar el ID de la clave SSH a eliminar. Este ID se muestra al crear la clave SSH y también se muestra al enumerar las claves 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.
### Listar estadísticas de administración
#### Caso de uso
> *Listar estadísticas de administración en GitHub Enterprise*
#### Sintaxis
Proporcione el módulo `adminstats`, junto con cualquier información de autenticación relevante y URL. Se requiere acceso de administrador del sitio en 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`
#### Salida de ejemplo```
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
Lista las protecciones de rama en GitHub Enterprise
Proporciona el módulo protection, junto con cualquier información de autenticación relevante y la URL. Opcionalmente, proporciona una cadena en el parámetro de opciones para devolver resultados coincidentes contenidos en los nombres de los repositorios.
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
## Detección
A continuación se presentan firmas estáticas para el uso específico de esta herramienta en su estado predeterminado:
* GUID del proyecto - `{266C644A-69B1-426B-A47C-1CF32B211F80}`
* Consulte la [Regla Yara de SCMKit](https://github.com/xforcered/scmkit/blob/main/Detections/SCMKit.yar) en este repositorio.
* Cadena de User Agent - `SCMKIT-5dc493ada400c79dd318abbe770dac7c`
* Consulte la [Regla Snort de SCMKit](https://github.com/xforcered/scmkit/blob/main/Detections/SCMKit.rules) en este repositorio.
* Nombres de token de acceso y claves SSH: los tokens de acceso y las claves SSH que se crean con la herramienta llevan el prefijo `SCMKIT-` en el nombre.
Para obtener orientación sobre la detección de las técnicas utilizadas por la herramienta, consulte la [publicación de blog](https://securityintelligence.com/posts/abusing-source-code-management-systems) de X-Force Red.
## Referencias
* Documentación de la API de Bitbucket
* https://developer.atlassian.com/server/bitbucket/reference/rest-api/
* Documentación de Octokit
* https://octokitnet.readthedocs.io/en/latest/
* https://github.com/octokit/octokit.net
* Documentación de la API de GitHub
* https://docs.github.com/en/rest/overview
* Documentación de la API de GitLab
* https://docs.gitlab.com/ee/api/api_resources.html
* Documentación del paquete Nuget GitLabApiClient
* https://github.com/nmklotas/GitLabApiClient
| Biblioteca | URL | Licencia |
|---|
| 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 |
| Escenario de Ataque | Módulo | ¿Requiere Admin? | GitHub Enterprise | GitLab Enterprise | Bitbucket Server |
|---|
| Reconocimiento | listrepo | No | X | X | X |
| Reconocimiento | searchrepo | No | X | X | X |
| Reconocimiento | searchcode | No | X | X | X |
| Reconocimiento | searchfile | No | X | X | X |
| Reconocimiento | listsnippet | No | X | ||
| Reconocimiento | listrunner | No | X | ||
| Reconocimiento | listgist | No | X | ||
| Reconocimiento | listorg | No | X | ||
| Reconocimiento | privs | No | X | X | |
| Reconocimiento | protection | No | X | ||
| Persistencia | listsshkey | No | X | X | X |
| Persistencia | removesshkey | No | X | X | X |
| Persistencia | createsshkey | No | X | X | X |
| Persistencia | listpat | No | X | X | |
| Persistencia | removepat | No | X | X | |
| Persistencia | createpat | Sí (solo GitLab Enterprise) | X | X | |
| Escalada de Privilegios | addadmin | Sí | X | X | X |
| Escalada de Privilegios | removeadmin | Sí | X | X | X |
| Reconocimiento | adminstats | Sí | X |