
عدة هجوم لإدارة الكود المصدري
Source Code Management Attack Toolkit - SCMKit هي مجموعة أدوات يمكن استخدامها لمهاجمة أنظمة SCM. تتيح SCMKit للمستخدم تحديد نظام SCM ووحدة الهجوم لاستخدامها، إلى جانب تحديد بيانات اعتماد صالحة (اسم المستخدم/كلمة المرور أو مفتاح API) لنظام SCM المعني. حاليًا، أنظمة SCM التي تدعمها SCMKit هي GitHub Enterprise وGitLab Enterprise وBitbucket Server. تتضمن وحدات الهجوم المدعومة الاستطلاع وتصعيد الامتيازات والثبات. تم بناء SCMKit بطريقة نمطية، بحيث يمكن إضافة وحدات وأنظمة SCM جديدة في المستقبل من قبل مجتمع أمن المعلومات.
المكتبات الخارجية التالية مستخدمة في هذا المشروع.
اتبع الخطوات التالية لإعداد Visual Studio لترجمة المشروع بنفسك. يتطلب هذا مكتبة .NET يمكن تثبيتها من مدير حزم NuGet.
https://api.nuget.org/v3/index.jsonInstall-Package Costura.Fody -Version 3.3.3Install-Package OctokitInstall-Package GitLabApiClientInstall-Package Newtonsoft.Jsonالجدول التالي يوضح أماكن دعم كل وحدة
اكتشاف المستودعات المستخدمة في نظام SCM معين
قم بتوفير وحدة listrepo، إلى جانب أي معلومات مصادقة ذات صلة والرابط. سيؤدي ذلك إلى إخراج اسم المستودع والرابط.
سيؤدي هذا إلى سرد جميع المستودعات التي يمكن للمستخدم رؤيتها.
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
سيؤدي هذا إلى سرد جميع المستودعات التي يمكن للمستخدم رؤيتها.
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
سيؤدي هذا إلى سرد جميع المستودعات التي يمكن للمستخدم رؤيتها.
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
### البحث عن المستودعات
#### حالة الاستخدام
> *البحث عن المستودعات حسب اسم المستودع في نظام SCM معين*
#### الصيغة
استخدم وحدة `searchrepo` ومعايير البحث الخاصة بك في مفتاح سطر الأوامر `-o`، مع أي معلومات مصادقة ذات صلة وعنوان URL. سيؤدي هذا إلى إخراج اسم المستودع وعنوان URL المطابقين.
##### GitHub Enterprise
بحث مستودعات GitHub هو بحث "يحتوي على" حيث سيبحث النص الذي تدخله عن المستودعات التي تحتوي أسماؤها على مصطلح البحث الخاص بك.
`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
بحث مستودعات GitLab هو بحث "يحتوي على" حيث سيبحث النص الذي تدخله عن المستودعات التي تحتوي أسماؤها على مصطلح البحث الخاص بك.
`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
بحث مستودعات Bitbucket هو بحث "يبدأ بـ" حيث سيبحث النص الذي تدخله عن المستودعات التي تبدأ أسماؤها بمصطلح البحث الخاص بك.
`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"`
#### مثال على الإخراج```
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
البحث عن الكود الذي يحتوي على كلمة مفتاحية معيّنة في نظام SCM معيّن
قم بتوفير وحدة searchcode ومعايير البحث الخاصة بك في مفتاح سطر الأوامر -o، مع أي معلومات مصادقة ذات صلة وعنوان URL. سيؤدي ذلك إلى إخراج عنوان URL لملف الكود المطابق، بالإضافة إلى السطر في الكود الذي طابق البحث.
بحث كود GitHub هو بحث "يحتوي على" حيث أن النص الذي تدخله سيبحث عن كود يحتوي على مصطلح البحث في أي سطر.
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"
بحث كود GitLab هو بحث "يحتوي على" حيث أن النص الذي تدخله سيبحث عن كود يحتوي على مصطلح البحث في أي سطر.
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"
بحث كود Bitbucket هو بحث "يحتوي على" حيث أن النص الذي تدخله سيبحث عن كود يحتوي على مصطلح البحث في أي سطر.
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
### البحث عن الملفات
#### حالة الاستخدام
> *البحث عن الملفات في المستودعات التي تحتوي على كلمة مفتاحية معيّنة في اسم الملف داخل نظام SCM معيّن*
#### الصيغة
قم بتوفير وحدة `searchfile` ومعايير البحث الخاصة بك في مفتاح سطر الأوامر `-o`، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL. سيؤدي ذلك إلى إخراج عنوان URL للملف المطابق في مستودعه.
##### GitHub Enterprise
بحث ملفات GitLab هو بحث "يحتوي على" حيث السلسلة التي تدخلها ستقوم بالبحث عن الملفات التي تحتوي على مصطلح البحث الخاص بك في اسم الملف.
`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
بحث ملفات GitLab هو بحث "يحتوي على" حيث السلسلة التي تدخلها ستقوم بالبحث عن الملفات التي تحتوي على مصطلح البحث الخاص بك في اسم الملف.
`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
بحث ملفات Bitbucket هو بحث "يحتوي على" حيث السلسلة التي تدخلها ستقوم بالبحث عن الملفات التي تحتوي على مصطلح البحث الخاص بك في اسم الملف.
`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"`
#### مثال على المخرجات```
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
سرد المقتطفات المملوكة من قبل المستخدم الحالي في GitLab
قدّم وحدة listsnippet، مع أي معلومات مصادقة ذات صلة وعنوان 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
### سرد العدائين
#### حالة الاستخدام
> *سرد جميع عدائي GitLab المتاحين للمستخدم الحالي في GitLab*
#### الصيغة
قم بتوفير وحدة `listrunner`، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL. إذا كان المستخدم مسؤولًا، فستتمكن من سرد جميع العدائين داخل مثيل GitLab Enterprise، بما في ذلك العدائين المشتركين وعدائي المجموعات.
##### 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`
#### مثال على الإخراج```
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
قائمة بالـ gists المملوكة للمستخدم الحالي في GitHub
قم بتوفير وحدة listgist، إلى جانب أي معلومات مصادقة ذات صلة وعنوان 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
### قائمة المؤسسات
#### حالة الاستخدام
> *سرد جميع المؤسسات التي ينتمي إليها المستخدم الحالي في GitHub*
#### الصيغة
قم بتوفير وحدة `listorg`، بالإضافة إلى أي معلومات مصادقة ذات صلة وعنوان 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`
#### مثال للإخراج```
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
احصل على الصلاحيات المخصصة لرمز الوصول المستخدم في نظام SCM معين
قم بتوفير وحدة privs، إلى جانب مفتاح API وعنوان 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.
### إضافة مسؤول
#### حالة الاستخدام
> *ترقية مستخدم عادي إلى دور إداري في نظام SCM معيّن*
#### الصيغة
قم بتوفير الوحدة `addadmin`، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL. بالإضافة إلى ذلك، قم بتوفير المستخدم الهدف الذي ترغب في إضافة دور إداري له.
##### 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
يُدعم فقط مصادقة اسم المستخدم/كلمة المرور لتنفيذ الإجراءات غير المتعلقة بالمستودعات أو المشاريع في Bitbucket.
`SCMKit.exe -s bitbucket -m addadmin -c userName:password -u https://bitbucket.something.local -o targetUserName`
#### مثال على الإخراج```
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.
خفض دور مستخدم إداري إلى دور مستخدم عادي في نظام SCM معين
قم بتوفير وحدة removeadmin، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL. بالإضافة إلى ذلك، قم بتوفير المستخدم المستهدف الذي تريد إزالة الدور الإداري منه.
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
تُدعم فقط مصادقة اسم المستخدم/كلمة المرور لتنفيذ الإجراءات غير المتعلقة بالمستودعات أو المشاريع في 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.
### إنشاء رمز وصول
#### حالة الاستخدام
> *إنشاء رمز وصول لاستخدامه في نظام SCM معين*
#### الصيغة
قم بتوفير وحدة `createpat`، بالإضافة إلى أي معلومات مصادقة ذات صلة وعنوان URL. بالإضافة إلى ذلك، قم بتوفير المستخدم الهدف الذي تريد إنشاء رمز وصول له.
##### GitLab Enterprise
لا يمكن تنفيذ هذا إلا بواسطة مسؤول. ستقوم بتوفير اسم المستخدم الذي تريد إنشاء 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
يقوم بإنشاء PAT للمستخدم الحالي الذي يقوم بالمصادقة. في Bitbucket، لا يمكنك إنشاء PAT لمستخدم آخر، حتى كمسؤول. يتم دعم مصادقة اسم المستخدم/كلمة المرور فقط لتنفيذ الإجراءات غير المتعلقة بالمستودعات أو المشاريع في Bitbucket. لاحظ معرف PAT الذي يظهر بعد إنشائه. ستحتاج إليه عندما تحتاج إلى إزالة PAT في المستقبل.
`SCMKit.exe -s bitbucket -m createpat -c userName:password -u https://bitbucket.something.local `
#### مثال على المخرجات```
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.
سرد رموز الوصول لمستخدم على نظام SCM معين
قم بتقديم وحدة listpat، بالإضافة إلى أي معلومات مصادقة ذات صلة وعنوان URL.
يتطلب صلاحيات المسؤول فقط إذا كنت تريد سرد رموز PAT لمستخدم آخر. يمكن للمستخدم العادي سرد رموز 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
سرد رموز الوصول للمستخدم الحالي. يتم دعم مصادقة اسم المستخدم/كلمة المرور فقط لتنفيذ الإجراءات غير المتعلقة بالمستودعات أو المشاريع في Bitbucket.
SCMKit.exe -s bitbucket -m listpat -c userName:password -u https://bitbucket.something.local
سرد رموز الوصول لمستخدم آخر (يتطلب صلاحيات المسؤول). يتم دعم مصادقة اسم المستخدم/كلمة المرور فقط لتنفيذ الإجراءات غير المتعلقة بالمستودعات أو المشاريع في 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
### إزالة رمز الوصول
#### حالة الاستخدام
> *إزالة رمز وصول لمستخدم في نظام SCM معيّن*
#### الصيغة
وفّر وحدة `removepat`، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL. بالإضافة إلى ذلك، وفّر معرّف PAT الخاص بالمستخدم المستهدف الذي ترغب في إزالة رمز الوصول له.
##### GitLab Enterprise
لا يتطلب صلاحيات المسؤول إلا إذا كنت تريد إزالة PAT لمستخدم آخر. يمكن للمستخدم العادي إزالة PAT الخاص به. يجب عليك توفير معرّف PAT المراد إزالته. يظهر هذا المعرّف عند إنشاء PAT وأيضًا عند سرد 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
يُدعم فقط مصادقة اسم المستخدم/كلمة المرور لتنفيذ إجراءات لا تتعلق بالمستودعات أو المشاريع في Bitbucket. يجب عليك توفير معرّف PAT المراد إزالته. يظهر هذا المعرّف عند إنشاء PAT.
`SCMKit.exe -s bitbucket -m removepat -c userName:password -u https://bitbucket.something.local -o patID`
#### مثال على المخرجات```
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.
إنشاء مفتاح SSH ليُستخدم في نظام SCM معيّن
قم بتوفير وحدة createsshkey، بالإضافة إلى أي معلومات مصادقة ذات صلة وعنوان URL.
ينشئ مفتاح SSH للمستخدم الحالي الذي تتم المصادقة باسمه.
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"
ينشئ مفتاح SSH للمستخدم الحالي الذي تتم المصادقة باسمه. لاحظ معرّف مفتاح SSH الذي يظهر بعد إنشائه. ستحتاج إليه عندما تحتاج إلى إزالة مفتاح SSH في المستقبل.
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"
ينشئ مفتاح SSH للمستخدم الحالي الذي تتم المصادقة باسمه. يُدعم فقط مصادقة اسم المستخدم/كلمة المرور لتنفيذ الإجراءات غير المتعلقة بالمستودعات أو المشاريع في Bitbucket. لاحظ معرّف مفتاح SSH الذي يظهر بعد إنشائه. ستحتاج إليه عندما تحتاج إلى إزالة مفتاح SSH في المستقبل.
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.
### قائمة مفاتيح SSH
#### حالة الاستخدام
> *سرد مفاتيح SSH لمستخدم على نظام SCM معين*
#### الصيغة
قم بتوفير وحدة `listsshkey`، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL.
##### GitHub Enterprise
سرد مفاتيح SSH للمستخدم الحالي. سيتضمن ذلك معرّفات مفاتيح SSH، والتي تكون مطلوبة عندما تريد إزالة مفتاح 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
سرد مفاتيح SSH للمستخدم الحالي.
`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
سرد مفاتيح SSH للمستخدم الحالي. يتم دعم مصادقة اسم المستخدم/كلمة المرور فقط لتنفيذ الإجراءات غير المتعلقة بالمستودعات أو المشاريع في Bitbucket.
`SCMKit.exe -s bitbucket -m listsshkey -c userName:password -u https://bitbucket.something.local`
#### مثال على الإخراج```
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
إزالة مفتاح SSH لمستخدم في نظام SCM معين
قم بتوفير وحدة removesshkey، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL. بالإضافة إلى ذلك، قم بتوفير معرّف مفتاح SSH للمستخدم الهدف لإزالته.
يجب عليك توفير معرّف مفتاح SSH المراد إزالته. يتم عرض هذا المعرّف عندما تقوم بسرد مفاتيح 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
يجب عليك توفير معرّف مفتاح SSH المراد إزالته. يتم عرض هذا المعرّف عندما تقوم بإنشاء مفتاح SSH ويظهر أيضًا عند سرد مفاتيح 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
يتم دعم مصادقة اسم المستخدم/كلمة المرور فقط لتنفيذ إجراءات غير متعلقة بالمستودعات أو المشاريع في Bitbucket. يجب عليك توفير معرّف مفتاح SSH المراد إزالته. يتم عرض هذا المعرّف عندما تقوم بإنشاء مفتاح SSH ويظهر أيضًا عند سرد مفاتيح 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.
### قائمة إحصائيات المسؤول
#### حالة الاستخدام
> *سرد إحصائيات المسؤول في GitHub Enterprise*
#### الصيغة
قم بتوفير وحدة `adminstats`، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL. يلزم الوصول كمسؤول موقع في 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`
#### مثال على الإخراج```
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
سرد حماية الفروع في GitHub Enterprise
قم بتوفير وحدة protection، إلى جانب أي معلومات مصادقة ذات صلة وعنوان URL. اختياريًا، يمكنك توفير سلسلة نصية في معامل الخيارات لإرجاع النتائج المطابقة الموجودة في أسماء المستودعات.
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
## الكشف
فيما يلي توقيعات ثابتة للاستخدام المحدد لهذه الأداة في حالتها الافتراضية:
* GUID المشروع - `{266C644A-69B1-426B-A47C-1CF32B211F80}`
* انظر [قاعدة Yara الخاصة بـ SCMKit](https://github.com/xforcered/scmkit/blob/main/Detections/SCMKit.yar) في هذا المستودع.
* سلسلة وكيل المستخدم - `SCMKIT-5dc493ada400c79dd318abbe770dac7c`
* انظر [قاعدة Snort الخاصة بـ SCMKit](https://github.com/xforcered/scmkit/blob/main/Detections/SCMKit.rules) في هذا المستودع.
* أسماء رموز الوصول ومفاتيح SSH - رموز الوصول ومفاتيح SSH التي يتم إنشاؤها باستخدام الأداة تسبق أسماؤها بـ `SCMKIT-`.
للحصول على إرشادات الكشف عن التقنيات التي تستخدمها الأداة، راجع [منشور المدونة](https://securityintelligence.com/posts/abusing-source-code-management-systems) الخاص بـ X-Force Red.
## المراجع
* توثيق Bitbucket API
* https://developer.atlassian.com/server/bitbucket/reference/rest-api/
* توثيق Octokit
* https://octokitnet.readthedocs.io/en/latest/
* https://github.com/octokit/octokit.net
* توثيق GitHub API
* https://docs.github.com/en/rest/overview
* توثيق GitLab API
* https://docs.gitlab.com/ee/api/api_resources.html
* توثيق حزمة Nuget الخاصة بـ GitLabApiClient
* https://github.com/nmklotas/GitLabApiClient
| المكتبة | الرابط | الترخيص |
|---|
| 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 |
| سيناريو الهجوم | الوحدة | يتطلب مسؤول؟ | GitHub Enterprise | GitLab Enterprise | Bitbucket Server |
|---|
| استطلاع | listrepo | لا | X | X | X |
| استطلاع | searchrepo | لا | X | X | X |
| استطلاع | searchcode | لا | X | X | X |
| استطلاع | searchfile | لا | X | X | X |
| استطلاع | listsnippet | لا | X | ||
| استطلاع | listrunner | لا | X | ||
| استطلاع | listgist | لا | X | ||
| استطلاع | listorg | لا | X | ||
| استطلاع | privs | لا | X | X | |
| استطلاع | protection | لا | X | ||
| ثبات | listsshkey | لا | X | X | X |
| ثبات | removesshkey | لا | X | X | X |
| ثبات | createsshkey | لا | X | X | X |
| ثبات | listpat | لا | X | X | |
| ثبات | removepat | لا | X | X | |
| ثبات | createpat | نعم (لـ GitLab Enterprise فقط) | X | X | |
| تصعيد الامتيازات | addadmin | نعم | X | X | X |
| تصعيد الامتيازات | removeadmin | نعم | X | X | X |
| استطلاع | adminstats | نعم | X |