forked from p15670423/monkey
Merge pull request #1947 from guardicore/1924-upgrade-mongodb
Upgrade MongoDB in build scripts
This commit is contained in:
commit
ed2efbc0bf
|
@ -33,6 +33,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- The "/api/netmap/nodeStates" endpoint to "/api/netmap/node-states". #1888
|
- The "/api/netmap/nodeStates" endpoint to "/api/netmap/node-states". #1888
|
||||||
- All "/api/monkey_control" endpoints to "/api/monkey-control". #1888
|
- All "/api/monkey_control" endpoints to "/api/monkey-control". #1888
|
||||||
- All "/api/monkey" endpoints to "/api/agent". #1888
|
- All "/api/monkey" endpoints to "/api/agent". #1888
|
||||||
|
- Update MongoDB version to 4.4.x. #1924
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- VSFTPD exploiter. #1533
|
- VSFTPD exploiter. #1533
|
||||||
|
|
|
@ -21,7 +21,6 @@ $WINDOWS_64_BINARY_PATH = "monkey-windows-64.exe"
|
||||||
$MONKEY_ISLAND_DIR = Join-Path "\monkey" -ChildPath "monkey_island"
|
$MONKEY_ISLAND_DIR = Join-Path "\monkey" -ChildPath "monkey_island"
|
||||||
$MONKEY_DIR = Join-Path "\monkey" -ChildPath "infection_monkey"
|
$MONKEY_DIR = Join-Path "\monkey" -ChildPath "infection_monkey"
|
||||||
$TEMP_PYTHON_INSTALLER = ".\python.exe"
|
$TEMP_PYTHON_INSTALLER = ".\python.exe"
|
||||||
$TEMP_MONGODB_ZIP = ".\mongodb.zip"
|
|
||||||
$TEMP_OPEN_SSL_ZIP = ".\openssl.zip"
|
$TEMP_OPEN_SSL_ZIP = ".\openssl.zip"
|
||||||
$TEMP_CPP_INSTALLER = "cpp.exe"
|
$TEMP_CPP_INSTALLER = "cpp.exe"
|
||||||
$TEMP_NPM_INSTALLER = "node.msi"
|
$TEMP_NPM_INSTALLER = "node.msi"
|
||||||
|
@ -29,7 +28,6 @@ $TEMP_UPX_ZIP = "upx.zip"
|
||||||
$UPX_FOLDER = "upx-3.96-win64"
|
$UPX_FOLDER = "upx-3.96-win64"
|
||||||
|
|
||||||
# Other url's
|
# Other url's
|
||||||
$MONGODB_URL = "https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2012plus-v4.2-latest.zip"
|
|
||||||
$OPEN_SSL_URL = "https://indy.fulgan.com/SSL/openssl-1.0.2u-x64_86-win64.zip"
|
$OPEN_SSL_URL = "https://indy.fulgan.com/SSL/openssl-1.0.2u-x64_86-win64.zip"
|
||||||
$CPP_URL = "https://go.microsoft.com/fwlink/?LinkId=746572"
|
$CPP_URL = "https://go.microsoft.com/fwlink/?LinkId=746572"
|
||||||
$NPM_URL = "https://nodejs.org/dist/v16.14.2/node-v16.14.2-x64.msi"
|
$NPM_URL = "https://nodejs.org/dist/v16.14.2/node-v16.14.2-x64.msi"
|
||||||
|
|
|
@ -163,25 +163,8 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
|
||||||
[Environment]::SetEnvironmentVariable("Path", $env:Path, "User")
|
[Environment]::SetEnvironmentVariable("Path", $env:Path, "User")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download mongodb
|
$install_mongo_script = (Join-Path -Path $monkey_home -ChildPath "$MONKEY_ISLAND_DIR\windows\install_mongo.ps1")
|
||||||
if (!(Test-Path -Path (Join-Path -Path $binDir -ChildPath "mongodb")))
|
Invoke-Expression "$install_mongo_script -binDir $binDir"
|
||||||
{
|
|
||||||
"Downloading mongodb ..."
|
|
||||||
$webClient.DownloadFile($MONGODB_URL, $TEMP_MONGODB_ZIP)
|
|
||||||
"Unzipping mongodb"
|
|
||||||
Expand-Archive $TEMP_MONGODB_ZIP -DestinationPath $binDir
|
|
||||||
# Get unzipped folder's name
|
|
||||||
$mongodb_folder = Get-ChildItem -Path $binDir | Where-Object -FilterScript {
|
|
||||||
($_.Name -like "mongodb*")
|
|
||||||
} | Select-Object -ExpandProperty Name
|
|
||||||
# Move all files from extracted folder to mongodb folder
|
|
||||||
New-Item -ItemType directory -Path (Join-Path -Path $binDir -ChildPath "mongodb")
|
|
||||||
"Moving extracted files"
|
|
||||||
Move-Item -Path (Join-Path -Path $binDir -ChildPath $mongodb_folder | Join-Path -ChildPath "\bin\*") -Destination (Join-Path -Path $binDir -ChildPath "mongodb\")
|
|
||||||
"Removing zip file"
|
|
||||||
Remove-Item $TEMP_MONGODB_ZIP
|
|
||||||
Remove-Item (Join-Path -Path $binDir -ChildPath $mongodb_folder) -Recurse
|
|
||||||
}
|
|
||||||
|
|
||||||
# Download OpenSSL
|
# Download OpenSSL
|
||||||
"Downloading OpenSSL ..."
|
"Downloading OpenSSL ..."
|
||||||
|
|
|
@ -10,25 +10,28 @@ MONGODB_DIR=$1 # If using deb, this should be: /var/monkey/monkey_island/bin/mon
|
||||||
|
|
||||||
if [[ ${os_version_monkey} == "Ubuntu 16.04"* ]]; then
|
if [[ ${os_version_monkey} == "Ubuntu 16.04"* ]]; then
|
||||||
echo Detected Ubuntu 16.04
|
echo Detected Ubuntu 16.04
|
||||||
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.2.3.tgz"
|
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.2.20.tgz"
|
||||||
elif [[ ${os_version_monkey} == "Ubuntu 18.04"* ]]; then
|
elif [[ ${os_version_monkey} == "Ubuntu 18.04"* ]]; then
|
||||||
echo Detected Ubuntu 18.04
|
echo Detected Ubuntu 18.04
|
||||||
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.3.tgz"
|
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.20.tgz"
|
||||||
elif [[ ${os_version_monkey} == "Ubuntu 19.10"* ]]; then
|
elif [[ ${os_version_monkey} == "Ubuntu 19.10"* ]]; then
|
||||||
echo Detected Ubuntu 19.10
|
echo Detected Ubuntu 19.10
|
||||||
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.3.tgz"
|
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.20.tgz"
|
||||||
elif [[ ${os_version_monkey} == "Ubuntu 20.04"* ]]; then
|
elif [[ ${os_version_monkey} == "Ubuntu 20.04"* ]]; then
|
||||||
echo Detected Ubuntu 20.04
|
echo Detected Ubuntu 20.04
|
||||||
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.0.tgz"
|
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.14.tgz"
|
||||||
|
elif [[ ${os_version_monkey} == "Ubuntu 22.04"* ]]; then
|
||||||
|
echo Detected Ubuntu 22.04
|
||||||
|
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.14.tgz"
|
||||||
elif [[ ${os_version_monkey} == "Debian GNU/Linux 9"* ]]; then
|
elif [[ ${os_version_monkey} == "Debian GNU/Linux 9"* ]]; then
|
||||||
echo Detected Debian 9
|
echo Detected Debian 9
|
||||||
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian92-4.2.3.tgz"
|
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian92-4.2.20.tgz"
|
||||||
elif [[ ${os_version_monkey} == "Debian GNU/Linux 10"* ]]; then
|
elif [[ ${os_version_monkey} == "Debian GNU/Linux 10"* ]]; then
|
||||||
echo Detected Debian 10
|
echo Detected Debian 10
|
||||||
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-4.2.3.tgz"
|
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-4.2.20.tgz"
|
||||||
elif [[ ${os_version_monkey} == "Kali GNU/Linux"* ]]; then
|
elif [[ ${os_version_monkey} == "Kali GNU/Linux"* ]]; then
|
||||||
echo Detected Kali Linux
|
echo Detected Kali Linux
|
||||||
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-4.2.3.tgz"
|
export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-4.2.20.tgz"
|
||||||
else
|
else
|
||||||
echo Unsupported OS
|
echo Unsupported OS
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true, Position = 0)]
|
||||||
|
[String]$binDir
|
||||||
|
)
|
||||||
|
|
||||||
|
$MONGODB_URL = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2012plus-4.2.20.zip"
|
||||||
|
$TEMP_MONGODB_ZIP = (Join-Path -path $(Get-Location) -ChildPath ".\mongodb.zip")
|
||||||
|
|
||||||
|
|
||||||
|
if (!(Test-Path -Path (Join-Path -Path $binDir -ChildPath "mongodb")))
|
||||||
|
{
|
||||||
|
"Downloading mongodb ..."
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile($MONGODB_URL, $TEMP_MONGODB_ZIP)
|
||||||
|
|
||||||
|
"Unzipping mongodb"
|
||||||
|
Expand-Archive $TEMP_MONGODB_ZIP -DestinationPath $binDir
|
||||||
|
|
||||||
|
# Get unzipped folder's name
|
||||||
|
$mongodb_folder_name = Get-ChildItem -Path $binDir | Where-Object -FilterScript {
|
||||||
|
($_.Name -like "mongodb*")
|
||||||
|
} | Select-Object -ExpandProperty Name
|
||||||
|
|
||||||
|
Write-Output $mongodb_folder_name
|
||||||
|
|
||||||
|
# Move mongod file and license file from extracted folder to mongodb folder
|
||||||
|
New-Item -ItemType directory -Path (Join-Path -Path $binDir -ChildPath "mongodb")
|
||||||
|
"Moving extracted mongod and license files"
|
||||||
|
$mongodb_folder_path = (Join-Path -Path $binDir -ChildPath $mongodb_folder_name)
|
||||||
|
$mongodb_bin_folder_path = (Join-Path -Path $mongodb_folder_path -ChildPath "\bin\")
|
||||||
|
$mongod_binary = (Join-Path -Path $mongodb_bin_folder_path -ChildPath "mongod.exe")
|
||||||
|
$license_file = (Join-Path -Path $mongodb_folder_path -ChildPath "LICENSE-Community.txt")
|
||||||
|
Move-Item -Path $mongod_binary -Destination (Join-Path -Path $binDir -ChildPath "mongodb\")
|
||||||
|
Move-Item -Path $license_file -Destination (Join-Path -Path $binDir -ChildPath "mongodb\")
|
||||||
|
|
||||||
|
"Removing zip file and folder with extracted contents"
|
||||||
|
Remove-Item $TEMP_MONGODB_ZIP
|
||||||
|
Remove-Item $mongodb_folder_path -Recurse
|
||||||
|
}
|
Loading…
Reference in New Issue