
Toolkit di attacco per la gestione del codice sorgente
Source Code Management Attack Toolkit - SCMKit è un toolkit che può essere utilizzato per attaccare sistemi SCM. SCMKit permette all'utente di specificare il sistema SCM e il modulo di attacco da utilizzare, insieme alla specifica di 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 costruito con un approccio modulare, in modo che nuovi moduli e sistemi SCM possano essere aggiunti in futuro dalla comunità della sicurezza informatica.
Le seguenti librerie di terze parti sono utilizzate in questo progetto.
Segui i passaggi seguenti per configurare Visual Studio al fine di compilare il progetto da te. Ciò 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
Scoprire i repository utilizzati in un particolare sistema SCM
Fornisci il modulo listrepo, insieme alle informazioni di autenticazione pertinenti e all'URL. Verranno restituiti 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 un particolare sistema SCM*
#### Sintassi
Fornisci il modulo `searchrepo` e i criteri di ricerca nell'opzione `-o` da riga di comando, insieme a tutte le informazioni di autenticazione e URL pertinenti. Questo restituirà il nome del repository corrispondente e l'URL.
##### GitHub Enterprise
La ricerca dei repository di GitHub è una ricerca "contiene" in cui la stringa che inserisci cercherà repository con nomi che contengono il tuo 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 "contiene" in cui la stringa che inserisci cercherà repository con nomi che contengono il tuo 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 "inizia con" in cui la stringa che inserisci cercherà repository con nomi che iniziano con il tuo 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"`
#### Output di Esempio```
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
Ricerca di codice contenente una determinata parola chiave in uno specifico sistema SCM
Fornisci il modulo searchcode e i tuoi criteri di ricerca nell'opzione -o della riga di comando, insieme a eventuali informazioni di autenticazione e URL pertinenti. Questo restituirà l'URL del file di codice corrispondente, insieme alla riga del codice che corrisponde.
La ricerca del codice su 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 su 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 su 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
### Cerca file
#### Caso d'uso
> *Cerca file nei repository che contengono una parola chiave specificata nel nome del file in un particolare sistema SCM*
#### Sintassi
Fornisci il modulo `searchfile` e i criteri di ricerca nell'opzione `-o` da riga di comando, insieme a eventuali informazioni di autenticazione e URL. Verrà restituito l'URL del file corrispondente nel suo repository.
##### GitHub Enterprise
La ricerca file di GitLab è una ricerca "contiene" in cui la stringa inserita cercherà 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 "contiene" in cui la stringa inserita cercherà 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 "contiene" in cui la stringa inserita cercherà 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"`
#### Esempio di output```
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 posseduti dall'utente corrente in GitLab
Fornisci il modulo listsnippet, insieme a qualsiasi informazione di autenticazione rilevante e URL.
SCMKit.exe -s gitlab -m listsnippet -c userName:password -u https://gitlab.something.local
SCMKit.exe -s gitlab -m listsnippet -c apikey -u https://gitlab.something.local
C:>SCMKit.exe -s gitlab -m listsnippet -c username:password -u https://gitlab.hogwarts.local
================================================== Module: listsnippet System: gitlab Auth Type: Username/Password Options: Target URL: https://gitlab.hogwarts.local
Title | Raw URL
spell-script | https://gitlab.hogwarts.local/-/snippets/2/raw
### Elenca Runner
#### Caso d'Uso
> *Elenca tutti i runner GitLab disponibili per l'utente corrente in GitLab*
#### Sintassi
Fornisci il modulo `listrunner`, insieme a tutte le informazioni di autenticazione e URL pertinenti. 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`
#### Esempio di Output```
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
Elenco dei gist posseduti dall'utente corrente su GitHub
Fornisci il modulo listgist, insieme a tutte le informazioni di autenticazione e URL pertinenti.
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 Org
#### Caso d'uso
> *Elenca tutte le organizzazioni di cui l'utente corrente è membro in GitHub*
#### Sintassi
Fornisci il modulo `listorg`, insieme a eventuali 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 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
Fornisci il modulo `addadmin`, insieme a tutte le informazioni di autenticazione e l'URL pertinenti. Inoltre, fornisci l'utente target a cui desideri 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
Solo l'autenticazione con nome utente/password è supportata per eseguire azioni non relative a repository o progetti in Bitbucket.
`SCMKit.exe -s bitbucket -m addadmin -c userName:password -u https://bitbucket.something.local -o targetUserName`
#### Esempio di Output```
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.
Declassare un utente amministratore a un normale utente in un particolare sistema SCM
Fornisci il modulo removeadmin, insieme alle informazioni di autenticazione e all'URL pertinenti. Inoltre, specifica l'utente target a cui rimuovere il ruolo di amministratore.
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 username/password è supportata per eseguire azioni non relative a repository 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.
### Creare un 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 eventuali informazioni di autenticazione e URL pertinenti. Inoltre, fornisci l'utente di destinazione per cui desideri creare un token di accesso.
##### GitLab Enterprise
Questa operazione può essere eseguita solo da un amministratore. Dovrai fornire 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 è possibile 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 del PAT che viene mostrato dopo la creazione. Ti servirà quando dovrai rimuovere il PAT in futuro.
`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 per un utente su un particolare sistema SCM
Fornisci il modulo listpat, insieme alle informazioni di autenticazione pertinenti e all'URL.
Richiede l'admin solo se si vogliono 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. Solo l'autenticazione con nome utente/password è supportata per eseguire azioni non relative a repository o progetti in Bitbucket.
SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local
Elenca i token di accesso per un altro utente (richiede admin). Solo l'autenticazione con nome utente/password è supportata per eseguire azioni non relative a repository o progetti in 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
### Rimuovi Token di Accesso
#### Caso d'Uso
> *Rimuovi un token di accesso per un utente in un particolare sistema SCM*
#### Sintassi
Fornisci il modulo `removepat`, insieme a qualsiasi informazione di autenticazione rilevante e URL. Inoltre, fornisci l'ID PAT dell'utente target per cui desideri rimuovere un token di accesso.
##### GitLab Enterprise
Richiede solo l'admin se si desidera 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
Solo l'autenticazione username/password è supportata per eseguire azioni non relative a repository o progetti in Bitbucket. Devi fornire l'ID PAT da rimuovere. Questo ID veniva mostrato ogni volta che creavi il PAT.
`SCMKit.exe -s bitbucket -m removepat -c userName:password -u https://bitbucket.something.local -o patID`
#### Esempio di Output```
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.
Creare una chiave SSH da utilizzare in un particolare sistema SCM
Fornire il modulo createsshkey, insieme alle informazioni di autenticazione pertinenti e all'URL.
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 che viene 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. Solo l'autenticazione con nome utente/password è supportata per eseguire azioni non relative ai repository o ai progetti in Bitbucket. Prendi nota dell'ID della chiave SSH che viene 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 le chiavi SSH
#### Caso d'uso
> *Elenca le chiavi SSH per un utente su un particolare sistema SCM*
#### Sintassi
Fornisci il modulo `listsshkey`, insieme a qualsiasi informazione di autenticazione e URL pertinenti.
##### GitHub Enterprise
Elenca le chiavi SSH per l'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 per l'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 per l'utente corrente. Solo l'autenticazione con nome utente/password è supportata per eseguire azioni non relative a repository o progetti in Bitbucket.
`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 qualsiasi informazione di autenticazione e URL pertinenti. Inoltre, fornisci l'ID della chiave SSH dell'utente target da rimuovere.
Devi fornire l'ID della chiave SSH da rimuovere. Questo ID viene 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 viene mostrato ogni volta che crei la chiave SSH ed è anche mostrato 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
Solo l'autenticazione username/password è supportata per eseguire azioni non relative a repository o progetti in Bitbucket. Devi fornire l'ID della chiave SSH da rimuovere. Questo ID viene mostrato ogni volta che crei la chiave SSH ed è anche mostrato 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 di amministrazione
#### Caso d'uso
> *Elenca le statistiche di amministrazione in GitHub Enterprise*
#### Sintassi
Fornisci il modulo `adminstats`, insieme a qualsiasi informazione di autenticazione rilevante e 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`
#### Esempio di output```
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 branch in GitHub Enterprise
Fornisci il modulo protection, insieme alle informazioni di autenticazione e all'URL pertinenti. Opzionalmente, fornisci una stringa nel parametro delle opzioni per restituire risultati corrispondenti contenuti nei nomi dei repo.
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
## Rilevamento
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 la [Regola Yara di SCMKit](https://github.com/h4wkst3r/scmkit/blob/main/Detections/SCMKit.yar) in questo repository.
* Stringa User Agent - `SCMKIT-5dc493ada400c79dd318abbe770dac7c`
* Vedi la [Regola Snort di SCMKit](https://github.com/h4wkst3r/scmkit/blob/main/Detections/SCMKit.rules) in questo repository.
* Nomi dei token di accesso e delle chiavi SSH - I token di accesso e le chiavi SSH creati con lo strumento hanno il prefisso `SCMKIT-` nel nome.
Per una guida al rilevamento delle tecniche utilizzate dallo strumento, consulta l'[articolo 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 | Licenza MIT |
| Fody | https://github.com/Fody/Fody | Licenza MIT |
| GitLabApiClient | https://github.com/nmklotas/GitLabApiClient | Licenza MIT |
| Newtonsoft.Json | https://github.com/JamesNK/Newtonsoft.Json | Licenza MIT |
| 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 |