> For the complete documentation index, see [llms.txt](https://n000b3r.gitbook.io/oscp-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://n000b3r.gitbook.io/oscp-notes/misc/cross-compiling-exploit-code.md).

# Cross-Compiling Exploit Code

### Compiling a Windows exploit on Linux environment

```shell
i686-w64-mingw32-gcc 42341.c -o syncbreeze_exploit.exe
```

{% hint style="info" %}
`Install the complier using sudo apt install mingw-w64`&#x20;
{% endhint %}

{% hint style="info" %}
Use the -lws2\_32 parameter if error  "/tmp:syncbreeze\_exploit.c:(.text+0x2e): undefined reference to `_imp__WSAStartup@8"` occurs
{% endhint %}

### For C++

```bash
# dpkg --add-architecture i386
# install mingw32/64
# 32 bits:
i686-w64-mingw32-g++-win32 exp.cpp -static -o exp
# 64 bits:
x86_64-w64-mingw32-g++ exp.cpp -static -o exp
```
