forked from BinaryDefense/auto-ossec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request BinaryDefense#10 from Yoshi325/msi-parameter
Add IP Address as a Parameter to Create-AutoOssecMsi Script
- Loading branch information
Showing
2 changed files
with
67 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#REQUIRES -Version 2.0 | ||
<# | ||
.SYNOPSIS | ||
Uses the WiX Toolset to create an msi. | ||
.NOTES | ||
File Name : Create-MsiForAutoOSSEC.ps1 | ||
Author : Binary Defense Systems | ||
Prerequisite : WiX Toolset v3.10 | ||
Copyright 2015 through 2016 to Binary Defense Systems, LLC | ||
.LINK | ||
WiX Toolset Can be found at: | ||
http://wixtoolset.org/ | ||
#> | ||
|
||
[CmdletBinding()] | ||
Param( | ||
[Parameter(Mandatory=$False, Position=1)] | ||
[string]$Address = $(Read-Host "What is the IP Address where you will be running auto_server.py?") | ||
) | ||
|
||
If ([string]::IsNullOrEmpty(${Address})) { | ||
Write-Host "FAIL: An IP Address must be specified." | ||
Exit 3 | ||
} | ||
|
||
$AddressParsed = $Null | ||
$AddressIsWildcard = (0 -Eq $Address.CompareTo('0.0.0.0/0')) | ||
$AddressIsValid = ($AddressIsWildcard -Or [System.Net.IPAddress]::tryparse($Address,[ref] $AddressParsed)) | ||
If (-Not $AddressIsValid) { | ||
Write-Host "FAIL: A Valid IP Address or Wildcard (0.0.0.0/0) must be specified." | ||
Exit 2 | ||
} | ||
|
||
$OutputPrefix = "auto_ossec" | ||
$OutputExtension = "msi" | ||
If ($AddressIsWildcard) { | ||
# Windows doesn't apperciate slashes in filenames. | ||
$OutputName = "${OutputPrefix}-0.0.0.0.${OutputExtension}" | ||
} Else { | ||
$OutputName = "${OutputPrefix}-${Address}.${OutputExtension}" | ||
} | ||
Write-Host "Creating MSI: ${OutputName}" | ||
If ($True) { | ||
Write-Host -NoNewLine " Locating WiX Toolset... " | ||
If (Test-Path 'C:\Program Files\WiX Toolset v3.10\bin') { | ||
$WiX_BinRoot = 'C:\Program Files\WiX Toolset v3.10\bin' | ||
} ElseIf (Test-Path 'C:\Program Files (x86)\WiX Toolset v3.10\bin') { | ||
$WiX_BinRoot = 'C:\Program Files (x86)\WiX Toolset v3.10\bin' | ||
} Else { | ||
Write-Host "FAIL: Unable to locate WiX Toolset." | ||
Exit 1 | ||
} | ||
Write-Host "located." | ||
|
||
Write-Host -NoNewLine " Compiling... " | ||
& "${WiX_BinRoot}\candle.exe" -dServerAddress="${Address}" .\auto_ossec.wxs | Out-Null | ||
Write-Host "compiled." | ||
|
||
Write-Host -NoNewLine " Linking... " | ||
& "${WiX_BinRoot}\light.exe" -spdb -out "${OutputName}" auto_ossec.wixobj | Out-Null | ||
Write-Host "linked." | ||
|
||
Write-Host -NoNewLine " Cleaning up... " | ||
Remove-Item auto_ossec.wixobj | Out-Null | ||
Write-Host "cleaned up." | ||
} | ||
Write-Host "created." |
This file was deleted.
Oops, something went wrong.