-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add on_error and some example profiles
- Loading branch information
1 parent
c3bcf6f
commit 0f7800e
Showing
4 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
id: captcha_profile | ||
title: Captcha | ||
sidebar_position: 2 | ||
--- | ||
|
||
Here is an example of a profile that provides users with a captcha challenge when they trigger a HTTP scenario. | ||
|
||
```yaml | ||
name: captcha_remediation | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" && Alert.GetScenario() contains "http" | ||
## Any scenario with http in its name will trigger a captcha challenge | ||
decisions: | ||
- type: captcha | ||
duration: 4h | ||
on_success: break | ||
--- | ||
name: default_ip_remediation | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" | ||
decisions: | ||
- type: ban | ||
duration: 4h | ||
#duration_expr: "Sprintf('%dh', (GetDecisionsCount(Alert.GetValue()) + 1) * 4)" | ||
on_success: break | ||
``` | ||
However, you may want to provide a limit to captcha challenges within a period of time to a given IP address because they may ignore your captcha challenges and still cause load on your server. | ||
You can use the `GetDecisionsCount` or `GetDecisionsSinceCount` helper to achieve this: | ||
|
||
```yaml | ||
name: captcha_remediation | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" && Alert.GetScenario() contains "http" && GetDecisionsSinceCount(Alert.GetValue(), "24h") <= 3 | ||
## Same as above but only 3 captcha decision per 24 hours before ban | ||
decisions: | ||
- type: captcha | ||
duration: 4h | ||
on_success: break | ||
--- | ||
name: default_ip_remediation | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" | ||
decisions: | ||
- type: ban | ||
duration: 4h | ||
#duration_expr: "Sprintf('%dh', (GetDecisionsCount(Alert.GetValue()) + 1) * 4)" | ||
on_success: break | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
id: cti_profile | ||
title: CrowdSec CTI | ||
sidebar_position: 2 | ||
--- | ||
|
||
Here is an example of a profile that uses the CTI module to make decisions based on the background noise score of an IP address. | ||
|
||
:::info | ||
You **MUST** configure the CTI beforehand, see [CTI helpers](/expr/cti_helpers.md). | ||
::: | ||
|
||
```yaml | ||
name: high_bn_score | ||
on_error: continue | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" && CrowdsecCTI(Alert.GetValue()).GetBackgroundNoiseScore() > 6 && !CrowdsecCTI(Alert.GetValue()).IsFalsePositive() | ||
decisions: | ||
- type: ban | ||
duration: 24h | ||
on_success: break | ||
--- | ||
name: mid_bn_score | ||
on_error: continue | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" && CrowdsecCTI(Alert.GetValue()).GetBackgroundNoiseScore() >= 3 && !CrowdsecCTI(Alert.GetValue()).IsFalsePositive() | ||
decisions: | ||
- type: ban | ||
duration: 12h | ||
on_success: break | ||
--- | ||
name: default_ip_remediation | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" | ||
decisions: | ||
- type: ban | ||
duration: 4h | ||
#duration_expr: "Sprintf('%dh', (GetDecisionsCount(Alert.GetValue()) + 1) * 4)" | ||
on_success: break | ||
``` | ||
You could also use the background noise within the `duration_expr` to make the ban duration proportional to the background noise score: | ||
|
||
```yaml | ||
--- | ||
name: bn_score | ||
on_error: continue | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" && CrowdsecCTI(Alert.GetValue()).GetBackgroundNoiseScore() > 0 && !CrowdsecCTI(Alert.GetValue()).IsFalsePositive() | ||
decisions: | ||
- type: ban | ||
duration: 12h | ||
duration_expr: "Sprintf('%dm', (240 + (144 * CrowdsecCTI(Alert.GetValue()).GetBackgroundNoiseScore()))" | ||
## 240 minutes (4 hours) + 144 minutes (2 hours) per point of background noise score | ||
on_success: break | ||
--- | ||
name: default_ip_remediation | ||
filters: | ||
- Alert.Remediation == true && Alert.GetScope() == "Ip" | ||
decisions: | ||
- type: ban | ||
duration: 4h | ||
on_success: break | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters