18. Miscellaneous misconfigurations

Portions that require linux: htb-student:HTB_@cademy_stdnt! Open PS and SSH to 172.16.5.225

Exchange Related Group Membership

if we compromise exchange server this often leads to domain admin privileges ult

PrivExchange

results from a flaw in exch. server pushsubscription

Printer bug is flaw in MS-RPRN print system remote protocol

spooler runs as sys and is installed by default in winserv running desktop experience

we can use Get-SpoolStatus module http://web.archive.org/web/20200919080216/https://github.com/cube0x0/Security-Assessment https://github.com/NotMedic/NetNTLMtoSilverTicket to assess vulnerability

flaw can be used to compromise a host in another forest that has unconstrained delegation enabled; such as a DC. it can help us to attack across forest trusts once we have compromised one forest.

PS C:\htb> Import-Module .\SecurityAssessment.ps1
PS C:\htb> Get-SpoolStatus -ComputerName ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL

MS14-068

This vulnerability allows forged PAC to be accepted by KDC.

https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS14-068/pykek


Sniffing LDAP credentials

Many apps/printers store LDAP creds in web admin console. Consoles often left with weak/default pws. Sometimes viewable in cleartext. Occasionally test connection functionality we can use to gather creds by changing the LDAP IP to that of our atk host and using a netcat listener on ldap port 389 When device attempts to test LDAP connecction it will send creds to our machine Those accounts are often privileged or could be used for foothold. Other times, full LDAP server required - see post: https://grimhacker.com/2018/03/09/just-a-printer/


Enumerating DNS records

https://github.com/dirkjanm/adidnsdump

Post: https://dirkjanm.io/getting-in-the-zone-dumping-active-directory-dns-with-adidnsdump/

Helpful if naming convention for hosts in enumeration using bloodhoudn is similar to something like SRV01934.INLANEFREIGHT.LOCAL

If servers/workstations have non-descriptive names it can make it difficult to know what exactly to attack. If we can access DNS entries in AD, we can find interesting dns records that point to the same server, such as JENKINS.INLANEFREIGHT.LOCAL which can be used to determine what to target.

Tool works because by default, all users can list the child objects of a DNS zone in an AD environment.

stejwes@htb[/htb]$ adidnsdump -u inlanefreight\\forend ldap://172.16.5.5 

Password: 

[-] Connecting to host...
[-] Binding to host
[+] Bind OK
[-] Querying zone for records
[+] Found 27 records

stejwes@htb[/htb]$ head records.csv 

type,name,value
A,LOGISTICS,172.16.5.240
AAAA,ForestDnsZones,dead:beef::7442:c49d:e1d7:2691
AAAA,ForestDnsZones,dead:beef::231
A,ForestDnsZones,10.129.202.29
A,ForestDnsZones,172.16.5.240
A,ForestDnsZones,172.16.5.5
AAAA,DomainDnsZones,dead:beef::7442:c49d:e1d7:2691
AAAA,DomainDnsZones,dead:beef::231
A,DomainDnsZones,10.129.202.29

Other, more specific misconfigurations

Passwords in description field

PS C:\htb> Get-DomainUser * | Select-Object samaccountname,description |Where-Object {$_.Description -ne $null}

samaccountname description
-------------- -----------
administrator  Built-in account for administering the computer/domain
guest          Built-in account for guest access to the computer/domain
krbtgt         Key Distribution Center Service Account
ldap.agent     *** DO NOT CHANGE ***  3/12/2012: Sunsh1ne4All!

PASSWD_NOTREQD field

Some dom accounts may have this field set in the UAC attribute. If this is set, the user is not subject to the current password policy length, meaning they could have a shorter password or no password at all (if empty pws are allowed)

Sometimes PWs are set blank intentionally. Or accidentally hitting enter before entering a password when changing it via cmdline.

Get-DomainUser -UACFilter PASSWD_NOTREQD | Select-Object samaccountname,useraccountcontrol

Credentials in SMB shares / SYSVOL scripts

SYSVOL share can be a treasure trove of data especially in large orgs. Pillaging:

Module shows an example of finding a script named reset_local_admin_pass.vbs that contains password for builtin local administrator on windows host. We can password spray this pw across the domain with nxc and see if we get any hits.

Group Policy Peferences (GPP) Passwords

When GPPS created, xml file created in SYSVOL and also cached locally on endpoints the GP applies to.

These files are used to:

These files contain an array of conf data and defined passwords. The cpassword attribute value is AES256 encrypted but Microsoft published the AES private key on MSDN which can be used to decrypt.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-gppref/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be?redirectedfrom=MSDN

Patched in 2014 https://support.microsoft.com/en-us/topic/ms14-025-vulnerability-in-group-policy-preferences-could-allow-elevation-of-privilege-may-13-2014-60734e15-af79-26ca-ea53-8cd617073c30

Patch does not remove existing groups.xml files with passwords from SYSVOL - if you delete GPP policy instead of unlinking it from the OU the cached copy on local computer remains.

gpp-decrypt can also be used to decrypt the password

stejwes@htb[/htb]$ gpp-decrypt VPe/o9YRyz2cksnYRbNeQj35w9KxQ5ttbvtRaAVqxaE

GPP pws located by browsing SYSVOL or using Get-GPPPassword.ps1 (from metasploit post module) or other python/ruby scripts that will locate gpp and returned decrypted cpass https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Get-GPPPassword.ps1 CME has two modules for locating/retrieving GPP passwords quick tip regarding GPPs

PW reuse is widespread.

stejwes@htb[/htb]$ crackmapexec smb -L | grep gpp

[*] gpp_autologin             Searches the domain controller for registry.xml to find autologon information and returns the username and password.
[*] gpp_password              Retrieves the plaintext password and other information for accounts pushed through Group Policy Preferences.

can also find passwords in files like Registry.xml when autologin is configured via group policy.

stejwes@htb[/htb]$ crackmapexec smb 172.16.5.5 -u forend -p Klmcargo2 -M gpp_autologin

ASREPRoasting

ASREPROASTING VS KERBEROASTING

AS_REP Roasting is taking place during the initial authentication procedure within Kerberos. It´s abusing the fact, that for accounts with the option Do not require Kerberos preauthentication set, there is no need to send the (normally required) encrypted timestamp (with the users password hash) at the very beginning. Thus everyone on the network who knows the name of an affected account may ask the KDC to authenticate as that user and in return fetch a AS_REP response which partly is encrypted with the AS_REP roastable account´s password hash. Once obtained, an attacker can try to offline crack the hash and fetch the cleartext credentials.

Kerberoasting aims at asking for service tickets related to services on the network where the SPNs are tied to user accounts, rather than computer accounts. The background here is that if a person creates a user he will choose the password most likely according to human standards i.e. a phrase, a word mixed with numbers, etc. If that password is weakly chosen, then it is possible to crack the hash and get the cleartext credentials.
During the process of asking to access a service on the network, the TGS will send a data package that contains a service ticket which is encrypted with the service-account´s password hash, that again like in the AS_REP roasting attack can be cracked offline.

It's possible to get TGT for any account that has do not require kerberos pre-authentication setting enabled. Many vendor installation guides specify svc account must be configured this way. Authentication service reply (AS_REP) is encrypted with the account's password and any domain user can request it

With pre-auth

asreproasting is similar to kerberoasting but it involves attacking the AS-REP instead of the TGS-REP - an SPN is not required.

Enumerating DONT_REQ_PREAUTH

PS C:\htb> Get-DomainUser -PreauthNotRequired | select samaccountname,userprincipalname,useraccountcontrol | fl

once we have this info we can use rubeus to retrieve the ASREP does not require any domain user context and can be done just by knowing sam name for the user without kerberos pre-auth

.\Rubeus.exe asreproast /user:mmorgan /nowrap /format:hashcat

use hashcat mode 18200

if we enumerate using Kerbrute the tool will automatically retrieve AS-REP for any users without kerberos pre-auth

stejwes@htb[/htb]$ kerbrute userenum -d inlanefreight.local --dc 172.16.5.5 /opt/jsmith.txt 

With a list of valid users we can use Get-NPUsers.py from impacket to hunt down all users with kerberos pre-auth not required. The tool will retrieve the ASREP in hashcat format. We can also feed it the jsmith.txt wordlist and it will throw errors for users that do not exist. If unable to crack the ASREP it is still good to report this as a finding, just lower risk because we cannot crack it.

stejwes@htb[/htb]$ GetNPUsers.py INLANEFREIGHT.LOCAL/ -dc-ip 172.16.5.5 -no-pass -usersfile valid_ad_users 

Group Policy Object (GPO) abuse

GPO misconfigurations can be abused to perform the following attacks:

Enumeration is possible using many of the prior tools (Powerview, bloodhound) Others:

Using Get-DomainGPO function from powerview we can get a listing of GPOs by name

If Group Policy Management Tools are installed on the host we are working from we can use various built-in GroupPolicy cmdlets such as Get-GPO to do the same enum https://docs.microsoft.com/en-us/powershell/module/grouppolicy/?view=windowsserver2022-ps

Get-GPO -All | Select DisplayName

Next check if a user we can control has any rights over GPOs - Specific user/grps may have that access. See if entire domain user group has rights over one/more GPOs

PS C:\htb> $sid=Convert-NameToSid "Domain Users"
PS C:\htb> Get-DomainGPO | Get-ObjectAcl | ?{$_.SecurityIdentifier -eq $sid}

Use GPO GUID with Get-Gpo to see display name

PS C:\htb Get-GPO -Guid 7CA9C789-14CE-46E3-A722-83F4097AF532

![](/img/Pasted image 20240910180538.png) https://github.com/FSecureLABS/SharpGPOAbuse We can use a tool like SharpGPOAbuse to take advantage of this GPO misconfig by performing actions like adding users we control to local admin group on one of the affected hosts, creating an immediate scheduled task on one of them to give us a reverse shell, or configure malicious computer startup script to provide us a revshell etc.


We have seen various misconfigurations that we may run into during an assessment, and there are many more that will be covered in more advanced Active Directory modules. It is worth familiarizing ourselves with as many attacks as possible, so we recommend doing some research on topics such as: