07-21-2020 04:50 AM - edited 04-09-2021 03:04 AM
NEWS: Cisco hosted SecureX Integration Modules
Cisco Secure is moving forward with Cisco hosted SecureX Integration Modules, where you do not need Serverless or docker any more. Find details in Part 1 of the documentation.
If you are moving to the Cisco hosted version of the Integration Modules the steps below are not necessary.
This steps explains some easy steps to configure, upload and integrate 3rd Party enrichment modules.
There are just some simple steps to do. The following steps are similar to all of the modules available on Github.
Before we start, let us clone a Template GitHub Repository, because it also includes a Python Script we need later to configure the JWT token.
Step: JWT Source (not necessary any more): Clone the JWT Token Git Repository to download the Python Script for the token generation we need later: git clone https://github.com/CiscoSecurity/tr-05-jwt-generator.git.
Note: Cisco constantly enhances the 3rd Party integrations. The JWT Token generation is now implemented as a command line tool. So you can skip this step.
Step: Download: The module points directly to Github. Just click the ".... Serverless Relay" link.
In the GitHub UI click "Code" to get the dropdown including Link for cloning.
Note: When executing the following commands, it is essential to do this in the right folder!
Step: Download: Start the virtual environment, if not already started, using the command line: source securex/bin/activate
Note: you must be in the directory /usr/local/SecureX, otherwise the virtual environment cannot be started.
Step: Download: In the root folder of our virtual environment type the following command.
As seen in the screenshot above (using AbuseIPDB as an example):
git clone https://github.com/CiscoSecurity/tr-05-serverless-abuseipdb.git.
1
2
3
4
5
6
7
8
9
10
11
|
(securex) sh-3.2 # pwd /usr/local/SecureX (securex) sh-3.2 # git clone https://github.com/CiscoSecurity/tr-05-serverless-abuseipdb.git Cloning into 'tr-05-serverless-abuseipdb' ... remote: Enumerating objects: 107, done . remote: Counting objects: 100% (107 /107 ), done . remote: Compressing objects: 100% (77 /77 ), done . remote: Total 398 (delta 55), reused 51 (delta 29), pack-reused 291 Receiving objects: 100% (398 /398 ), 103.09 KiB | 235.00 KiB /s , done . Resolving deltas: 100% (245 /245 ), done . (securex) sh-3.2 #
|
Note: Always do this step, some modules may need different libraries to work probably. There will not be any issue with your deployment. The needed components are listed in the requirements.txt file.
We already downloaded the necessary source. This section describes how to generate all Tokens we need for the SecureX Integration authentication bearer and the AWS SECRET_KEY value.
Note: There are Modules available which to not need any Authentication Bearer, e.g. like the Shodan Module. So you can skip the JWT Token generation. Always take a look for specific Module Settings on GitHub.
Step: JWT Token: Generate an API key from the 3rd Party Vendor. Many of them a providing community
or free APIs which can be used to test the Integration. Follow the steps and guides as outlined there.
Note: In August 2020 we simplified the token generation, so you do not need to copy the jwt_generator.py file any more. All necessary files are already included when cloning the tr-05-serverless-relay code from Github and afterwards updating the app.
Execute the following commands to upgrade an existing virtual environment starting in directory /usr/local/SecureX/tr-05-serverless-relay/.
1. Update the local code: git pull
This updates the requirements.txt file
2. Install the latest components including the jwt command line tool: pip install --upgrade --requirement requirements.txt
Switch into the directory: cd /usr/local/SecureX/tr-05-serverless-abuseipdb/
Generate the JWT token using the command: jwt dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
(securex) sh-3.2 # pwd /usr/local/SecureX/tr-05-serverless-abuseipdb (securex) sh-3.2 # jwt dev Enter: Abuse IPDB API Key: FhFUAjPqS1mRFXUnb09eCXeiq7uSr0azbl2PF0fDcxxxxxxxxxx The JWT for the AbuseIPDB IP Checker module is: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJGaEZVQWpQcVMxbVJGxxxxxxxxxx The SECRET_KEY to validate the JWT is: 6QKh6b77pyCfEQYjanlTre2LyHoaY4vVJmw8YdbIIyWylxxxxxxxxx Use this URL to navigate to the AWS Console and configure the SECRET_KEY environment variable using the above value: https: //console .aws.amazon.com /lambda/home ?region=us-east-1 #/functions/tr-abuseipdb-relay-dev/edit/environment-variables?tab=configuration Use one of these URLs to navigate to Threat Response in your region and create the AbuseIPDB IP Checker module using your Lambda's URL and the JWT: US: https: //visibility .amp.cisco.com /settings/modules/available/07aedd54-aaed-43d0-b862-xxxxxxxxxxxx/new EU: https: //visibility .eu.amp.cisco.com /settings/modules/available/4b4b5ea4-fc3f-43d3-95b7-xxxxxxxxxxxx/new APJC: https: //visibility .apjc.amp.cisco.com /settings/modules/available/e97eecc4-6680-42d2-bb14-xxxxxxxxxxxx/new (securex) sh-3.2 # |
Copy the output, you will need the generated tokens later.
Now let us upload the Application to AWS:
Step: Upload/Deploy Package: Before uploading the WebApp to AWS, we have to ensure, that the s3_Package which is generated during upload, is unique. To do so, we have to modify the zappa_settings.json file.
The easies way is to add your AWS AccountID to the s3_bucket definition in the zappa_settings.json file.
{ "dev": { "app_function": "app.app", "aws_region": "us-east-1", "exclude": [".*", "*.json", "*.md", "*.txt"], "keep_warm": false, "log_level": "INFO", "manage_roles": false, "profile_name": "serverless", "project_name": "tr-abuseipdb-relay", "role_name": "tr-serverless-relay-ZappaLambdaExecutionRole", "runtime": "python3.7", "s3_bucket": "zappa-tr-abuseipdb-relay-XXXXXXXXXXXX" } }
Step: Upload/Deploy Package: Deploy the App to AWS using the following Command: zappa deploy dev.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
(securex) sh-3.2 # pwd /usr/local/SecureX/tr-05-serverless-abuseipdb (securex) sh-3.2 # zappa deploy dev Calling deploy for stage dev.. Downloading and installing dependencies.. - markupsafe==1.1.1: Downloading 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 27.5k /27 .5k [00:00<00:00, 580kB /s ]
.
.
.
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4 /4 [00:23<00:00, 5.84s /res ] Deploying API Gateway.. . . . Your updated Zappa deployment is live!: https: //XXXXXXXXXX .execute-api.us-east-1.amazonaws.com /dev |
Note: You can check the URL and other settings by typing: zappa status dev.
The last configuration step is to add an environment variable to the Lambda function on AWS.
Add the necessary values to the Module Settings:
Repeat these steps to add other available integrations.
Note: In some cases i have seen an Error 502 message when deploying the serverless app.
|
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: