githubEdit

Active Directory Pentesting

Active Directory (AD) is a directory service developed by Microsoft for Windows domain networks.

Enumeration

Domain Controllers Discovery

dig @<target-ip> example.local ANY
gobuster dns -d example.local -w subdomains.txt -t 25

Enumeration with BloodHound

1. Run BloodHound

We use BloodHound Community Editionarrow-up-right. The following command starts the Docker Compose of the BloodHound.

curl -L https://ghst.ly/getbhce > docker-compose.yml
sudo docker-compose down -v # If you want to reset the password of BloodHound...
sudo docker-compose pull && sudo docker-compose up

After that, we can use the web UI by accessing to localhost:8080 in web browser. Login with the username admin and the password which is displayed the log when executing the above command.

To specify arbitrary ip and port, set the environment variables on our attack machine:

export BLOODHOUND_HOST=10.0.0.1
export BLOODHOUND_PORT=8090

2. Collect Data

  • Option1. Using NetExec

    If you already have NetExec in your machine, I think it is the most easiest way.

  • Option2. Using BloodHound.py

    We can also use BloodHound.pyarrow-up-right. Install it as follow:

    Then collect data:

3. Upload Collected Data

After running, the result files (*.json) generated in the current directory. Upload all these JSON files to the BloodHound in web browser.

We can explore the relationship in the Active Directory.

Investigation

Abuse Logon Script for Other Users

If the current user has the permission to write scripts in SYSVOL, we may be able to change other users logon script path.

When the other user logs on, the .bat script will be executed.

Force Change Password Attack

If we found some username/password, and other usernames, we might be able to change other user passwords. The user needs to have GenericAll permission to change passwords of other users.

Microsoft Management Console (mmc)

To setup AD, follow this instructions:

  1. Right-click on the Windows icon.

  2. Click "Run" and enter "mmc" then click "OK".

  3. In the MMC, click "File → Add or Remove Snap-ins".

  4. Add all three "Active Directory…" snap-ins.

  5. Right-click on the "Active Directory…" in the left pane and select "Change Forest".

  6. Enter the domain as the Root domain and click OK.

  7. Click on "View → Advanced Features".

Naming Convention

If we found usernames list in Active Directory, we can modify usernames with naming convention. For instance,

SSH Login with AD Credentials

Inject Credentials into Memory

DNS Configuration

Now check if the configuration is set correctly.

Basic Knowledge

User Management

  • Delegation

    In Active Directory, the administrator delegate another user to manage users over an Organizational Unit (OU), without the admin privileges.

    1. Setup

      1. Open "Active Directory Users and Computers".

      2. Right-click on the target OU, and click “Deligate Control…”. Then the new window will open.

      3. In the window, input username who you want to delegate the privilege that manage users.

      4. Select tasks to which the delegated user should manage.

      5. Click OK.

    2. Manage Users

      1. Logon as the delegated user.

      2. For instance, if you want to reset the john's password, execute the following command in PowerShell. Then input new password in prompt.

      3. The first time John logs on after that, we want John to change his arbitrary password not the password you entered. So that to, execute the following command.

      4. Now when John logs on he will be prompt to change a new password.

Intercept NetNTLM Authentication

Start Responder to listen for any LLMNR, NBT-NS, WPAD requests.

Leave Responder running until receiving some requests. If you get NTLM hash, crack it in local machine.

References

Last updated