From 36faa9f5a337ffe5209b6902a692a529bfa51482 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 11 May 2022 16:21:32 +0530 Subject: [PATCH 1/6] Build: Update MongoDB links in install_mongo.sh --- monkey/monkey_island/linux/install_mongo.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/monkey/monkey_island/linux/install_mongo.sh b/monkey/monkey_island/linux/install_mongo.sh index 825daaf5a..454f18e69 100755 --- a/monkey/monkey_island/linux/install_mongo.sh +++ b/monkey/monkey_island/linux/install_mongo.sh @@ -10,25 +10,25 @@ MONGODB_DIR=$1 # If using deb, this should be: /var/monkey/monkey_island/bin/mon if [[ ${os_version_monkey} == "Ubuntu 16.04"* ]]; then 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 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 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 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} == "Debian GNU/Linux 9"* ]]; then 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 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 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 echo Unsupported OS exit 1 From 3e5ae392c9072522291c310407456b727518650f Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 12 May 2022 17:03:38 +0530 Subject: [PATCH 2/6] Build: Create separate mongo installation script for Windows --- deployment_scripts/config.ps1 | 2 - deployment_scripts/deploy_windows.ps1 | 21 +---------- .../monkey_island/windows/install_mongo.ps1 | 37 +++++++++++++++++++ 3 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 monkey/monkey_island/windows/install_mongo.ps1 diff --git a/deployment_scripts/config.ps1 b/deployment_scripts/config.ps1 index b14d095e7..1f33d0e8a 100644 --- a/deployment_scripts/config.ps1 +++ b/deployment_scripts/config.ps1 @@ -21,7 +21,6 @@ $WINDOWS_64_BINARY_PATH = "monkey-windows-64.exe" $MONKEY_ISLAND_DIR = Join-Path "\monkey" -ChildPath "monkey_island" $MONKEY_DIR = Join-Path "\monkey" -ChildPath "infection_monkey" $TEMP_PYTHON_INSTALLER = ".\python.exe" -$TEMP_MONGODB_ZIP = ".\mongodb.zip" $TEMP_OPEN_SSL_ZIP = ".\openssl.zip" $TEMP_CPP_INSTALLER = "cpp.exe" $TEMP_NPM_INSTALLER = "node.msi" @@ -29,7 +28,6 @@ $TEMP_UPX_ZIP = "upx.zip" $UPX_FOLDER = "upx-3.96-win64" # 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" $CPP_URL = "https://go.microsoft.com/fwlink/?LinkId=746572" $NPM_URL = "https://nodejs.org/dist/v16.14.2/node-v16.14.2-x64.msi" diff --git a/deployment_scripts/deploy_windows.ps1 b/deployment_scripts/deploy_windows.ps1 index 1260dfafb..b151834ed 100644 --- a/deployment_scripts/deploy_windows.ps1 +++ b/deployment_scripts/deploy_windows.ps1 @@ -163,25 +163,8 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName, [Environment]::SetEnvironmentVariable("Path", $env:Path, "User") } - # Download mongodb - if (!(Test-Path -Path (Join-Path -Path $binDir -ChildPath "mongodb"))) - { - "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 - } + $install_mongo_script = (Join-Path -Path $monkey_home -ChildPath "$MONKEY_ISLAND_DIR\windows\install_mongo.ps1") + Invoke-Expression "$install_mongo_script -binDir $binDir" # Download OpenSSL "Downloading OpenSSL ..." diff --git a/monkey/monkey_island/windows/install_mongo.ps1 b/monkey/monkey_island/windows/install_mongo.ps1 new file mode 100644 index 000000000..ec96e6522 --- /dev/null +++ b/monkey/monkey_island/windows/install_mongo.ps1 @@ -0,0 +1,37 @@ +param( + [Parameter(Mandatory = $true, Position = 0)] + [String]$binDir +) + +$MONGODB_URL = "https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2012plus-v4.2-latest.zip" +$TEMP_MONGODB_ZIP = ".\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 + + # 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 + } From ae500131b9138736a66dd4d8f20263489aa5ab2c Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 12 May 2022 17:14:49 +0530 Subject: [PATCH 3/6] Build: Update mongo download link for Windows --- monkey/monkey_island/windows/install_mongo.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/monkey_island/windows/install_mongo.ps1 b/monkey/monkey_island/windows/install_mongo.ps1 index ec96e6522..b6a3ff3c1 100644 --- a/monkey/monkey_island/windows/install_mongo.ps1 +++ b/monkey/monkey_island/windows/install_mongo.ps1 @@ -3,7 +3,7 @@ param( [String]$binDir ) -$MONGODB_URL = "https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2012plus-v4.2-latest.zip" +$MONGODB_URL = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2012plus-4.2.20.zip" $TEMP_MONGODB_ZIP = ".\mongodb.zip" From 8546330965789356f3cc0c6a162e799dd8efc0a8 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 12 May 2022 17:47:10 +0530 Subject: [PATCH 4/6] Changelog: Add entry for MongoDB upgrade --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 374815c82..27bf5e27f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). - The "/api/netmap/nodeStates" endpoint to "/api/netmap/node-states". #1888 - All "/api/monkey_control" endpoints to "/api/monkey-control". #1888 - All "/api/monkey" endpoints to "/api/agent". #1888 +- Update MongoDB version to 4.4.x. #1924 ### Removed - VSFTPD exploiter. #1533 From 3b10a915265e9dcf56678de4a7529022283f0596 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 12 May 2022 18:52:52 +0530 Subject: [PATCH 5/6] Island: Modify temporary mongodb zip path in linux mongo installation script --- monkey/monkey_island/windows/install_mongo.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/windows/install_mongo.ps1 b/monkey/monkey_island/windows/install_mongo.ps1 index b6a3ff3c1..4f7b3aa4e 100644 --- a/monkey/monkey_island/windows/install_mongo.ps1 +++ b/monkey/monkey_island/windows/install_mongo.ps1 @@ -4,7 +4,7 @@ param( ) $MONGODB_URL = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2012plus-4.2.20.zip" -$TEMP_MONGODB_ZIP = ".\mongodb.zip" +$TEMP_MONGODB_ZIP = (Join-Path -path $(Get-Location) -ChildPath ".\mongodb.zip") if (!(Test-Path -Path (Join-Path -Path $binDir -ChildPath "mongodb"))) @@ -21,6 +21,8 @@ if (!(Test-Path -Path (Join-Path -Path $binDir -ChildPath "mongodb"))) ($_.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" From 029ff379c1805854794a127bedf62b913f9e036c Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 12 May 2022 19:09:10 +0530 Subject: [PATCH 6/6] Island: Add condition for Ubuntu 22.04 in mongo installation script --- monkey/monkey_island/linux/install_mongo.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/monkey/monkey_island/linux/install_mongo.sh b/monkey/monkey_island/linux/install_mongo.sh index 454f18e69..891a1ea29 100755 --- a/monkey/monkey_island/linux/install_mongo.sh +++ b/monkey/monkey_island/linux/install_mongo.sh @@ -20,6 +20,9 @@ elif [[ ${os_version_monkey} == "Ubuntu 19.10"* ]]; then elif [[ ${os_version_monkey} == "Ubuntu 20.04"* ]]; then echo Detected Ubuntu 20.04 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 echo Detected Debian 9 export tgz_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian92-4.2.20.tgz"