From 55dae3f29d477618bd42be222366deddad2f6a46 Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 8 Jan 2021 15:15:15 +0530 Subject: [PATCH] Minor code changes --- .../commands/local_linux_curl.js | 19 +++++++++++-------- .../commands/local_linux_wget.js | 19 +++++++++++-------- .../commands/local_windows_cmd.js | 8 +++++--- .../commands/local_windows_powershell.js | 9 ++++++--- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_linux_curl.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_linux_curl.js index a837d237e..ed9ffdec6 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_linux_curl.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_linux_curl.js @@ -2,12 +2,15 @@ import {OS_TYPES} from '../utils/OsTypes'; export default function generateLocalLinuxCurl(ip, osType, username) { - let bitText = osType === OS_TYPES.LINUX_32 ? '32' : '64'; - let command = `curl https://${ip}:5000/api/monkey/download/monkey-linux-${bitText} -k ` - + `-o monkey-linux-${bitText}; ` - + `chmod +x monkey-linux-${bitText}; ` - + `./monkey-linux-${bitText} m0nk3y -s ${ip}:5000;`; - if (username != '') - command = `su - ${username} -c "${command}"`; - return command; + let bitText = osType === OS_TYPES.LINUX_32 ? '32' : '64'; + let command = `curl https://${ip}:5000/api/monkey/download/monkey-linux-${bitText} -k ` + + `-o monkey-linux-${bitText}; ` + + `chmod +x monkey-linux-${bitText}; ` + + `./monkey-linux-${bitText} m0nk3y -s ${ip}:5000;`; + + if (username != '') { + command = `su - ${username} -c "${command}"`; } + + return command; +} diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_linux_wget.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_linux_wget.js index 08645b23d..3f47dc996 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_linux_wget.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_linux_wget.js @@ -2,12 +2,15 @@ import {OS_TYPES} from '../utils/OsTypes'; export default function generateLocalLinuxWget(ip, osType, username) { - let bitText = osType === OS_TYPES.LINUX_32 ? '32' : '64'; - let command = `wget --no-check-certificate https://${ip}:5000/api/monkey/download/` - + `monkey-linux-${bitText}; ` - + `chmod +x monkey-linux-${bitText}; ` - + `./monkey-linux-${bitText} m0nk3y -s ${ip}:5000`; - if (username != '') - command = `su - ${username} -c "${command}"`; - return command; + let bitText = osType === OS_TYPES.LINUX_32 ? '32' : '64'; + let command = `wget --no-check-certificate https://${ip}:5000/api/monkey/download/` + + `monkey-linux-${bitText}; ` + + `chmod +x monkey-linux-${bitText}; ` + + `./monkey-linux-${bitText} m0nk3y -s ${ip}:5000`; + + if (username != '') { + command = `su - ${username} -c "${command}"`; } + + return command; +} diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_windows_cmd.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_windows_cmd.js index 82cf35d8e..1f66740f6 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_windows_cmd.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_windows_cmd.js @@ -8,7 +8,9 @@ export default function generateLocalWindowsCmd(ip, osType, username) { + `monkey-windows-${bitText}.exe','.\\monkey.exe'); ` + `;Start-Process -FilePath '.\\monkey.exe' -ArgumentList 'm0nk3y -s ${ip}:5000';`; - if (username != '') - command = `runas /user:${username} "cmd /K ${command}"`; - return command; + if (username != '') { + command = `runas /user:${username} "cmd /K ${command}"`; + } + + return command; } diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_windows_powershell.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_windows_powershell.js index 7845a59c0..7244615ed 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_windows_powershell.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/commands/local_windows_powershell.js @@ -7,7 +7,10 @@ export default function generateLocalWindowsPowershell(ip, osType, username) { + `(New-Object System.Net.WebClient).DownloadFile('https://${ip}:5000/api/monkey/download/ ` + `monkey-windows-${bitText}.exe','.\\monkey.exe'); ` + `;Start-Process -FilePath '.\\monkey.exe' -ArgumentList 'm0nk3y -s ${ip}:5000';`; - if (username != '') - command = `Start-Process powershell.exe -ArgumentList "-noexit ${command}" -Credential ${username}`; - return command; + + if (username != '') { + command = `Start-Process powershell.exe -ArgumentList "-noexit ${command}" -Credential ${username}`; + } + + return command; }