UI: fix manual run command for powershell as a user

This commit is contained in:
VakarisZ 2021-11-05 09:47:59 +02:00
parent 9eff78fb60
commit 51eb6f2ce5
1 changed files with 11 additions and 6 deletions

View File

@ -1,15 +1,20 @@
import {OS_TYPES} from '../utils/OsTypes';
export default function generateLocalWindowsPowershell(ip, osType, username) {
export function getAgentDownloadCommand(ip, osType) {
let bitText = osType === OS_TYPES.WINDOWS_32 ? '32' : '64';
let command = `[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}; `
+ `(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';`;
return `$execCmd = @"\r\n`
+ `-noexit [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {\`$true};`
+ `(New-Object System.Net.WebClient).DownloadFile('https://${ip}:5000/api/monkey/download/monkey-windows-${bitText}.exe',`
+ `"""$env:TEMP\\monkey.exe""");Start-Process -FilePath '$env:TEMP\\monkey.exe' -ArgumentList 'm0nk3y -s ${ip}:5000';`
+ `\r\n"@; \r\n`
+ `Start-Process -FilePath powershell.exe -ArgumentList $execCmd`
}
export default function generateLocalWindowsPowershell(ip, osType, username) {
let command = getAgentDownloadCommand(ip, osType)
if (username != '') {
command = `Start-Process powershell.exe -ArgumentList "-noexit ${command}" -Credential ${username}`;
command += ` -Credential ${username}`;
}
return command;