Posted by: Leap Security
It is possible to compile windows code natively in Kali using MinGW compiler and Wine. While MinGW comes already installed and configured for users in Backtrack, it does not in Kali.
Let’s go over how to install and configure MinGW for Kali and how to use it to compile windows code, but first some quick definitions.
What is Wine?
Wine allows windows applications to be run on several platforms such as Linux, Mac OS X and more.
What is MinGW?
MinGW is a collection of windows development tools including compilers such as GCC and G++. Using both MiniGW and Wine it is possible to compile windows code thus creating a portable executable (pe) which can be later run with wine.
Installing MinGW on Kali Linux
As previously mentioned, MinGW does not come installed on Kali by default. Thus one does not have access to important tools and compilers such as gcc. Let’s install and configure it.
- Download the MinGW installer from their sourceforge.
- Run the installer (mingw-get-setup.exe) with wine.
- Select the Install with GUI option.
- The MinGW installation manager should now be open. Select mingw32-base.
- Select Installation > Update Catalogue on the top left hand corner.
- Some missing DLLs will need to be downloaded, download them here.
- Unzip them and move them to the wine drive_c/windows folder.
Excellent, we now have Mingw installed! You can confirm this by visiting the /root/.wine/drive_c/MinGW directory. You should also have gcc installed under /root/.wine/drive_c/MinGW/bin/gcc.exe.
Compiling Windows Code in Kali
With MinGW installed all we have to do now is use gcc to compile our c code. Below is an example of usage. The example below assumes the user is inside the /root/.wine/drive_c/MinGW/bin directory.