Skip to content

Instantly share code, notes, and snippets.

@arush15june
Last active December 28, 2023 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arush15june/e631a383a47b5b421c3b135cc1b4bd7e to your computer and use it in GitHub Desktop.
Save arush15june/e631a383a47b5b421c3b135cc1b4bd7e to your computer and use it in GitHub Desktop.
wixl-linux-msi-generate

Build Wixl

  • Build wixl binary using Dockerfile.wixl
  • Copy the wixl binary from the container or use the container with a volume to build your MSI

Build MSI

  • Make sure software.exe is present on disk in the CWD.
  • Use the generated wixl binary to build the wxs template.
wixl -v software.wxs.template -o software.msi

Sign the binary

  • Make sure osslsigncode is installed.
  • You need a PFX code signing certificate (non-EV)
  • Use the following the command line to sign both the EXE and MSI files
osslsigncode sign -pkcs12 codesigning.pfx -in software_unsigned.exe -out software_signed.exe -pass "<password>"
osslsigncode sign -pkcs12 codesigning.pfx -in software_unsigned.msi -out software_signed.msi -pass "<password>"

Fake Code Sign

You can also use Limelighter to sign the binaries using a self-signed code signing certificate.

Customize Template

Customize the template according to wix configuration. Please remember, wixl does not support all features of the WXS configurations, knowing which configurations are supported is a trip down the wixl source code.

WIXL Executable

You can also find a compiled wixl ELF here generated using the provided dockerfile.

FROM ubuntu:20.04 as base
USER root
ENV DEBIAN_FRONTEND=noninteractive
RUN /usr/bin/apt-get update && /usr/bin/apt-get -y install meson \
ninja-build \
valac \
libgtk-3-dev \
bison \
cmake \
libgsf-1-dev \
libgcab-dev \
libgirepository1.0-dev \
ninja-build \
libmsi0 \
wget \
&& rm -rf /var/lib/apt/lists/*;
RUN /bin/mkdir /opt/msi \
&& /bin/mkdir /mnt/attack \
&& /usr/bin/wget -O /opt/msitools.tar.xz https://download.gnome.org/sources/msitools/0.101/msitools-0.101.tar.xz \
&& /usr/bin/tar -xvf /opt/msitools.tar.xz -C /opt/msi
WORKDIR /opt/msi/msitools-0.101
RUN meson setup builddir \
&& ninja -C builddir \
&& meson install -C builddir;
# In the software directory
# docker run --rm -it -v $(pwd):/mnt/attack
#COPY software.exe /mnt/attack/build/software.exe
#RUN wixl -v software.template.wxs -o software.msi
# Output MSI will be saved to PWD.
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product Name='Software Name' Id='<put unique UUID here>' UpgradeCode='<put unique UUID here>'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Software Manufacturer'>
<Package InstallScope="perMachine" Id='*' Keywords='Installer' Description="Software Installer"
Comments='Software Installer' Manufacturer='Software Manufacturer'
InstallerVersion='200' Languages='1033' Compressed='yes' SummaryCodepage='1252' />
<Media Id='1' Cabinet='Software.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
<Property Id='DiskPrompt' Value="Software Installation" />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='Software' Name='Software'>
<Directory Id='INSTALLDIR' Name='File'>
<Component Id='MainExecutable' Guid='96e5aa48-e250-4900-a75e-ca7f7b030690'>
<File Id='SoftwareEXE' Name='software.exe' DiskId='1' Source='software.exe' KeyPath='yes'/>
</Component>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="ProgramMenuDir" Name="Software 1.0.0">
<Component Id="ProgramMenuDir" Guid="df114d75-4b4f-44c0-a9a9-792d3572196a">
<RemoveFolder Id='ProgramMenuDir' On='uninstall' />
<RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
</Component>
</Directory>
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
<Feature Id='Complete' Level='1'>
<ComponentRef Id='MainExecutable' />
<ComponentRef Id='ProgramMenuDir' />
</Feature>
<InstallExecuteSequence>
<Custom Action='installservice' Before='InstallFinalize' Sequence='6598'>(NOT Installed) AND (NOT REMOVE)</Custom>
<Custom Action='startservice' Before='InstallFinalize' Sequence='6599'>(NOT Installed) AND (NOT REMOVE)</Custom>
<Custom Action="stopservice" After="InstallInitialize" Sequence='1501'>(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
<Custom Action="uninstallservice" After="InstallInitialize" Sequence='1502'>(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>
<Property Id='SOFTWAREINSTALL' Value='C:\Program Files (x86)\Software\File\software.exe' />
<CustomAction Property='SOFTWAREINSTALL' ExeCommand='install' Id='installservice' Execute='deferred' Return='check'/>
<CustomAction Property='SOFTWAREINSTALL' ExeCommand='start' Id='startservice' Execute='deferred' Return='check'/>
</Product>
</Wix>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment