[SOLVED] Trend Micro Apex One Security Agent update 6 package (build 11564)

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
olaplanche
Messages: 178
Registration: January 26, 2017 - 11:11

February 3, 2022 - 8:56 AM

:!: Updated 08/03/2023 :!: New version of the package, new use of the msi package created with the ClientPackagersource)

:!: The MSI file is generated using the Apex One server's ClientPackager :!:

The package code:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""

# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
bin_name = "TrendMicroSecurityAgent.msi"
properties = {
    'MyServer':'"myserver:8080|4343"',
    'MyDomain':'"Workgroup\Subdomain"',
    }

def install():
    # Initializing variables
    package_version = control.get_software_version()

    # Installing the package
    for to_update in installed_softwares('Trend Micro Apex One Security Agent'):
        if Version(to_update["version"]) < Version(package_version) or force:
            print(r"Upgrading: %s (%s)" % (bin_name, package_version))
            run(r'msiexec /fov "%s"' % bin_name) # If Agent already installed, upgrade.
    else:
        install_msi_if_needed(bin_name,properties=properties) # If Agent not installed, install.
For the uninstallation to work, simply disable the uninstallation password from the server console.
Last edited by olaplanche on March 8, 2023 - 10:44, edited 7 times.
- Installed WAPT version: 2.6.0.16795 Enterprise
- Server OS: Linux / Debian Bookworm
- Administration/package creation machine OS: Windows 10
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

February 3, 2022 - 10:38

Thank you for sharing :-)
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
gly
Messages: 24
Registration: May 30, 2019 - 11:45

February 3, 2022 - 11:02 AM

Thanks so much! One question though: how do you handle the fact that the Trend Micro agents update themselves automatically, and then when you update your WAPT package, it tries to update on the workstations as well?
I've tested it, and the problem is that the WAPT packages report errors because they're already up to date.
olaplanche
Messages: 178
Registration: January 26, 2017 - 11:11

February 3, 2022 - 11:19

I do not update the agent program via the Apex One server (configurable in the server, agent management, privileges and other settings).
When a new version of the agent program is released, a new MSI package must be generated using the server's ClientPackager, and the WAPT package must be updated ;)

EDIT: If the agent updates itself, and you update your package later, upon deploying the new package it will detect that the same version is already installed and will not reinstall it without error in the WAPT console
installing wapt-trend-micro-apex-one-security-agent
MSI TrendMicroSecurityAgent.msi already installed. Skipping msiexec
- Installed WAPT version: 2.6.0.16795 Enterprise
- Server OS: Linux / Debian Bookworm
- Administration/package creation machine OS: Windows 10
gly
Messages: 24
Registration: May 30, 2019 - 11:45

February 3, 2022 - 3:22 PM

EDIT: If the agent updates itself, and you update your package later, upon deploying the new package it will detect that the same version is already installed and will not reinstall it without error in the WAPT console
Are you sure about that? I remember making mistakes myself
gly
Messages: 24
Registration: May 30, 2019 - 11:45

February 3, 2022 - 4:15 PM

Indeed, it doesn't reinstall if it's already installed.

However, I can't find your setting regarding the registry keys. Is it because the password needs to be disabled during uninstallation? Or is it a difference in console version? I'm on build 10064.

Thanks.
olaplanche
Messages: 178
Registration: January 26, 2017 - 11:11

February 4, 2022 - 9:09 AM

Hello,

No, it's not necessary to disable the password during uninstallation in the server console.
I'm on an older build (9167), and haven't had time to update it yet...

The option is located in this menu:

Picture

EDIT: Link to the official documentation: https://docs.trendmicro.com/en-us/enter ... l_002.aspx
- Installed WAPT version: 2.6.0.16795 Enterprise
- Server OS: Linux / Debian Bookworm
- Administration/package creation machine OS: Windows 10
olaplanche
Messages: 178
Registration: January 26, 2017 - 11:11

May 24, 2022 - 1:25 PM

OK, I updated the server to build 10101 and the agent's self-protection options have indeed disappeared.
This is a deliberate choice by Trend Micro... source
Security Agent self-protection


Self-protection settings are automatically enabled and not configurable. Previous dependencies for the self-protection features have been removed to allow all Security Agents to be protected at all times.
Back to square one :(
- Installed WAPT version: 2.6.0.16795 Enterprise
- Server OS: Linux / Debian Bookworm
- Administration/package creation machine OS: Windows 10
olaplanche
Messages: 178
Registration: January 26, 2017 - 11:11

June 1, 2022 - 09:34

Firstly, in order for the installation and update of the agent to work when an uninstallation password is configured, you must not use the msi package (installation OK, update KO, the agent protection password is requested...).

An installation executable package must be created from the server that will work for installation and updates without requiring a password:
Picture

The adapted wapt package code:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = ['{1841AFE1-4BA7-44D4-8700-6ACF860A8ED1}']

def install():
    # Initializing variables
    package_version = control.get_software_version()

    # Vérification de la version pour gestion d'erreur
    for to_install in installed_softwares('Trend Micro Apex One Security Agent'):
        if Version(to_install["version"]) < Version(package_version) or force:
            print ('installing %s' % control.package)
            install_exe_if_needed('TrendMicroSecurityAgent.exe')
        else:
            print ('%s already installed' % control.package)
    uninstallkey.remove('{1841AFE1-4BA7-44D4-8700-6ACF860A8ED1}')
For uninstallation, I suggest two solutions that I have tested:

Solution 1:

Disabling the uninstall password from the server console will set the "Allow Uninstall" registry key to 1 on the agents. Uninstallation is possible with the following code:

Code: Select all

def uninstall():
    print ('uninstalling %s' % control.package)
    run(r'"msiexec.exe" /x {1841AFE1-4BA7-44D4-8700-6ACF860A8ED1} /qn')
Solution 2:

Uninstallation is possible with the following code without disabling the password in the admin console (the password will be in plain text in the package):

Code: Select all

def uninstall():
    print ('uninstalling %s' % control.package)
    run(r'"%s\Trend Micro\Security Agent\pccntmon.exe" -m <uninstall_password>' % programfiles32)
source

Some leads that did not pan out:

Creating the executable package from the packager client relies on the ofcscan.ini configuration file on the server; editing this file allows you to find the agent's self-protection options:
[INI_CLIENT_SECTION]
SP_EnableFileProtection = 1
SP_EnableRegistryKeyProtection = 1
SP_EnableProcessProtection = 1
Unfortunately, setting them to 0 doesn't seem to work...

However, in the registry of the following agent, the keys for the self-protection options are indeed found:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\TrendMicro\PC-cillinNTCorp\CurrentVersion\AEGIS
By setting the "SP_EnableRegistryKeyProtection" key to 0, registry protection is indeed disabled, so the "Allow Uninstall" key can be modified again from within a WAPT package without disabling the agent's password. The problem is that it's not possible to modify the "SP_EnableRegistryKeyProtection" key while the agent is running... You first have to close the agent, which then prompts for the password... in short, I don't see how to fully automate the uninstallation within a WAPT package.
- Installed WAPT version: 2.6.0.16795 Enterprise
- Server OS: Linux / Debian Bookworm
- Administration/package creation machine OS: Windows 10
olaplanche
Messages: 178
Registration: January 26, 2017 - 11:11

March 8, 2023 - 10:43

Good morning,

New version of the package on the front page.

I'm adding here the code for a package I needed to migrate an agent from one server to another during a migration (source).

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""

# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
server_name = "myserver.contoso.local"
client_port = "25840"
agent_password = "uninstall_password"

def install():
    # Initializing variables

    # Installing the package
    print("Moving Apex One Security Agent to server : %s" % server_name)
    run(r'"IpXfer\IpXfer_x64.exe" -s %s -p 8080 -sp 4343 -c %s -e "IpXfer\OfcNTCer.dat" -pwd %s' % (server_name,client_port,agent_password))


- Installed WAPT version: 2.6.0.16795 Enterprise
- Server OS: Linux / Debian Bookworm
- Administration/package creation machine OS: Windows 10
Locked