Windows deployment scripts to python3

This commit is contained in:
VakarisZ 2019-09-26 10:53:25 +03:00
parent a194bb5622
commit 9a21a50fd1
2 changed files with 5 additions and 13 deletions

View File

@ -3,7 +3,7 @@ $MONKEY_FOLDER_NAME = "infection_monkey"
# Url of public git repository that contains monkey's source code # Url of public git repository that contains monkey's source code
$MONKEY_GIT_URL = "https://github.com/guardicore/monkey" $MONKEY_GIT_URL = "https://github.com/guardicore/monkey"
# Link to the latest python download or install it manually # Link to the latest python download or install it manually
$PYTHON_URL = "https://www.python.org/ftp/python/2.7.13/python-2.7.13.amd64.msi" $PYTHON_URL = "https://www.python.org/ftp/python/3.7.4/python-3.7.4-amd64.exe"
# Monkey binaries # Monkey binaries
$LINUX_32_BINARY_URL = "https://github.com/guardicore/monkey/releases/download/1.6/monkey-linux-32" $LINUX_32_BINARY_URL = "https://github.com/guardicore/monkey/releases/download/1.6/monkey-linux-32"
@ -33,14 +33,11 @@ $TEMP_CPP_INSTALLER = "cpp.exe"
$TEMP_NPM_INSTALLER = "node.msi" $TEMP_NPM_INSTALLER = "node.msi"
$TEMP_PYWIN32_INSTALLER = "pywin32.exe" $TEMP_PYWIN32_INSTALLER = "pywin32.exe"
$TEMP_UPX_ZIP = "upx.zip" $TEMP_UPX_ZIP = "upx.zip"
$TEMP_VC_FOR_PYTHON27_INSTALLER = "vcforpython.msi"
$UPX_FOLDER = "upx394w" $UPX_FOLDER = "upx394w"
# Other url's # Other url's
$VC_FOR_PYTHON27_URL = "https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi"
$MONGODB_URL = "https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-latest.zip" $MONGODB_URL = "https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-latest.zip"
$OPEN_SSL_URL = "https://indy.fulgan.com/SSL/Archive/openssl-1.0.2l-i386-win32.zip" $OPEN_SSL_URL = "https://indy.fulgan.com/SSL/Archive/openssl-1.0.2l-i386-win32.zip"
$CPP_URL = "https://go.microsoft.com/fwlink/?LinkId=746572"
$NPM_URL = "https://nodejs.org/dist/v10.13.0/node-v10.13.0-x64.msi" $NPM_URL = "https://nodejs.org/dist/v10.13.0/node-v10.13.0-x64.msi"
$PYWIN32_URL = "https://github.com/mhammond/pywin32/releases/download/b224/pywin32-224.win-amd64-py2.7.exe" $PYWIN32_URL = "https://github.com/mhammond/pywin32/releases/download/b224/pywin32-224.win-amd64-py2.7.exe"
$UPX_URL = "https://github.com/upx/upx/releases/download/v3.94/upx394w.zip" $UPX_URL = "https://github.com/upx/upx/releases/download/v3.94/upx394w.zip"

View File

@ -44,15 +44,15 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
try try
{ {
$version = cmd.exe /c '"python" --version 2>&1' $version = cmd.exe /c '"python" --version 2>&1'
if ( $version -like 'Python 2.7.*' ) { if ( $version -like 'Python 3.*' ) {
"Python 2.7.* was found, installing dependancies" "Python 3.* was found, installing dependencies"
} else { } else {
throw System.Management.Automation.CommandNotFoundException throw System.Management.Automation.CommandNotFoundException
} }
} }
catch [System.Management.Automation.CommandNotFoundException] catch [System.Management.Automation.CommandNotFoundException]
{ {
"Downloading python 2.7 ..." "Downloading python 3 ..."
$webClient.DownloadFile($PYTHON_URL, $TEMP_PYTHON_INSTALLER) $webClient.DownloadFile($PYTHON_URL, $TEMP_PYTHON_INSTALLER)
Start-Process -Wait $TEMP_PYTHON_INSTALLER -ErrorAction Stop Start-Process -Wait $TEMP_PYTHON_INSTALLER -ErrorAction Stop
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
@ -69,7 +69,7 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
$PYTHON_PATH = Split-Path -Path (Get-Command python | Select-Object -ExpandProperty Source) $PYTHON_PATH = Split-Path -Path (Get-Command python | Select-Object -ExpandProperty Source)
# Get vcforpython27 before installing requirements # Get vcforpython27 before installing requirements
"Downloading Visual C++ Compiler for Python 2.7 ..." "Downloading Visual C++ Compiler for Python 3 ..."
$webClient.DownloadFile($VC_FOR_PYTHON27_URL, $TEMP_VC_FOR_PYTHON27_INSTALLER) $webClient.DownloadFile($VC_FOR_PYTHON27_URL, $TEMP_VC_FOR_PYTHON27_INSTALLER)
Start-Process -Wait $TEMP_VC_FOR_PYTHON27_INSTALLER -ErrorAction Stop Start-Process -Wait $TEMP_VC_FOR_PYTHON27_INSTALLER -ErrorAction Stop
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
@ -115,11 +115,6 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
"Removing zip file" "Removing zip file"
Remove-Item $TEMP_OPEN_SSL_ZIP Remove-Item $TEMP_OPEN_SSL_ZIP
# Download and install C++ redistributable
"Downloading C++ redistributable ..."
$webClient.DownloadFile($CPP_URL, $TEMP_CPP_INSTALLER)
Start-Process -Wait $TEMP_CPP_INSTALLER -ErrorAction Stop
Remove-Item $TEMP_CPP_INSTALLER
# Generate ssl certificate # Generate ssl certificate
"Generating ssl certificate" "Generating ssl certificate"