Trend Micro Web Security Custom Response Integration

Trend Micro Web Security Custom Response Integration

Before going through this article, check our Out-of-the-box App Integrations category. This is the recommended way to integrate the components of your cybersecurity stack with Lumu. If the product you are looking to integrate is there, it is advised to use that integration instead.
Due to the lack of API support from the Trend Micro Web Security solution, this example emulates the access and configuration steps a regular admin user would carry out to feed URLs into a Custom URL Category. This integration script is offered as-is. No further support will be provided. Any change in the authentication flow within Trend Micro Web Security will affect the operation of this script.
This article shows how to leverage the Lumu Defender API and the Trend Micro Web Security Custom URL Categories and Cloud Access Policies to mitigate security risks.



Requirements

  • Trend Micro Web Security Admin user.
    • Two-factor authentication must be disabled.
    • An administration user with email authentication is required
  • Lumu Defender API key. 
    • To retrieve an API token, please refer to the Defender API document.
  • Script host
    • Host with Python 3.10+ with Internet visibility over Lumu Defender endpoints and Trend Micro Web Security URLs.
  • Script package.

Set up Trend Micro Web Security

Define the Customized URL category name

Define the name you want to use for the Lumu Customized URL category. Make sure this name is unique and it is not used in another category.

If you use an existing category, the integration will overwrite its contents. By default, the integration script will create a category named Lumu.

Deploy the script

Script location

Unpack the deployed package provided by Lumu in your preferred path/folder. Keep in mind this location, as it will be required for further configurations. From now on, we will refer to this folder as <tmws_lumu_root> .

Install requirements

The file requirements.txt contains the list of dependencies for this data collector. After deploying the package locally, run the following command from the deployment folder:

pip install -r ./requirements.txt

Script details

To run the script, you must locate yourself on the path selected for deployment ( <tmws_lumu_root> ). Use the following command to show all options available for the package:

python3 lumu-tmws.py --help

Usage: lumu-tmws.py [options]

OptionsDescription
-h, --helpshow this help message and exit
--config CONFIGLoad options from config file
--company-key COMPANY_KEY--company_key COMPANY_KEYLumu Company Key (Defender API).
--proxy-host PROXY_HOST--proxy_host PROXY_HOSTProxy host (if required)
--proxy-port PROXY_PORT--proxy_port PROXY_PORTProxy port (if required)
--proxy-user PROXY_USER--proxy_user PROXY_USERProxy user (if required)
--proxy-password PROXY_PASSWORD--proxy_password PROXY_PASSWORDProxy password (if required)
--logging {screen,file}Logging option (default screen).
--verbose, -vVerbosity level.
--user USERNAME--username USERNAMETrend Micro Web Security user.
--password PASSWORDTrend Micro Web Security password.
--adversary-types {C2C,Malware,DGA,Mining,Spam,Phishing,Network Scan}--adversary_types {C2C,Malware,DGA,Mining,Spam,Phishing,Network Scan}Lumu adversary types to be filtered.
--days DAYSThe number of days backward from now to query Lumu incidents (default 30).
--custom-category CUSTOM_CATEGORY, --custom_category CUSTOM_CATEGORYCustom category to be populated. If it doesn't exist, the integration tries to create it (default Lumu).
--clean       Cleans all rules and objects created by the Lumu integration.

Usage examples

Use the following command to fetch and push all adversaries detected by Lumu in the last 30 days to Trend Micro Web Security Custom URL Category.

python3 lumu-tmws.py --username <tmws-username> --password <tmws-password> --company-key <lumu-defender-api-key>
By default, the integration script uses the Lumu custom category.

Use the following command to fetch and push all adversaries detected by Lumu in the last 30 days to a user-defined Trend Micro Web Security Custom URL Category.

python3 lumu-tmws.py --username <tmws-username> --password <tmws-password> --company-key <lumu-defender-api-key> --custom-category <tmws-custom-category>

Task: fetch Lumu detected adversaries filtering by type

To specify the types of adversaries you want to filter in your queries, use the option --adversary-types ADVERSARY-TYPE . If you need to set more types of adversaries, you can repeat the option as follows:

python3 lumu-tmws.py --username <tmws-username> --password <tmws-password> --company-key <lumu-defender-api-key> [--custom-category <tmws-custom-category>] --adversary-types C2C --adversary-types Mining

For this example, the script will fetch Lumu detected adversaries of types C2C and Mining .

Task: run with .config file

You can run the integration using a configuration file where you can save the required arguments in the form of <argument_name>=<value>, one argument per line. In the <sophos-lumu> path, save a file named .config with your configuration. Following, you have a sample of the format of the file.

  1. ## TMWS Lumu configuration file
    # TMWS
    username=<TMWS_USERNAME>
    password=<TMWS_PASSWORD>
    # If the category does not exist, the integration attempts to create it
    custom_category=<TMWS_CATEGORY>

    # Lumu
    company-key=<DEFENDER_KEY>

    # Misc
    days=30
    adversary-types=C2C
    adversary-types=Malware
    adversary-types=Mining
    adversary-types=Spam
    adversary-types=Phishing
If you need to add flags (arguments without values like -v or --clean, those need to be added on the command line). In the repo files, you will find a sample file named .config_sample. You can tailor its content according to your needs. Remember to rename it to .config before running the integration script.

Task: Clean records

When the script is run with the –clean flag, it will erase all Lumu records created.

python3 lumu-tmws.py --username <tmws-username> --password <tmws-password> --company-key <lumu-defender-api-key> [--custom-category <tmws-custom-category>] --clean
The integration script deletes the Custom category used for pushing the URLs. If you have Cloud Access Rules using it, you need to review manually the rules and modify them accordingly.

Task: save log output to file

Use the argument --logging file to store a record of all tasks run. Using this, the entire script output will be redirected to a file named lumu.log in the script root path ( <twms_lumu_root> ).

python3 lumu-tmws.py --username <tmws-username> --password <tmws-password> --company-key <lumu-defender-api-key> [--custom-category <tmws-custom-category>] --logging file

Other tasks

The above samples can be combined according to your needs.

Further considerations

To run the script on a timely basis, consider implementing a Scheduled task in Windows or a Cron task in Unix-based systems. We recommend that the scheduled job runs every 30 minutes.

Following, you have an example of how this Cron job should look using the recommended time.

*/30 * * * * python3 lumu-tmws.py --username <tmws-username> --password <tmws-password> --company-key <lumu-defender-api-key> [--custom-category <tmws-custom-category>] --logging file

It’s recommended to add the --logging file argument to any scheduled task. It will record all the output in the log file for further reference. If you have created a configuration file, your crontab entry doesn’t need arguments. It should look as follows:

*/30 * * * * python3 lumu-tmws.py

If you need to work with another scheduling time, you can use the crontab guru service.

To avoid race conditions, you can run only one instance. If you have one running, the second one will be canceled immediately.

Expected results

After running the script, all queried adversaries will be pushed into the selected Custom URL Category as follows:



Remember to use the selected Custom URL Category in a Cloud Access Rule with block action. Depending on the blocking configuration, you can show a warning to the end-user.


Troubleshooting and known issues

To identify failures in the script execution, use the -v flag. The script execution log will show more detailed information.

Another instance is running

If you receive the following error.

Error: Another instance is running. Quitting.

There could be another instance running. To check this, open the pid.pid file in the integration folder. This file stores the process id if it’s running. Search for this process in your system. The following pictures show the process in Windows and Linux.


If the previous validation indicates that another instance is running, please, check its progress using the integration’s log lumu.log .


        • Related Articles

        • Trend Micro Vision One (XDR) Custom Response Integration

          This article shows how to leverage the Lumu Defender API and Trend Micro Vision One (XDR) API to mitigate security risks. Requirements Trend Micro Vision One subscription Lumu Defender API key To retrieve an API token, please refer to the Defender ...
        • Trend Micro Apex Central Custom Response Integration

          Before going through this article, check our Out-of-the-box App Integrations category. This is the recommended way to integrate the components of your cybersecurity stack with Lumu. If the product you are looking to integrate is there, it is advised ...
        • Forcepoint Web Security Cloud Custom Response Integration

          This article shows how to leverage the Lumu Defender API and Forcepoint Web Security Cloud to mitigate security risks. Forcepoint Web Security Cloud service doesn't have a REST API, so this script simulates the actions run by an admin user to feed a ...
        • Bitdefender Custom Response Integration

          Bitdefender Custom Response Integration This article shows how to leverage the Lumu Defender API and Bitdefender API to mitigate security risks. Requirements GravityZone Business Security Enterprise, cloud version, ...
        • Infoblox Custom Response Integration

          Before going through this article, check our Out-of-the-box App Integrations category. This is the recommended way to integrate the components of your cybersecurity stack with Lumu. If the product you are looking to integrate is there, it is advised ...