Created
October 30, 2024 14:32
-
-
Save Pelirrojo/5f795e8775d08dd46c904ee0f032991a to your computer and use it in GitHub Desktop.
Phase 2: Enhanced Protection | Implement Custom WAF Rules for Pattern Matching
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
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween | |
# https://blog.evereven.tech | |
# Create a WebACL Group Rule (replace [SUSPICIOUS_AGENT_IN_BASE64]) | |
aws wafv2 create-rule-group \ | |
--name "pattern-matching-rules" \ | |
--scope REGIONAL \ | |
--capacity 1000 \ | |
--visibility-config \ | |
MetricName=DDOSRuleMetric,SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true \ | |
--rules '[ | |
{ | |
"Name": "BadUserAgentRule", | |
"Priority": 2, | |
"VisibilityConfig": { | |
"SampledRequestsEnabled": true, | |
"CloudWatchMetricsEnabled": true, | |
"MetricName": "RateBasedRuleMetric" | |
}, | |
"Statement": { | |
"ByteMatchStatement": { | |
"SearchString": "[SUSPICIOUS_AGENT_IN_BASE64]", | |
"FieldToMatch": { | |
"SingleHeader": { | |
"Name": "user-agent" | |
} | |
}, | |
"TextTransformations": [ | |
{ | |
"Priority": 1, | |
"Type": "NONE" | |
} | |
], | |
"PositionalConstraint": "CONTAINS" | |
} | |
}, | |
"Action": { | |
"Block": {} | |
} | |
} | |
]' | |
# Check at: | |
# https://us-east-1.console.aws.amazon.com/wafv2/homev2/rule-groups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment