Code Monkey home page Code Monkey logo

youve-been-hacked's Introduction

You've Been Hacked โ€” An Interactive Course on Web Security

An interactive web security course based on Carsten Eiler's book "You've Been Hacked", Rheinwerk Computing, 1st edition (ISBN 978-3-8362-4460-2).

Synopsys

This repository contains Dockerfiles, setup instructions, some code and write-ups for carrying out the experiments described in Carsten Eiler's book "You've Been Hacked" on security vulnerabilities in web applications. It also contains slides summarizing each chapter that can be used for teaching.

Creating Docker Containers

Running the demo web application in a Docker container is the easiest way to get started. The Docker directory in this repository contains the Dockerfile needed to build the Docker image with the vulnerable demo web application. You can build the image manually using Makefile or simply run docker-compose.

Running Dockers Containers

Using docker-compose

This is the easiest way to run the containers. Simply issue docker-compose up and docker-compose will take care of all configuration details:

$ docker-compose up
Creating network "docker_hacknet" with the default driver
Creating docker_zap_1     ... done
Creating docker_vulnapp_1 ... done
Attaching to docker_zap_1, docker_vulnapp_1
vulnapp_1  |  * Starting web server apache2
vulnapp_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.3. Set the 'ServerName' directive globally to suppress this message
zap_1      | Using ZAP command line options: -host 0.0.0.0 -port 8090
vulnapp_1  |  * 
vulnapp_1  |  * Starting MySQL database server mysqld
vulnapp_1  |    ...done.
vulnapp_1  |  * Checking for tables which need an upgrade, are corrupt or were 
vulnapp_1  | not closed cleanly.

Using docker container run

If you prefer to run the containers manually, you first need to create a new Docker network:

$ docker network create -d bridge hack-network

Next, you need to start the container with the vulnerable app:

$ docker container run --rm -it -p 8888:80 --network="hack-network" -v $(PWD)/tmp:/opt/tmp youve-been-hacked

Note that for the above command, you will need an empty directory tmp in the directory where you run this command.

and the container with ZAProxy:

$ docker container run -u zap -p 8080:8080 -p 8090:8090 --network="hack-network" -i owasp/zap2docker-stable zap-webswing.sh

If everything went well, you should see two containers with docker container ps:

$  docker container ps -a                                                                   
CONTAINER ID        IMAGE                     COMMAND             CREATED              STATUS                      PORTS                                            NAMES
eb264e004d2a        owasp/zap2docker-stable   "zap-webswing.sh"   58 seconds ago       Up 57 seconds (unhealthy)   0.0.0.0:8080->8080/tcp, 0.0.0.0:8090->8090/tcp   kind_cohen
9ea057ec1cea        youve-been-hacked         "/bin/bash"         About a minute ago   Up About a minute           0.0.0.0:8888->80/tcp                             exciting_maxwell
$

Setting up ZAProxy

As described in this post, you will need to activate ZAProxy (ZAP), configure your browser to proxy via ZAP and import the public ZAP Root certificate so that it is trusted to sign websites. You can create a separate browser profile for proxying through ZAP (see this page for Firefox).

First, fire up your web browser and visit http://127.0.0.1:8080/zap/. You'll see how the ZAP Web UI starts. Start a ZAP session (you can choose "I do not want to persist this session at this moment in time"). Select "Update All" in the "Manage Add-ons" window.

zap

Next, go to "Tools" -> "Options" -> "Dynamic SSL Certificates" -> "Save" and save the ZAP certificate on your host and import it into your browser. Read off the IP address and port number at the bottom of ZAP's window and configure your web browser to use that IP/port as proxy.

Accessing the Vulnerable Web App through ZAP

You're now ready to play with the vulnerable demo app. If you started the containers using docker-compose, you need to look up the vulnerable app container IP address. Run docker container inspect docker_vulnapp_1 and look for IPAddress: under Networks:. Assuming that this IP address on your machine is 172.18.0.3, you can access the vulnerable app (through ZAP) using http://172.18.0.3/daten/kapitel1.html. (Within the Docker network, vulnerable app container exposes its port 80; since 80 is a standard port for HTTP, you don't need to write it out explicitly).

If you started the Docker containers manually, the above might not work for you. In that case, try http://host.docker.internal:8888/daten/kapitel1.html and you should see the web application. You must use host.docker.internal instead of 127.0.0.1 when proxying through ZAP. Otherwise, your HTTP request would be resolved to the localhost of the Docker container where ZAP is running and you would get a "connection refused" warning and a Bad Gateway response.

References

youve-been-hacked's People

Contributors

duplys avatar

Stargazers

 avatar  avatar

Watchers

 avatar

youve-been-hacked's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.