OWASP WebGoat インストール

owasp.org

意図的に脆弱性を入れ込んだ練習用アプリケーション。オープンソースコンポーネントを使用するJavaベースのアプリケーションに一般的に見られる脆弱性をテストできる。
WebGoat 8には、ほぼすべてのOWASPトップ10の脆弱性などに関するレッスンが含まれています。
 
警告1: このプログラムの実行中、マシンは攻撃に対して非常に脆弱になります。このプログラムを使用している間は、インターネットから切断する必要があります。WebGoatのデフォルト構成はローカルホストにバインドして、露出を最小限に抑えます。
 
警告2: このプログラムは教育目的のみです。許可なくこれらのテクニックを試みると、捕まる可能性が非常に高くなります。不正なハッキングに巻き込まれた場合、ほとんどの企業があなたを解雇します。あなたがセキュリティ調査を行っていたと主張することは、すべてのハッカーが最初に主張することであるため、機能しません。

WebWolf : ファイルアップロードや電子メールクライアントなどの補助プログラム。

実行方法は3つ。

  1. スタンドアローン
    https://github.com/WebGoat/WebGoat/releases から最新のWebGoatリリースをダウンロードして利用。

  2. Dockerを使用して実行

  3. docker-composeの利用

Dockerを使用して実行

WebGoat と WebWalf を個別に実行したらWebWolfがエラーで立ち上がらなかった。 WebGoat と WebWalf のセットみたいな別のコンテナを使ったらいけた。

WebGoat/README.MD at develop · WebGoat/WebGoat · GitHub

PS D:\hoge> docker run -p 8080:8080 -p 9090:9090 -e TZ=Asia/Tokyo webgoat/goatandwolf      
Starting nginx: nginx.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (jar:file:/home/webgoat/webgoat.jar!/BOOT-INF/lib/xnio-nio-3.3.8.Final.jar!/) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
16:02:11.194 [main] INFO org.owasp.webgoat.StartWebGoat - Starting WebGoat with args: --webgoat.build.version=8.1.0,--server.address=0.0.0.0

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)

2021-02-11 16:02:11.903  INFO 27 --- [           main] org.owasp.webgoat.StartWebGoat           : Starting StartWebGoat v8.1.0 on 422ead5382ce with PID 27 (/home/webgoat/webgoat.jar started by webgoat in /home/webgoat)
2021-02-11 16:02:11.904 DEBUG 27 --- [           main] org.owasp.webgoat.StartWebGoat           : Running with Spring Boot 
v2.2.2.RELEASE, Spring v5.2.2.RELEASE
(後略)

ブラウザで localhost:8080/WebGoat にアクセスする。

f:id:hirose-test:20210208003508j:plain

以下、失敗例。

https://hub.docker.com/r/webgoat/webgoat-8.0/

PS D:\hoge> docker pull webgoat/webgoat-8.0
Using default tag: latest
latest: Pulling from webgoat/webgoat-8.0
5e6ec7f28fb7: Pull complete
1cf4e4a3f534: Pull complete
5d9d21aca480: Pull complete
0a126fb8ec28: Pull complete
1904df324545: Pull complete
e6d9d96381c8: Pull complete
885c4a759329: Pull complete
970a9918b240: Pull complete
0320947fb529: Pull complete
Digest: sha256:e24bcaf41034c28b6a08aba94507a169ae23f2b87899e225a3d18fe8c36d26f5
Status: Downloaded newer image for webgoat/webgoat-8.0:latest
docker.io/webgoat/webgoat-8.0:latest

PS D:\hoge> docker images
REPOSITORY               TAG       IMAGE ID       CREATED        SIZE
webgoat/webgoat-8.0      latest    6664051b8808   8 months ago   380MB
docker/getting-started   latest    3c156928aeec   9 months ago   24.8MB

PS D:\hoge> docker run -p 8080:8080 -t webgoat/webgoat-8.0
02:28:58.561 [main] INFO org.owasp.webgoat.StartWebGoat - Starting WebGoat with args: --server.port=8080,--server.address=0.0.0.0

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)

2021-02-07 02:28:59.286  INFO 1 --- [           main] org.owasp.webgoat.StartWebGoat           : Starting StartWebGoat v8.1.0 on 9913d4af2f47 with PID 1 (/home/webgoat/webgoat.jar 
started by webgoat in /home/webgoat)
(後略)

WebWolf のインストール

ファイルアップロードや電子メールクライアントなどの補助プログラム。

PS D:\hoge> docker pull webgoat/webwolf
Using default tag: latest
latest: Pulling from webgoat/webwolf
5e6ec7f28fb7: Already exists
1cf4e4a3f534: Already exists
5d9d21aca480: Already exists
0a126fb8ec28: Already exists
1904df324545: Already exists
e6d9d96381c8: Already exists
2fb6ac8a8efc: Pull complete
0c7dc85d3c42: Pull complete
c96fa3c8c36f: Pull complete
Digest: sha256:1bcf794e1e0d09188219d2c22f8c19007038afdd1a6102a71e991c36df6d9160
Status: Downloaded newer image for webgoat/webwolf:latest
docker.io/webgoat/webwolf:latest

PS D:\jpge> docker run -p 9090:9090 -t webgoat/webwolf
 Waiting for database to be available...

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)

2021-02-07 02:54:26.015  INFO 8 --- [           main] org.owasp.webwolf.WebWolf                : Starting WebWolf v8.1.0 on efd94f4aaa2e with PID 8 (/home/webwolf/webwolf.jar started by webwolf in /)
(後略)

なんかエラー出た。

2021-02-11 05:47:53.911 ERROR 8 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : java.net.ConnectException: Connection refused (Connection refused)

2021-02-11 05:47:53.915 WARN 8 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution

2021-02-11 05:47:53.929 INFO 8 --- [ main] ConditionEvaluationReportLoggingListener :


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2021-02-11 05:47:53.934 ERROR 8 --- [ main] o.s.boot.SpringApplication : Application run failed


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]

WebWolf Could not obtain connection to query metadata : java.net.ConnectException: Connection refused: connect · Issue #750 · WebGoat/WebGoat · GitHub

後で調べる。

C:\Users\shink>java -version openjdk version "13.0.2" 2020-01-14 OpenJDK Runtime Environment (build 13.0.2+8) OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)

docker-compse を使用して実行。

VSCode のターミナルから。

WebGoat イメージの入手

PS D:\hoge> docker pull webgoat/webgoat-8.0

作業ディレクトリを作成

PS D:\hoge> mkdir compose_wp

作業ディレクトリに移動

PS D:\hoge> cd compose_wp  
PS D:\hoge\compose_wp> curl https://raw.githubusercontent.com/WebGoat/WebGoat/develop/docker-compose.yml | docker-compose -f - up

こちらも失敗
/* -----codeの行番号----- */