# Building Windows C# Tools and Payloads from Kali Linux

DevFeed: [Building Windows C# Tools and Payloads from Kali Linux](<https://devfeed.tech/articles/building-windows-c-tools-and-payloads-from-kali-linux-118957.md>)

Original publisher: [Read original article](<https://www.kali.org/blog/windows-csharp-payloads/>)

Published: 2026-11-04T00:00:00Z

Content type: tutorial

Language: en

Sources: [Kali Linux](<https://devfeed.tech/sources/kali-linux.md>)

Topics: [Cross-Compilation](<https://devfeed.tech/topics/cross-compilation.md>), [builds](<https://devfeed.tech/topics/builds.md>), [Windows](<https://devfeed.tech/topics/windows.md>), [WINE](<https://devfeed.tech/topics/wine.md>), [.NET Framework](<https://devfeed.tech/topics/net-framework.md>), [console](<https://devfeed.tech/topics/console.md>), [Process](<https://devfeed.tech/topics/process.md>)

Tags: [advanced](<https://devfeed.tech/tags/advanced.md>), [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [clm](<https://devfeed.tech/tags/clm.md>), [compile](<https://devfeed.tech/tags/compile.md>), [distribution](<https://devfeed.tech/tags/distribution.md>), [kali](<https://devfeed.tech/tags/kali.md>), [kali-linux](<https://devfeed.tech/tags/kali-linux.md>), [kalilinux](<https://devfeed.tech/tags/kalilinux.md>), [linux](<https://devfeed.tech/tags/linux.md>), [penetration](<https://devfeed.tech/tags/penetration.md>), [penetration-testing](<https://devfeed.tech/tags/penetration-testing.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tools](<https://devfeed.tech/tags/tools.md>), [windows](<https://devfeed.tech/tags/windows.md>)

## AI overview

The article shows how Kali Linux can build and run Windows C# artifacts for penetration-testing exercises. Install `mono-devel` and use `mcs` to compile C# into a Windows executable or DLL; `wine` with `wine-mono` can run ordinary binaries on Kali. A Constrained Language Mode bypass example additionally requires Microsoft PowerShell and installer DLLs, which the article locates in files downloaded by configuring `powershell-empire`. It also describes using the `csharp` interpreter with a shell function to transform `msfvenom` output, and compiling Rubeus with `dotnet publish` using a patch for a self-contained build. For DotNetToJScript, the authors use repository binaries because they could not compile them; that workflow requires `wine` and `dotnet35`, since `wine-mono` alone did not work. These are article-specific procedures; the supplied text does not establish broader compatibility or current package availability.

## Source excerpt

One of our team members recently took (and passed!) OffSec's advanced penetration testing course & exam, PEN-300/OSEP. Whilst it focuses a lot on Microsoft Windows, there were a few extra places where Linux could be used to complete the same task... just quicker! Compiling C# code in Kali In general, what you need for compiling CSharp (C#) code in Kali is mono-devel : kali@kali:~$ sudo apt install mono-devel Now we need some code to compile. Here's a very basic way of executing a program (process): using System; using System.Diagnostics; namespace Exec { class Program { static void Main() { Process proc = new Process(); ProcessStartInfo procInfo = new ProcessStartInfo("cmd.exe", "/T:09 /K systeminfo"); procInfo.CreateNoWindow = false; procInfo.UseShellExecute = false; proc.StartInfo = procInfo; proc.Start(); } } } If you would like some more examples to get you going, try a Shellcode Launcher or a Simple Reverse Shell. All that is left is to compile: kali@kali:~$ TERM=linux mcs -out:exec.exe exec.cs kali@kali:~$ kali@kali:~$ file exec.* exec.cs: C++ source, ASCII text exec.exe: PE32 executable for MS Windows 4.00 (console), Intel i386 Mono/.Net assembly, 3 sections kali@kali:~$ How to run these binaries from Kali Linux Simple: just install wine and wine-mono. It's really handy, as you can test your Windows binaries (even reverse shells) directly from Kali: kali@kali:~$ sudo dpkg --add-architecture i386 kali@kali:~$ sudo apt update [...] kali@kali:~$ sudo apt -y install wine32 [...] kali@kali:~$ # Install wine-mono kali@kali:~$ wget https://dl.winehq.org/wine/wine-mono/11.3.0/wine-mono-11.3.0-x86.msi [...] kali@kali:~$ kali@kali:~$ wine msiexec /i wine-mono-11.3.0-x86.msi [...] kali@kali:~$ And now, to run your freshly built .exe binary, just use: kali@kali:~$ wine exec.exe Constrained Language Mode Bypass It's not always that easy -- sometimes things get a bit trickier. For example, for compiling the Constrained Language Mode (CLM) bypass section, we need some DLL libr