diff --git a/agent/agent/delete.go b/agent/agent/delete.go index af51fca85..58348cd02 100644 --- a/agent/agent/delete.go +++ b/agent/agent/delete.go @@ -39,6 +39,6 @@ func DeleteAgent(cnf *config.Config) error { utils.Logger.ErrorF("error removing UTMStack Agent from Agent Manager %v", err) } - utils.Logger.Info("UTMStack Agent removed successfully") + utils.Logger.LogF(100, "UTMStack Agent removed successfully from agent manager") return nil } diff --git a/agent/collectors/windows_arm64.go b/agent/collectors/windows_arm64.go index fd79ff628..a71bd68e7 100644 --- a/agent/collectors/windows_arm64.go +++ b/agent/collectors/windows_arm64.go @@ -185,6 +185,8 @@ func (w Windows) SendSystemLogs() { return } + utils.Logger.LogF(100, "output: %s", string(output)) + logLines := strings.Split(string(output), "\n") validatedLogs := make([]string, 0, len(logLines)) @@ -192,7 +194,7 @@ func (w Windows) SendSystemLogs() { for _, logLine := range logLines { validatedLog, _, err := validations.ValidateString(logLine, false) if err != nil { - _ = utils.Logger.LogF(100, "error validating log: %s: %v", logLine, err) + utils.Logger.LogF(100, "error validating log: %s: %v", logLine, err) continue } diff --git a/agent/main.go b/agent/main.go index 6a4ab80ed..c733479d6 100644 --- a/agent/main.go +++ b/agent/main.go @@ -109,15 +109,13 @@ func main() { time.Sleep(5 * time.Second) case "uninstall": - fmt.Println("Uninstalling UTMStackAgent service ...") + fmt.Print("Uninstalling UTMStackAgent service ...") cnf, err := config.GetCurrentConfig() if err != nil { fmt.Println("Error getting config: ", err) os.Exit(1) } - - fmt.Print("Deleting agent ... ") if err = pb.DeleteAgent(cnf); err != nil { utils.Logger.ErrorF("error deleting agent: %v", err) } @@ -127,7 +125,9 @@ func main() { os.Remove(config.ConfigurationFile) serv.UninstallService() - utils.Logger.Info("UTMStackAgent service uninstalled correctly") + + fmt.Println("[OK]") + fmt.Println("UTMStackAgent service uninstalled correctly") os.Exit(1) case "help": Help() diff --git a/agent/version.json b/agent/version.json index 641e8961a..aa29fc441 100644 --- a/agent/version.json +++ b/agent/version.json @@ -1,3 +1,3 @@ { - "version": "10.6.0" + "version": "10.7.0" } diff --git a/frontend/src/app/app-module/app-module.module.ts b/frontend/src/app/app-module/app-module.module.ts index 49d68445d..a108810d4 100644 --- a/frontend/src/app/app-module/app-module.module.ts +++ b/frontend/src/app/app-module/app-module.module.ts @@ -55,7 +55,8 @@ import {UtmListComponent} from './guides/shared/components/utm-list.component'; import {ModuleIntegrationComponent} from './module-integration/module-integration.component'; import {AppModuleSharedModule} from './shared/app-module-shared.module'; import {LogCollectorComponent} from './guides/shared/components/log-collector.component'; -import {InstallLogCollectorComponent} from "./guides/shared/components/install-log-collector.component"; +import {InstallLogCollectorComponent} from './guides/shared/components/install-log-collector.component'; +import {AgentInstallSelectorComponent} from './guides/shared/components/agent-install-selector.component'; @NgModule({ @@ -111,7 +112,8 @@ import {InstallLogCollectorComponent} from "./guides/shared/components/install-l StepComponent, StepDirective, LogCollectorComponent, - InstallLogCollectorComponent + InstallLogCollectorComponent, + AgentInstallSelectorComponent ], imports: [ CommonModule, diff --git a/frontend/src/app/app-module/guides/guide-as400/constants.ts b/frontend/src/app/app-module/guides/guide-as400/constants.ts index b733c13d2..37f0201ed 100644 --- a/frontend/src/app/app-module/guides/guide-as400/constants.ts +++ b/frontend/src/app/app-module/guides/guide-as400/constants.ts @@ -4,13 +4,13 @@ export const PLATFORM = [ id: 1, name: 'WINDOWS', install: `New-Item -ItemType Directory -Force -Path "C:\\Program Files\\UTMStack\\UTMStack Collectors\\AS400"; ` + - `cd "C:\\Program Files\\UTMStack\\UTMStack Collectors\\AS400"; ` + - `Invoke-WebRequest -Uri "https://cdn.utmstack.com/collectors/as400/v3.0.1/windows-as400-collector.zip" ` + - `-OutFile ".\\windows-as400-collector.zip"; Expand-Archive -Path ".\\windows-as400-collector.zip" ` + - `-DestinationPath "."; Remove-Item ".\\windows-as400-collector.zip"; Start-Process ".\\utmstack_collectors_installer.exe" ` + - `-ArgumentList 'install', 'as400', 'V_IP', 'V_TOKEN' -NoNewWindow -Wait`, + `cd "C:\\Program Files\\UTMStack\\UTMStack Collectors\\AS400"; ` + + `Invoke-WebRequest -Uri "https://V_IP:9001/private/dependencies/collector/windows-as400-collector.zip" ` + + `-OutFile ".\\windows-as400-collector.zip"; Expand-Archive -Path ".\\windows-as400-collector.zip" ` + + `-DestinationPath "."; Remove-Item ".\\windows-as400-collector.zip"; Start-Process ".\\utmstack_collectors_installer.exe" ` + + `-ArgumentList 'install', 'as400', 'V_IP', 'V_TOKEN' -NoNewWindow -Wait`, - uninstall: `cd "C:\\Program Files\\UTMStack\\UTMStack Collectors\\AS400"; ` + + uninstall: `cd "C:\\Program Files\\UTMStack\\UTMStack Collectors\\AS400"; ` + `Start-Process ".\\utmstack_collectors_installer.exe" -ArgumentList ` + ` 'uninstall', 'as400' -NoNewWindow -Wait -ErrorAction SilentlyContinue ` + `| Out-Null; Start-Process -FilePath "sc.exe" -ArgumentList 'stop', ` + @@ -28,13 +28,15 @@ export const PLATFORM = [ id: 2, name: 'LINUX UBUNTU', install: `sudo bash -c "apt update -y && apt install wget unzip -y && mkdir -p ` + - `/opt/utmstack-linux-collectors/as400 && cd /opt/utmstack-linux-collectors/as400 && ` + - `wget https://cdn.utmstack.com/collectors/as400/v3.0.1/linux-as400-collector.zip ` + - `&& unzip linux-as400-collector.zip && rm linux-as400-collector.zip && chmod -R 777 ` + - `utmstack_collectors_installer && ./utmstack_collectors_installer install as400 ` + - `V_IP V_TOKEN"`, + `/opt/utmstack-linux-collectors/as400 && cd /opt/utmstack-linux-collectors/as400 && ` + + `wget --no-check-certificate --header='connection-key: V_TOKEN' ` + + `https://V_IP:9001/private/dependencies/collector/linux-as400-collector.zip ` + + `&& unzip linux-as400-collector.zip && rm linux-as400-collector.zip && chmod -R 777 ` + + `utmstack_collectors_installer && ./utmstack_collectors_installer install as400 ` + + `V_IP V_TOKEN"`, - uninstall: `sudo bash -c " cd /opt/utmstack-linux-collectors/as400 && ./utmstack_collectors_installer ` + + + uninstall: `sudo bash -c " cd /opt/utmstack-linux-collectors/as400 && ./utmstack_collectors_installer ` + `uninstall as400 && echo 'Removing UTMStack AS400 Collector dependencies...' && sleep 5 && rm ` + `-rf /opt/utmstack-linux-collectors/as400 && echo 'UTMStack AS400 Collector removed successfully.'"`, diff --git a/frontend/src/app/app-module/guides/guide-linux-agent/guide-linux-agent.component.html b/frontend/src/app/app-module/guides/guide-linux-agent/guide-linux-agent.component.html index eafe2f6f8..7aaa173a6 100644 --- a/frontend/src/app/app-module/guides/guide-linux-agent/guide-linux-agent.component.html +++ b/frontend/src/app/app-module/guides/guide-linux-agent/guide-linux-agent.component.html @@ -16,31 +16,14 @@

1 - Install according to your operating system: + Install or uninstall the UTMStack agent according to your operating system:

The following commands contains sensitive information, don't share it.
-
Ubuntu 16/18/20+
- - - -
Centos 7/Red Hat Enterprise Linux
- - - -
Centos 8/AlmaLinux
- - +
-
- The next information is not part of the installation process, is just in case you need to uninstall the agent -
-

- To uninstall linux agent, run the following command: - -

diff --git a/frontend/src/app/app-module/guides/guide-linux-agent/guide-linux-agent.component.ts b/frontend/src/app/app-module/guides/guide-linux-agent/guide-linux-agent.component.ts index 3a9d15653..7e0966211 100644 --- a/frontend/src/app/app-module/guides/guide-linux-agent/guide-linux-agent.component.ts +++ b/frontend/src/app/app-module/guides/guide-linux-agent/guide-linux-agent.component.ts @@ -14,6 +14,27 @@ export class GuideLinuxAgentComponent implements OnInit { @Input() version: string; token: string; + architectures = [ + { + id: 1, name: 'Ubuntu 16/18/20+', + install: this.getCommandUbuntu('utmstack-linux-agent'), + uninstall: this.getUninstallCommand('utmstack-linux-agent'), + shell: '' + }, + { + id: 2, name: 'Centos 7/Red Hat Enterprise Linux', + install: this.getCommandCentos7RedHat('utmstack-linux-agent'), + uninstall: this.getUninstallCommand('utmstack-linux-agent'), + shell: '' + }, + { + id: 3, name: 'Centos 8/AlmaLinux', + install: this.getCommandCentos8Almalinux('utmstack-linux-agent'), + uninstall: this.getUninstallCommand('utmstack-linux-agent'), + shell: '' + } + ]; + constructor(private federationConnectionService: FederationConnectionService) { } ngOnInit() { @@ -31,33 +52,38 @@ export class GuideLinuxAgentComponent implements OnInit { }); } - getCommandUbuntu(): string { + getCommandUbuntu(installerName: string): string { const ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host; return `sudo bash -c "apt update -y && apt install wget -y && mkdir -p /opt/utmstack-linux-agent && \ - wget -P /opt/utmstack-linux-agent https://cdn.utmstack.com/agent_updates/release/installer/v${this.version}/utmstack_agent_installer && \ - chmod -R 777 /opt/utmstack-linux-agent/utmstack_agent_installer && \ - /opt/utmstack-linux-agent/utmstack_agent_installer install ${ip} ${this.token} yes"`; + wget --no-check-certificate --header='connection-key: ${this.token}' -P /opt/utmstack-linux-agent \ + https://${ip}:9001/private/dependencies/agent/${installerName} && \ + chmod -R 777 /opt/utmstack-linux-agent/${installerName} && \ + /opt/utmstack-linux-agent/${installerName} install ${ip} ${this.token} yes"`; } - getCommandCentos7RedHat(): string { - const ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host; - return `sudo bash -c "yum install wget -y && mkdir /opt/utmstack-linux-agent && wget -P /opt/utmstack-linux-agent \ - https://cdn.utmstack.com/agent_updates/release/installer/v${this.version}/utmstack_agent_installer && \ - chmod -R 777 /opt/utmstack-linux-agent/utmstack_agent_installer && \ - /opt/utmstack-linux-agent/utmstack_agent_installer install ${ip} ${this.token} yes"`; + getCommandCentos7RedHat(installerName: string): string { + const ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host; + return `sudo bash -c "yum install wget -y && mkdir -p /opt/utmstack-linux-agent && \ + wget --no-check-certificate --header='connection-key: ${this.token}' -P /opt/utmstack-linux-agent \ + https://${ip}:9001/private/dependencies/agent/${installerName} && \ + chmod -R 777 /opt/utmstack-linux-agent/${installerName} && \ + /opt/utmstack-linux-agent/${installerName} install ${ip} ${this.token} yes"`; } - getCommandCentos8Almalinux(): string { + + getCommandCentos8Almalinux(installerName: string): string { const ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host; - return `sudo bash -c "dnf install wget -y && mkdir /opt/utmstack-linux-agent && \ - wget -P /opt/utmstack-linux-agent https://cdn.utmstack.com/agent_updates/release/installer/v${this.version}/utmstack_agent_installer && \ - chmod -R 777 /opt/utmstack-linux-agent/utmstack_agent_installer && \ - /opt/utmstack-linux-agent/utmstack_agent_installer install ${ip} ${this.token} yes"`; + return `sudo bash -c "dnf install wget -y && mkdir -p /opt/utmstack-linux-agent && \ + wget --no-check-certificate --header='connection-key: ${this.token}' -P /opt/utmstack-linux-agent \ + https://${ip}:9001/private/dependencies/agent/${installerName} && \ + chmod -R 777 /opt/utmstack-linux-agent/${installerName} && \ + /opt/utmstack-linux-agent/${installerName} install ${ip} ${this.token} yes"`; } - getUninstallCommand(): string { - return `sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_installer uninstall || true; \ + + getUninstallCommand(installerName: string): string { + return `sudo bash -c "/opt/utmstack-linux-agent/${installerName} uninstall || true; \ systemctl stop UTMStackAgent 2>/dev/null || true; systemctl disable UTMStackAgent 2>/dev/null || true; \ rm /etc/systemd/system/UTMStackAgent.service 2>/dev/null || true; systemctl stop UTMStackRedline 2>/dev/null || true; \ systemctl disable UTMStackRedline 2>/dev/null || true; rm /etc/systemd/system/UTMStackRedline.service 2>/dev/null || true; \ @@ -69,4 +95,5 @@ export class GuideLinuxAgentComponent implements OnInit { echo 'Removing UTMStack Agent dependencies...' && sleep 10 && rm -rf /opt/utmstack-linux-agent && \ echo 'UTMStack Agent dependencies removed successfully.'"`; } + } diff --git a/frontend/src/app/app-module/guides/guide-winlogbeat/guide-winlogbeat.component.html b/frontend/src/app/app-module/guides/guide-winlogbeat/guide-winlogbeat.component.html index 2d7d3f927..db1f473d1 100644 --- a/frontend/src/app/app-module/guides/guide-winlogbeat/guide-winlogbeat.component.html +++ b/frontend/src/app/app-module/guides/guide-winlogbeat/guide-winlogbeat.component.html @@ -19,33 +19,12 @@

  • 2 - To install windows agent, open a Windows powershell terminal as "Administrator" and run the following - command: + To install or uninstall the UTMStack agent, open a Windows PowerShell terminal as "Administrator" and run the following command:

    The following command contains sensitive information, don't share it.
    - +
  • - - - - - - - - - - - -
    - The next information is not part of the installation process, is just in case you need to uninstall the agent -
    -

    - To uninstall windows agent, open a Windows powershell terminal as "Administrator" and run the following - command: - -

    - diff --git a/frontend/src/app/app-module/guides/guide-winlogbeat/guide-winlogbeat.component.ts b/frontend/src/app/app-module/guides/guide-winlogbeat/guide-winlogbeat.component.ts index 844914d98..1959f773c 100644 --- a/frontend/src/app/app-module/guides/guide-winlogbeat/guide-winlogbeat.component.ts +++ b/frontend/src/app/app-module/guides/guide-winlogbeat/guide-winlogbeat.component.ts @@ -14,6 +14,21 @@ export class GuideWinlogbeatComponent implements OnInit { token: string; @Input() version: string; + architectures = [ + { + id: 1, name: 'AMD64', + install: this.getCommand('utmstack_agent_service.exe'), + uninstall: this.getUninstallCommand('utmstack_agent_service.exe'), + shell: 'Windows Powershell terminal as “ADMINISTRATOR”' + }, + { + id: 2, name: 'ARM64', + install: this.getCommand('utmstack_agent_service_arm64.exe'), + uninstall: this.getUninstallCommand('utmstack_agent_service_arm64.exe'), + shell: 'Windows Powershell terminal as “ADMINISTRATOR”' + } + ]; + constructor(private federationConnectionService: FederationConnectionService) { } @@ -32,29 +47,31 @@ export class GuideWinlogbeatComponent implements OnInit { }); } - getCommand(): string { + getCommand(arch: string): string { const ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host; + return `New-Item -ItemType Directory -Force -Path "C:\\Program Files\\UTMStack\\UTMStack Agent"; ` + - `Invoke-WebRequest -Uri "https://cdn.utmstack.com/agent_updates/release/installer/v${this.version}/utmstack_agent_installer.exe" ` + - `-OutFile "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_installer.exe"; ` + - `Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_installer.exe" ` + - `-ArgumentList 'install', '` + ip + `', '` + this.token + `', 'yes' -NoNewWindow -Wait`; + `& curl.exe -k -H "connection-key: ${this.token}" ` + + `-o "C:\\Program Files\\UTMStack\\UTMStack Agent\\${arch}" ` + + `"https://${ip}:9001/private/dependencies/agent/${arch}"; ` + + `Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\${arch}" ` + + `-ArgumentList 'install', '${ip}', '${this.token}', 'yes' -NoNewWindow -Wait`; } - getUninstallCommand(): string { - return `Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_installer.exe" -ArgumentList ` + - `'uninstall' -NoNewWindow -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'stop','UTMStackAgent' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'delete','UTMStackAgent' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'stop','UTMStackRedline' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'delete','UTMStackRedline' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'stop','UTMStackUpdater' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'delete','UTMStackUpdater' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'stop','UTMStackWindowsLogsCollector' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'delete','UTMStackWindowsLogsCollector' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'stop','UTMStackModulesLogsCollector' -Wait -ErrorAction SilentlyContinue | Out-Null; Start-Process -FilePath "sc.exe" ` + - `-ArgumentList 'delete','UTMStackModulesLogsCollector' -Wait -ErrorAction SilentlyContinue | Out-Null; ` + - `Write-Host "Removing UTMStack Agent dependencies..."; Start-Sleep -Seconds 10; Remove-Item 'C:\\Program Files\\UTMStack\\UTMStack Agent' ` + - `-Recurse -Force -ErrorAction Stop; Write-Host "UTMStack Agent removed successfully."`; + + getUninstallCommand(arch: string): string { + return `Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\${arch}" ` + + `-ArgumentList 'uninstall' -NoNewWindow -Wait -ErrorAction SilentlyContinue | Out-Null; ` + + `Start-Process -FilePath "sc.exe" -ArgumentList 'stop','UTMStackAgent' -Wait -ErrorAction SilentlyContinue | Out-Null; ` + + `Start-Process -FilePath "sc.exe" -ArgumentList 'delete','UTMStackAgent' -Wait -ErrorAction SilentlyContinue | Out-Null; ` + + `Start-Process -FilePath "sc.exe" -ArgumentList 'stop','UTMStackWindowsLogsCollector' -Wait -ErrorAction SilentlyContinue | Out-Null; ` + + `Start-Process -FilePath "sc.exe" -ArgumentList 'delete','UTMStackWindowsLogsCollector' -Wait -ErrorAction SilentlyContinue | Out-Null; ` + + `Start-Process -FilePath "sc.exe" -ArgumentList 'stop','UTMStackModulesLogsCollector' -Wait -ErrorAction SilentlyContinue | Out-Null; ` + + `Start-Process -FilePath "sc.exe" -ArgumentList 'delete','UTMStackModulesLogsCollector' -Wait -ErrorAction SilentlyContinue | Out-Null; ` + + `Write-Host "Removing UTMStack Agent dependencies..."; ` + + `Start-Sleep -Seconds 10; ` + + `Remove-Item 'C:\\Program Files\\UTMStack\\UTMStack Agent' -Recurse -Force -ErrorAction Stop; ` + + `Write-Host "UTMStack Agent removed successfully."`; } + } diff --git a/frontend/src/app/app-module/guides/shared/components/agent-install-selector.component.ts b/frontend/src/app/app-module/guides/shared/components/agent-install-selector.component.ts new file mode 100644 index 000000000..d7425020a --- /dev/null +++ b/frontend/src/app/app-module/guides/shared/components/agent-install-selector.component.ts @@ -0,0 +1,122 @@ +import {ChangeDetectionStrategy, Component, Input} from '@angular/core'; +import {ModalService} from '../../../../core/modal/modal.service'; +import { + ModalConfirmationComponent +} from '../../../../shared/components/utm/util/modal-confirmation/modal-confirmation.component'; +import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum'; + +@Component({ + selector: 'app-agent-install-selector', + template: ` +
    + + + + + + +
    + + {{selectedPlatform.shell}} + + + `, + styles: [` + .flex-container { + display: flex; + } + + .flex-item { + flex-grow: 1; + margin-right: 10px; + } + `], + changeDetection: ChangeDetectionStrategy.OnPush +}) + +export class AgentInstallSelectorComponent { + + @Input() protocols = []; + + actions = [ + {id: 1, name: 'INSTALL', action: 'install'}, + {id: 2, name: 'UNINSTALL', action: 'uninstall'} + ]; + + @Input() platforms = []; + + @Input() agent: string; + + _selectedProtocol: any; + _selectedPlatform: any; + _selectedAction: any; + module = UtmModulesEnum; + + constructor(private modalService: ModalService) { + } + + get command() { + return this.selectedPlatform[this.selectedAction.action]; + } + + get selectedPlatform() { + return this._selectedPlatform; + } + + set selectedPlatform(platform) { + this._selectedPlatform = platform; + } + + get selectedProtocol() { + return this._selectedProtocol; + } + + set selectedProtocol(protocol) { + this._selectedProtocol = protocol; + } + + get selectedAction() { + return this._selectedAction; + } + + set selectedAction(action) { + this._selectedAction = action; + } + + onChangeAction(action: any) { + console.log(action); + if (this.selectedPlatform && action.name === 'UNINSTALL') { + this.openModal(); + } + } + + openModal() { + const modalSource = this.modalService.open(ModalConfirmationComponent, {centered: true}); + + modalSource.componentInstance.header = 'Disable integration command'; + modalSource.componentInstance.message = 'The following command is to disable the integration. ' + + 'Running this command could cause irreversible damage to your infrastructure. ' + + 'Only continue if you are sure what you are doing and really want to disable the integration.'; + modalSource.componentInstance.confirmBtnText = 'Accept'; + modalSource.componentInstance.confirmBtnIcon = 'icon-cog3'; + modalSource.componentInstance.confirmBtnType = 'default'; + modalSource.componentInstance.hideBtnCancel = true; + modalSource.result.then(() => { + + }); + } +}