CrowdSec
Identify Malicious IP addresses with the CrowdSec CTI API.
Data Enrichment & Threat Intelligence · CrowdSec
Details
| ID | CrowdSec |
|---|---|
| Provider | CrowdSec |
| Category | Data Enrichment & Threat Intelligence |
| From Version | 6.5.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Supported Modules | Agentix XSIAM |
README
Identify Malicious IP addresses with the CrowdSec CTI API.
Configure CrowdSec in Cortex
| Parameter | Description | Required |
|---|---|---|
| Source Reliability | Reliability of the source providing the intelligence data. | True |
| API Key | True | |
| Trust any certificate (not secure) | False | |
| Use system proxy settings | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
ip
Check the specified IP Address against the CrowdSec CTI.
Base Command
ip
Input
| Argument Name | Description | Required |
|---|---|---|
| ip | The IP Address to check. | Required |
Context Output
| Path | Type | Description | |
|---|---|---|---|
| CrowdSec.Info.ip_range_score | Number | The score of the IP Range | |
| CrowdSec.Info.ip | String | The IP address | |
| CrowdSec.Info.ip_range | String | The IP range | |
| CrowdSec.Info.as_name | String | The AS name | |
| CrowdSec.Info.as_num | Number | The AS number | |
| CrowdSec.Info.location.country | String | The country of the IP | |
| CrowdSec.Info.location.city | String | The city of the IP | |
| CrowdSec.Info.location.latitude | Number | The latitude of the IP | |
| CrowdSec.Info.location.longitude | Number | The longitude of the IP | |
| CrowdSec.Info.reverse_dns | String | The reverse DNS of the IP | |
| CrowdSec.Info.behaviors | Array | List of IP behaviors | |
| CrowdSec.Info.history.first_seen | Date | Date of the first time this IP was reported | |
| CrowdSec.Info.history.last_seen | Date | Date of the last time this IP was reported | |
| CrowdSec.Info.history.full_age | Number | Delta in days between first seen and today | |
| CrowdSec.Info.history.days_age | Number | Delta in days between first and last seen timestamps | |
| CrowdSec.Info.classifications.classifications | Array | A list of categories associated with the IP. Those data can be sourced from 3rd parties (i.e. tor exit nodes list) | |
| CrowdSec.Info.classifications.false_positives | Array | A list of false positives tags associated with the IP. Any IP with false_positives tags shouldn’t be considered as malicious | |
| CrowdSec.Info.classifications.classifications.description | String | ||
| CrowdSec.Info.attack_details | Array | A more exhaustive list of the scenarios for which a given IP was reported | |
| CrowdSec.Info.target_countries | Object | The top 10 reports repartition by country about the IP, as a percentage | |
| CrowdSec.Info.scores.overall.aggressiveness | Number | Overall aggressiveness score | |
| CrowdSec.Info.scores.overall.threat | Number | Overall threat score | |
| CrowdSec.Info.scores.overall.trust | Number | Overall trust score | |
| CrowdSec.Info.scores.overall.anomaly | Number | Overall anomaly score | |
| CrowdSec.Info.scores.overall.total | Number | Overall score | |
| CrowdSec.Info.scores.last_day.aggressiveness | Number | Last day aggressiveness score | |
| CrowdSec.Info.scores.last_day.threat | Number | Last day threat score | |
| CrowdSec.Info.scores.last_day.trust | Number | Last day trust score | |
| CrowdSec.Info.scores.last_day.anomaly | Number | Last day anomaly score | |
| CrowdSec.Info.scores.last_day.total | Number | Last day score | |
| CrowdSec.Info.scores.last_week.aggressiveness | Number | Last week aggressiveness score | |
| CrowdSec.Info.scores.last_week.threat | Number | Last week threat score | |
| CrowdSec.Info.scores.last_week.trust | Number | Last week trust score | |
| CrowdSec.Info.scores.last_week.anomaly | Number | Last week anomaly score | |
| CrowdSec.Info.scores.last_week.total | Number | Last week score | |
| CrowdSec.Info.scores.last_month.aggressiveness | Number | Last month aggressiveness score | |
| CrowdSec.Info.scores.last_month.threat | Number | Last month threat score | |
| CrowdSec.Info.scores.last_month.trust | Number | Last month trust score | |
| CrowdSec.Info.scores.last_month.anomaly | Number | Last month anomaly score | |
| CrowdSec.Info.scores.last_month.total | Number | Last month score | |
| IP.Address | String | The IP Address | . |
| DBotScore.Score | number | The actual score. | |
| DBotScore.Vendor | String | The vendor used to calculate the score. | |
| DBotScore.Type | String | The indicator type. | |
| DBotScore.Indicator | String | The indicator that was tested. |
Configuration parameters
integrationReliability— Source Reliability (required)apikey— API Key (required)insecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (1)
-
ipCheck the specified IP Address against the CrowdSec CTI.
""" Cortex XSOAR CrowdSec Integration Unit Tests """ import json from unittest.mock import MagicMock import pytest from CrowdSec import Client client = Client( base_url="dummy_url", verify=False, headers={}, proxy=False, ) RELIABILITY = "B - Usually reliable" def util_load_json(path): with open(path, encoding="utf-8") as f: return json.loads(f.read()) def test_ip_command(mocker): from CrowdSec import ip_command test_data = util_load_json("test_data/test_ip_command.json") args = test_data.get("args") mocker.patch( "CrowdSec.Client.get_ip_information", return_value=test_data.get("crowdsec_result"), ) response = ip_command(client, RELIABILITY, args) mock_response = test_data.get("mock_response") mock_outputs = mock_response.get("outputs") mock_readable_output = mock_response.get("readable_output") mock_outputs_prefix = mock_response.get("outputs_prefix") mock_outputs_key_field = mock_response.get("outputs_key_field") assert mock_outputs == response[0].outputs assert mock_readable_output == response[0].readable_output assert mock_outputs_prefix == response[0].outputs_prefix assert mock_outputs_key_field == response[0].outputs_key_field def test_unknown_ip_command(mocker): from CrowdSec import ip_command test_data = util_load_json("test_data/test_unknown_ip_command.json") args = test_data.get("args") mocker.patch( "CrowdSec.Client.get_ip_information", return_value=test_data.get("crowdsec_result"), ) response = ip_command(client, RELIABILITY, args) mock_response = test_data.get("mock_response") mock_outputs = mock_response.get("outputs") mock_readable_output = mock_response.get("readable_output") mock_outputs_prefix = mock_response.get("outputs_prefix") mock_outputs_key_field = mock_response.get("outputs_key_field") assert mock_outputs == response[0].outputs assert mock_readable_output == response[0].readable_output assert mock_outputs_prefix == response[0].outputs_prefix assert mock_outputs_key_field == response[0].outputs_key_field def test_ip_command_no_ip(mocker): from CrowdSec import ip_command expected_error = "'ip' argument not specified" with pytest.raises(ValueError, match=expected_error): ip_command(client, RELIABILITY, {}) def test_ip_command_invalid_ip(mocker): from CrowdSec import ip_command args = {"ip": "1.1.1"} expected_error = "Invalid IP '1.1.1'" with pytest.raises(ValueError, match=expected_error): ip_command(client, RELIABILITY, args) def test_rate_limit(mocker): from CrowdSec import ip_command args = {"ip": "1.2.3.4"} mock_response = MagicMock() mock_response.status_code = 429 mock_response.json.return_value = { "message": "Rate limited", } mocker.patch("CrowdSec.Client._http_request", return_value=mock_response) expected_error = "You have been rate limited by CrowdSec CTI API. Please upgrade to Pro or wait." with pytest.raises(Exception, match=expected_error): ip_command(client, RELIABILITY, args) def test_test_module(mocker): from CrowdSec import test_module mock_response = MagicMock() mock_response.status_code = 200 mock_response.json.return_value = {"ip": "1.1.1.1", "ip_range": "1.1.1.0/24"} mocker.patch("CrowdSec.Client.test_module", return_value=mock_response) resp = test_module(client) assert resp == "ok" def test_test_module_bad_apikey(mocker): from CrowdSec import test_module mock_response = MagicMock() mock_response.status_code = 403 mock_response.json.return_value = {"message": "Forbidden"} mocker.patch("CrowdSec.Client.test_module", return_value=mock_response) resp = test_module(client) assert resp == "Authorization Error: make sure API Key is correctly set" def test_test_module_no_connection(mocker): from CrowdSec import test_module mock_response = MagicMock() mock_response.status_code = 500 mock_response.json.return_value = {"message": "Something went wrong"} mocker.patch("CrowdSec.Client.test_module", return_value=mock_response) resp = test_module(client) assert resp == "Something went wrong"