Skip to content

Instantly share code, notes, and snippets.

@opentechnologist
Created July 8, 2025 00:56
Show Gist options
  • Save opentechnologist/b494381f8ff6e7b93f185ee5ea722268 to your computer and use it in GitHub Desktop.
Save opentechnologist/b494381f8ff6e7b93f185ee5ea722268 to your computer and use it in GitHub Desktop.
a c# project that uses a manifest file to gain elevated privelege access.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="main"
type="win32"
/>
<description>Elevated Privelege UAC Demo</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/><!-- Windows 10 -->
<supportedOS Id="{4eb61bac-a3b6-4760-9581-655041ef4d69}"/><!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/><!-- Windows 8 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/><!-- Windows 7 -->
</application>
</compatibility>
</assembly>
using System;
using System.IO;
namespace MainPackage
{
public class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Console Application with Elevated Privilege Demo.");
Console.WriteLine();
Console.Write("press any key to exit..");
Console.ReadKey();
Console.WriteLine();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
Sdk="Microsoft.NET.Sdk"
DefaultTargets="Build"
>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<RootNamespace>MainPackage</RootNamespace>
<AssemblyName>main</AssemblyName>
<OutputType>Exe</OutputType>
<OutputPath>bin\</OutputPath>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Compile Include="main.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="CleanUp" AfterTargets="PostBuildEvent">
<ItemGroup>
<CoreLib Include="$(OutputPath)**\mscorlib.dll" />
<Debug Include="$(OutputPath)**\$(AssemblyName).pdb" />
<LangSupport Include="$(OutputPath)**\*.nlp" />
</ItemGroup>
<Delete Files="@(CoreLib)" />
<Delete Files="@(Debug)" />
<Delete Files="@(LangSupport)" />
<RemoveDir Directories="$(ProjectDir)obj" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment