
Toolkit di attacco per la gestione del codice sorgente
Source Code Management Attack Toolkit - SCMKit è un toolkit che può essere utilizzato per attaccare i sistemi SCM. SCMKit consente all'utente di specificare il sistema SCM e il modulo di attacco da utilizzare, oltre a specificare credenziali valide (username/password o chiave API) per il rispettivo sistema SCM. Attualmente, i sistemi SCM supportati da SCMKit sono GitHub Enterprise, GitLab Enterprise e Bitbucket Server. I moduli di attacco supportati includono ricognizione, escalation dei privilegi e persistenza. SCMKit è stato sviluppato con un approccio modulare, così che nuovi moduli e sistemi SCM possano essere aggiunti in futuro dalla community di sicurezza informatica.
Le seguenti librerie di terze parti sono utilizzate in questo progetto.
Segui i passaggi seguenti per configurare Visual Studio e compilare il progetto da solo. Questo richiede una libreria .NET che può essere installata dal gestore pacchetti NuGet.
https://api.nuget.org/v3/index.jsonInstall-Package Costura.Fody -Version 3.3.3Install-Package OctokitInstall-Package GitLabApiClientInstall-Package Newtonsoft.JsonLa tabella seguente mostra dove ogni modulo è supportato
Scopri i repository utilizzati in un particolare sistema SCM
Fornisci il modulo listrepo, insieme alle informazioni di autenticazione rilevanti e all'URL. Questo restituirà il nome del repository e l'URL.
Questo elencherà tutti i repository che un utente può vedere.
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
Questo elencherà tutti i repository che un utente può vedere.
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
Questo elencherà tutti i repository che un utente può vedere.
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
### Cerca Repository
#### Caso d'uso
> *Cerca repository per nome del repository in uno specifico sistema SCM*
#### Sintassi
Fornisci il modulo `searchrepo` e i tuoi criteri di ricerca nell'opzione della riga di comando `-o`, insieme a eventuali informazioni di autenticazione pertinenti e all'URL. L'output includerà il nome e l'URL del repository corrispondente.
##### GitHub Enterprise
La ricerca dei repository di GitHub è una ricerca di tipo "contiene", in cui la stringa inserita cercherà repository con nomi che contengono il termine di ricerca.
`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 ricerca dei repository di GitLab è una ricerca di tipo "contiene", in cui la stringa inserita cercherà repository con nomi che contengono il termine di ricerca.
`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 ricerca dei repository di Bitbucket è una ricerca di tipo "inizia con", in cui la stringa inserita cercherà repository con nomi che iniziano con il termine di ricerca.
`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"`
#### Esempio di output```
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
Cerca il codice contenente una determinata parola chiave in un particolare sistema SCM
Fornisci il modulo searchcode e i criteri di ricerca nell'opzione da riga di comando -o, insieme a eventuali informazioni di autenticazione e URL. Verrà restituito l'URL del file di codice corrispondente, insieme alla riga del codice che corrisponde.
La ricerca del codice di GitHub è una ricerca "contiene" in cui la stringa inserita cercherà il codice che contiene il termine di ricerca in qualsiasi riga.
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 ricerca del codice di GitLab è una ricerca "contiene" in cui la stringa inserita cercherà il codice che contiene il termine di ricerca in qualsiasi riga.
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 ricerca del codice di Bitbucket è una ricerca "contiene" in cui la stringa inserita cercherà il codice che contiene il termine di ricerca in qualsiasi riga.
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
### Ricerca File
#### Caso d'uso
> *Cerca file nei repository che contengono una determinata parola chiave nel nome del file in un particolare sistema SCM*
#### Sintassi
Fornisci il modulo `searchfile` e i tuoi criteri di ricerca nell'opzione della riga di comando `-o`, insieme alle eventuali informazioni di autenticazione e URL pertinenti. Questo restituirà l'URL del file corrispondente nel rispettivo repository.
##### GitHub Enterprise
La ricerca file di GitLab è una ricerca di tipo "contains": la stringa che inserisci cercherà i file che contengono il termine di ricerca nel nome del file.
`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 ricerca file di GitLab è una ricerca di tipo "contains": la stringa che inserisci cercherà i file che contengono il termine di ricerca nel nome del file.
`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 ricerca file di Bitbucket è una ricerca di tipo "contains": la stringa che inserisci cercherà i file che contengono il termine di ricerca nel nome del file.
`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"`
#### Output di esempio```
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
Elenca gli snippet di proprietà dell'utente corrente in GitLab
Fornire il modulo listsnippet, insieme a tutte le informazioni di autenticazione e all'URL pertinenti.
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
### Elenca i runner
#### Caso d'uso
> *Elenca tutti i runner GitLab disponibili per l'utente corrente in GitLab*
#### Sintassi
Fornisci il modulo `listrunner`, insieme a qualsiasi informazione di autenticazione rilevante e all'URL. Se l'utente è un amministratore, sarà possibile elencare tutti i runner all'interno dell'istanza GitLab Enterprise, inclusi i runner condivisi e di gruppo.
##### 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`
#### Output di esempio```
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
Elenca i gist di proprietà dell'utente corrente su GitHub
Fornisci il modulo listgist, insieme a qualsiasi informazione di autenticazione rilevante e 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
### Elenca organizzazioni
#### Caso d'uso
> *Elenca tutte le organizzazioni a cui appartiene l'utente corrente in GitHub*
#### Sintassi
Fornire il modulo `listorg`, insieme alle relative informazioni di autenticazione e URL.
##### GitHub Enterprise
`SCMKit.exe -s github -m listorg -c userName:password -u https://github.something.local`
`SCMKit.exe -s github -m listorg -c apiKey -u https://github.something.local`
#### Output di esempio```
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
Ottieni i privilegi assegnati a un token di accesso utilizzato in un particolare sistema SCM
Fornisci il modulo privs, insieme a una chiave API e a un 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.
### Aggiungi Amministratore
#### Caso d'uso
> *Promuovi un utente normale a un ruolo amministrativo in un particolare sistema SCM*
#### Sintassi
Fornire il modulo `addadmin`, insieme alle informazioni di autenticazione rilevanti e all'URL. Inoltre, fornire l'utente target a cui si desidera aggiungere un ruolo amministrativo.
##### 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
In Bitbucket è supportata solo l'autenticazione con nome utente/password per eseguire azioni non relative a repository o progetti.
`SCMKit.exe -s bitbucket -m addadmin -c userName:password -u https://bitbucket.something.local -o targetUserName`
#### Output di esempio```
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.
Declassa un utente amministrativo a un ruolo di utente normale in un particolare sistema SCM
Fornisci il modulo removeadmin, insieme a qualsiasi informazione di autenticazione pertinente e all'URL. Inoltre, fornisci l'utente target a cui desideri rimuovere un ruolo amministrativo.
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 l'autenticazione con nome utente/password è supportata per eseguire azioni non relative a repo o progetti in 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.
### Crea token di accesso
#### Caso d'uso
> *Crea un token di accesso da utilizzare in un particolare sistema SCM*
#### Sintassi
Fornisci il modulo `createpat`, insieme a qualsiasi informazione di autenticazione pertinente e all'URL. Inoltre, fornisci l'utente target per cui desideri creare un token di accesso.
##### GitLab Enterprise
Questa operazione può essere eseguita solo come amministratore. Fornisci il nome utente per cui desideri creare 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 per l'utente corrente che si sta autenticando. In Bitbucket non puoi creare un PAT per un altro utente, nemmeno come amministratore. Solo l'autenticazione con nome utente/password è supportata per eseguire azioni non relative a repository o progetti in Bitbucket. Prendi nota dell'ID PAT visualizzato dopo la creazione. Ti servirà quando in futuro dovrai rimuovere il PAT.
`SCMKit.exe -s bitbucket -m createpat -c userName:password -u https://bitbucket.something.local `
#### Output di esempio```
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.
Elenca i token di accesso di un utente su un particolare sistema SCM
Fornire il modulo listpat, insieme a tutte le informazioni di autenticazione pertinenti e all'URL.
Richiede privilegi di amministratore solo se si desidera elencare i PAT di un altro utente. Un utente normale può elencare i propri 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
Elenca i token di accesso per l'utente corrente. Per eseguire azioni non correlate a repository o progetti in Bitbucket, è supportata solo l'autenticazione tramite nome utente/password.
SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local
Elenca i token di accesso per un altro utente (richiede privilegi di amministratore). Per eseguire azioni non correlate a repository o progetti in Bitbucket, è supportata solo l'autenticazione tramite nome utente/password.
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
### Rimuovi token di accesso
#### Caso d'uso
> *Rimuove un token di accesso per un utente in un particolare sistema SCM*
#### Sintassi
Fornisci il modulo `removepat`, insieme alle informazioni di autenticazione rilevanti e all'URL. Inoltre, fornisci l'ID PAT dell'utente target per cui desideri rimuovere un token di accesso.
##### GitLab Enterprise
Richiede privilegi di amministratore solo se vuoi rimuovere il PAT di un altro utente. Un utente normale può rimuovere il proprio PAT. Devi fornire l'ID PAT da rimuovere. Questo ID veniva mostrato ogni volta che creavi il PAT e anche quando elencavi i 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
Per eseguire azioni non correlate a repository o progetti in Bitbucket è supportata solo l'autenticazione con nome utente/password. Devi fornire l'ID PAT da rimuovere. Questo ID veniva mostrato quando creavi il PAT.
`SCMKit.exe -s bitbucket -m removepat -c userName:password -u https://bitbucket.something.local -o patID`
#### Output di esempio```
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.
Crea una chiave SSH da utilizzare in un particolare sistema SCM
Fornire il modulo createsshkey, insieme a qualsiasi informazione di autenticazione e URL pertinenti.
Crea una chiave SSH per l'utente corrente che si autentica.
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 chiave SSH per l'utente corrente che si autentica. Prendi nota dell'ID della chiave SSH mostrato dopo la creazione. Ti servirà quando dovrai rimuovere la chiave SSH in 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 chiave SSH per l'utente corrente che si autentica. Per eseguire azioni non correlate a repo o progetti in Bitbucket è supportata solo l'autenticazione con nome utente/password. Prendi nota dell'ID della chiave SSH mostrato dopo la creazione. Ti servirà quando dovrai rimuovere la chiave SSH in 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.
### Elenca chiavi SSH
#### Caso d'uso
> *Elenca le chiavi SSH di un utente su un particolare sistema SCM*
#### Sintassi
Fornisci il modulo `listsshkey`, insieme alle informazioni di autenticazione pertinenti e all'URL.
##### GitHub Enterprise
Elenca le chiavi SSH dell'utente corrente. Questo includerà gli ID delle chiavi SSH, necessari quando si desidera rimuovere una chiave 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
Elenca le chiavi SSH dell'utente corrente.
`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
Elenca le chiavi SSH dell'utente corrente. In Bitbucket, per eseguire azioni non correlate a repository o progetti, è supportata solo l'autenticazione con nome utente/password.
`SCMKit.exe -s bitbucket -m listsshkey -c userName:password -u https://bitbucket.something.local`
#### Output di esempio```
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
Rimuovi una chiave SSH per un utente in un particolare sistema SCM
Fornisci il modulo removesshkey, insieme a tutte le informazioni di autenticazione pertinenti e all'URL. Inoltre, fornisci l'ID della chiave SSH dell'utente da rimuovere.
Devi fornire l'ID della chiave SSH da rimuovere. Questo ID veniva mostrato ogni volta che elenchi le chiavi 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
Devi fornire l'ID della chiave SSH da rimuovere. Questo ID veniva mostrato quando creavi la chiave SSH e viene mostrato anche quando elenchi le chiavi 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
Per eseguire azioni non correlate a repo o progetti in Bitbucket è supportata solo l'autenticazione con nome utente/password. Devi fornire l'ID della chiave SSH da rimuovere. Questo ID veniva mostrato quando creavi la chiave SSH e viene mostrato anche quando elenchi le chiavi 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.
### Elenca le statistiche admin
#### Caso d'uso
> *Elenca le statistiche admin in GitHub Enterprise*
#### Sintassi
Fornisci il modulo `adminstats`, insieme alle informazioni di autenticazione pertinenti e all'URL. Per utilizzare questo modulo è richiesto l'accesso come amministratore del sito in GitHub Enterprise.
##### GitHub Enterprise
`SCMKit.exe -s github -m adminstats -c userName:password -u https://github.something.local`
`SCMKit.exe -s github -m adminstats -c apikey -u https://github.something.local`
#### Output di esempio```
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
Elenca le protezioni dei rami in GitHub Enterprise
Fornisci il modulo protection, insieme a qualsiasi informazione di autenticazione pertinente e URL. Opzionalmente, fornisci una stringa nel parametro delle opzioni per restituire risultati corrispondenti contenuti nei nomi dei repository.
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
## Detection
Di seguito sono riportate le firme statiche per l'utilizzo specifico di questo strumento nel suo stato predefinito:
* GUID del progetto - `{266C644A-69B1-426B-A47C-1CF32B211F80}`
* Vedi [SCMKit Yara Rule](https://github.com/xforcered/scmkit/blob/HEAD/Detections/SCMKit.yar) in questo repository.
* Stringa User Agent - `SCMKIT-5dc493ada400c79dd318abbe770dac7c`
* Vedi [SCMKit Snort Rule](https://github.com/xforcered/scmkit/blob/HEAD/Detections/SCMKit.rules) in questo repository.
* Nomi di token di accesso e chiavi SSH - I token di accesso e le chiavi SSH creati utilizzando lo strumento hanno il nome preceduto da `SCMKIT-`.
Per una guida al rilevamento delle tecniche utilizzate dallo strumento, consulta il [post del blog](https://securityintelligence.com/posts/abusing-source-code-management-systems) di X-Force Red.
## Riferimenti
* Documentazione API Bitbucket
* https://developer.atlassian.com/server/bitbucket/reference/rest-api/
* Documentazione Octokit
* https://octokitnet.readthedocs.io/en/latest/
* https://github.com/octokit/octokit.net
* Documentazione API GitHub
* https://docs.github.com/en/rest/overview
* Documentazione API GitLab
* https://docs.gitlab.com/ee/api/api_resources.html
* Documentazione del pacchetto Nuget GitLabApiClient
* https://github.com/nmklotas/GitLabApiClient
| Libreria | URL | Licenza |
|---|
| 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 |
| Scenario di Attacco | Modulo | Richiede Admin? | GitHub Enterprise | GitLab Enterprise | Bitbucket Server |
|---|
| Ricognizione | listrepo | No | X | X | X |
| Ricognizione | searchrepo | No | X | X | X |
| Ricognizione | searchcode | No | X | X | X |
| Ricognizione | searchfile | No | X | X | X |
| Ricognizione | listsnippet | No | X | ||
| Ricognizione | listrunner | No | X | ||
| Ricognizione | listgist | No | X | ||
| Ricognizione | listorg | No | X | ||
| Ricognizione | privs | No | X | X | |
| Ricognizione | protection | No | X | ||
| Persistenza | listsshkey | No | X | X | X |
| Persistenza | removesshkey | No | X | X | X |
| Persistenza | createsshkey | No | X | X | X |
| Persistenza | listpat | No | X | X | |
| Persistenza | removepat | No | X | X | |
| Persistenza | createpat | Sì (solo GitLab Enterprise) | X | X | |
| Escalation dei Privilegi | addadmin | Sì | X | X | X |
| Escalation dei Privilegi | removeadmin | Sì | X | X | X |
| Ricognizione | adminstats | Sì | X |